Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
qnighy opened this issue May 29, 2017 · 0 comments
Closed

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

qnighy opened this issue May 29, 2017 · 0 comments
Labels
A-parser Area: The lexing & parsing of Rust source code to an AST

Comments

@qnighy
Copy link
Contributor

qnighy commented May 29, 2017

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)

@petrochenkov petrochenkov added the A-parser Area: The lexing & parsing of Rust source code to an AST label May 29, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue May 31, 2017
…chenkov

Parse macros named "default" correctly.

Fixes rust-lang#42292.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-parser Area: The lexing & parsing of Rust source code to an AST
Projects
None yet
Development

No branches or pull requests

2 participants