Skip to content

[nightly regression] rustc incorrectly parses attributes as macro invocations in nightly-2018-08-18 #53583

Closed
@jchlapinski

Description

@jchlapinski

In the newest nightly all attributes with names identical to existing macros are parsed as macro invocation (note the lack of ! at the front of dummy in the example below).
Previous version nightly-2018-08-17 works as expected.
This breaks compilation of some of our custom derives, using same name for attributes and macros, which was previously allowed.

I tried this code:

macro_rules! dummy {
    ($x:expr) => {
        println!("dummy: {}", $x)
    }
}

#[dummy("text")] // this should not be regarded as a `dummy` macro invocation, should it?
struct SampleStruct {

}

fn main() {
    dummy!("text");
}

I expected this to complain about unknown custom attribute dummy

Instead, I got this error:

error: macro `dummy` may not be used in attributes
 --> src/main.rs:7:1
  |
7 | #[dummy("text")]
  | ^^^^^^^^^^^^^^^^

Meta

rustc --version --verbose:

rustc 1.30.0-nightly (33b923fd4 2018-08-18)
binary: rustc
commit-hash: 33b923fd44c5c5925e635815fce68bdf1f98740f
commit-date: 2018-08-18
host: x86_64-unknown-linux-gnu
release: 1.30.0-nightly
LLVM version: 7.0

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyP-highHigh priorityT-langRelevant to the language team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions