dtolnay / paste

Macros for all your token pasting needs
Apache License 2.0
983 stars 53 forks source link

Conflict with extended_key_value_attributes #63

Closed dtolnay closed 3 years ago

dtolnay commented 3 years ago

The following macro call compiles successfully on every rustc from 1.31.0 through 1.46.0:

macro_rules! repro {
    ($doc:expr) => {
        paste::item! {
            #[doc = $doc]
            pub struct Struct;
        }
    };
}

macro_rules! call {
    ($name:ident) => {
        repro!(stringify!($name));
    };
}

call!(documentation);

However 1.47.0 started failing with:

error: unexpected token: `stringify`
  --> src/main.rs:3:9
   |
3  | /         paste::item! {
4  | |             #[doc = $doc]
5  | |             pub struct Struct;
6  | |         }
   | |_________^
...
16 |   call!(documentation);
   |   --------------------- in this macro invocation
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

And with a somewhat different message since 1.50.0:

error[E0658]: arbitrary expressions in key-value attributes are unstable
  --> src/main.rs:12:16
   |
12 |         repro!(stringify!($name));
   |                ^^^^^^^^^^^^^^^^^
...
16 | call!(documentation);
   | --------------------- in this macro invocation
   |
   = note: see issue #78835 <https://github.com/rust-lang/rust/issues/78835> for more information
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)