resolve/expand: Improve attribute expansion on macro definitions and calls
This commit is contained in:
parent
46c35c76fe
commit
d81c1946c6
8 changed files with 63 additions and 40 deletions
15
src/test/ui/attributes/key-value-expansion-on-mac.rs
Normal file
15
src/test/ui/attributes/key-value-expansion-on-mac.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#![feature(extended_key_value_attributes)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_dummy = stringify!(a)] // OK
|
||||
macro_rules! bar {
|
||||
() => {};
|
||||
}
|
||||
|
||||
// FIXME?: `bar` here expands before `stringify` has a chance to expand.
|
||||
// `#[rustc_dummy = ...]` is validated and dropped during expansion of `bar`,
|
||||
// the "unexpected token" errors comes from the validation.
|
||||
#[rustc_dummy = stringify!(b)] //~ ERROR unexpected token: `stringify!(b)`
|
||||
bar!();
|
||||
|
||||
fn main() {}
|
||||
8
src/test/ui/attributes/key-value-expansion-on-mac.stderr
Normal file
8
src/test/ui/attributes/key-value-expansion-on-mac.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error: unexpected token: `stringify!(b)`
|
||||
--> $DIR/key-value-expansion-on-mac.rs:12:17
|
||||
|
|
||||
LL | #[rustc_dummy = stringify!(b)]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -172,12 +172,6 @@ warning: unknown lint: `x5100`
|
|||
LL | #[deny(x5100)] impl S { }
|
||||
| ^^^^^
|
||||
|
||||
warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:438:1
|
||||
|
|
||||
LL | #[macro_escape]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:441:17
|
||||
|
|
||||
|
|
@ -186,6 +180,12 @@ LL | mod inner { #![macro_escape] }
|
|||
|
|
||||
= help: try an outer attribute: `#[macro_use]`
|
||||
|
||||
warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:438:1
|
||||
|
|
||||
LL | #[macro_escape]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
warning: use of deprecated attribute `plugin_registrar`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:228:17
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: arguments to `macro_use` are not allowed here
|
||||
--> $DIR/issue-43106-gating-of-macro_use.rs:6:1
|
||||
--> $DIR/issue-43106-gating-of-macro_use.rs:12:17
|
||||
|
|
||||
LL | #![macro_use(my_macro)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | mod inner { #![macro_use(my_macro)] }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arguments to `macro_use` are not allowed here
|
||||
--> $DIR/issue-43106-gating-of-macro_use.rs:9:1
|
||||
|
|
@ -11,10 +11,10 @@ LL | #[macro_use(my_macro)]
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arguments to `macro_use` are not allowed here
|
||||
--> $DIR/issue-43106-gating-of-macro_use.rs:12:17
|
||||
--> $DIR/issue-43106-gating-of-macro_use.rs:6:1
|
||||
|
|
||||
LL | mod inner { #![macro_use(my_macro)] }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #![macro_use(my_macro)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: malformed `macro_use` attribute input
|
||||
--> $DIR/issue-43106-gating-of-macro_use.rs:15:5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue