Skip to content

A macro named default can't be called in an impl #42292

Closed
@qnighy

Description

@qnighy

There is a corner case where the weak (contextual) keyword default can't be used in an identifier position. It occurs when a macro whose path starts with default is called inside an impl.

macro_rules! foo {
    ($($x:tt)*) => { $($x)* }
}
macro_rules! default {
    ($($x:tt)*) => { $($x)* }
}

struct A;
impl A {
    foo! { fn bar() {} }
    default! { fn baz() {} } // ERROR
}

fn main() {
    A::bar();
    A::baz();
}

Expected behavior: it compiles.

Observed behavior: parse error.

Version: rustc 1.19.0-nightly (28fd1e519 2017-05-27)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The lexing & parsing of Rust source code to an AST

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions