Add a test for resolving macro_rules calls inside attributes
(cherry picked from commit 3c4066d112)
This commit is contained in:
parent
4fa46ffbe4
commit
d0b047410d
2 changed files with 202 additions and 0 deletions
64
tests/ui/attributes/key-value-expansion-scope.rs
Normal file
64
tests/ui/attributes/key-value-expansion-scope.rs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#![doc = in_root!()] // FIXME, this is a bug
|
||||
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
|
||||
#![doc = in_mod_escape!()] // FIXME, this is a bug
|
||||
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
|
||||
|
||||
#[doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope
|
||||
#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
|
||||
#[doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope
|
||||
#[doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
|
||||
fn before() {
|
||||
#![doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope
|
||||
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
|
||||
#![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope
|
||||
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
|
||||
}
|
||||
|
||||
macro_rules! in_root { () => { "" } }
|
||||
|
||||
mod macros_stay {
|
||||
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
|
||||
|
||||
macro_rules! in_mod { () => { "" } }
|
||||
|
||||
#[doc = in_mod!()] // OK
|
||||
fn f() {
|
||||
#![doc = in_mod!()] // OK
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_use]
|
||||
mod macros_escape {
|
||||
#![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope
|
||||
|
||||
macro_rules! in_mod_escape { () => { "" } }
|
||||
|
||||
#[doc = in_mod_escape!()] // OK
|
||||
fn f() {
|
||||
#![doc = in_mod_escape!()] // OK
|
||||
}
|
||||
}
|
||||
|
||||
fn block() {
|
||||
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
|
||||
|
||||
macro_rules! in_block { () => { "" } }
|
||||
|
||||
#[doc = in_block!()] // OK
|
||||
fn f() {
|
||||
#![doc = in_block!()] // OK
|
||||
}
|
||||
}
|
||||
|
||||
#[doc = in_root!()] // OK
|
||||
#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
|
||||
#[doc = in_mod_escape!()] // OK
|
||||
#[doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
|
||||
fn after() {
|
||||
#![doc = in_root!()] // OK
|
||||
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
|
||||
#![doc = in_mod_escape!()] // OK
|
||||
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
138
tests/ui/attributes/key-value-expansion-scope.stderr
Normal file
138
tests/ui/attributes/key-value-expansion-scope.stderr
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
error: cannot find macro `in_mod` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:2:10
|
||||
|
|
||||
LL | #![doc = in_mod!()]
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_block` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:4:10
|
||||
|
|
||||
LL | #![doc = in_block!()]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_root` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:6:9
|
||||
|
|
||||
LL | #[doc = in_root!()]
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_mod` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:7:9
|
||||
|
|
||||
LL | #[doc = in_mod!()]
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_mod_escape` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:8:9
|
||||
|
|
||||
LL | #[doc = in_mod_escape!()]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_block` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:9:9
|
||||
|
|
||||
LL | #[doc = in_block!()]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_root` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:11:14
|
||||
|
|
||||
LL | #![doc = in_root!()]
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_mod` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:12:14
|
||||
|
|
||||
LL | #![doc = in_mod!()]
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_mod_escape` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:13:14
|
||||
|
|
||||
LL | #![doc = in_mod_escape!()]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_block` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:14:14
|
||||
|
|
||||
LL | #![doc = in_block!()]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_mod` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:20:14
|
||||
|
|
||||
LL | #![doc = in_mod!()]
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_mod_escape` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:32:14
|
||||
|
|
||||
LL | #![doc = in_mod_escape!()]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_block` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:43:14
|
||||
|
|
||||
LL | #![doc = in_block!()]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_mod` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:54:9
|
||||
|
|
||||
LL | #[doc = in_mod!()]
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_block` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:56:9
|
||||
|
|
||||
LL | #[doc = in_block!()]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_mod` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:59:14
|
||||
|
|
||||
LL | #![doc = in_mod!()]
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: cannot find macro `in_block` in this scope
|
||||
--> $DIR/key-value-expansion-scope.rs:61:14
|
||||
|
|
||||
LL | #![doc = in_block!()]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: have you added the `#[macro_use]` on the module/import?
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue