Skip to content

Commit 3c4066d

Browse files
committed
Add a test for resolving macro_rules calls inside attributes
1 parent a83f933 commit 3c4066d

File tree

2 files changed

+202
-0
lines changed

2 files changed

+202
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#![doc = in_root!()] // FIXME, this is a bug
2+
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
3+
#![doc = in_mod_escape!()] // FIXME, this is a bug
4+
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
5+
6+
#[doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope
7+
#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
8+
#[doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope
9+
#[doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
10+
fn before() {
11+
#![doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope
12+
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
13+
#![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope
14+
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
15+
}
16+
17+
macro_rules! in_root { () => { "" } }
18+
19+
mod macros_stay {
20+
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
21+
22+
macro_rules! in_mod { () => { "" } }
23+
24+
#[doc = in_mod!()] // OK
25+
fn f() {
26+
#![doc = in_mod!()] // OK
27+
}
28+
}
29+
30+
#[macro_use]
31+
mod macros_escape {
32+
#![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope
33+
34+
macro_rules! in_mod_escape { () => { "" } }
35+
36+
#[doc = in_mod_escape!()] // OK
37+
fn f() {
38+
#![doc = in_mod_escape!()] // OK
39+
}
40+
}
41+
42+
fn block() {
43+
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
44+
45+
macro_rules! in_block { () => { "" } }
46+
47+
#[doc = in_block!()] // OK
48+
fn f() {
49+
#![doc = in_block!()] // OK
50+
}
51+
}
52+
53+
#[doc = in_root!()] // OK
54+
#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
55+
#[doc = in_mod_escape!()] // OK
56+
#[doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
57+
fn after() {
58+
#![doc = in_root!()] // OK
59+
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
60+
#![doc = in_mod_escape!()] // OK
61+
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
62+
}
63+
64+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
error: cannot find macro `in_mod` in this scope
2+
--> $DIR/key-value-expansion-scope.rs:2:10
3+
|
4+
LL | #![doc = in_mod!()]
5+
| ^^^^^^
6+
|
7+
= help: have you added the `#[macro_use]` on the module/import?
8+
9+
error: cannot find macro `in_block` in this scope
10+
--> $DIR/key-value-expansion-scope.rs:4:10
11+
|
12+
LL | #![doc = in_block!()]
13+
| ^^^^^^^^
14+
|
15+
= help: have you added the `#[macro_use]` on the module/import?
16+
17+
error: cannot find macro `in_root` in this scope
18+
--> $DIR/key-value-expansion-scope.rs:6:9
19+
|
20+
LL | #[doc = in_root!()]
21+
| ^^^^^^^
22+
|
23+
= help: have you added the `#[macro_use]` on the module/import?
24+
25+
error: cannot find macro `in_mod` in this scope
26+
--> $DIR/key-value-expansion-scope.rs:7:9
27+
|
28+
LL | #[doc = in_mod!()]
29+
| ^^^^^^
30+
|
31+
= help: have you added the `#[macro_use]` on the module/import?
32+
33+
error: cannot find macro `in_mod_escape` in this scope
34+
--> $DIR/key-value-expansion-scope.rs:8:9
35+
|
36+
LL | #[doc = in_mod_escape!()]
37+
| ^^^^^^^^^^^^^
38+
|
39+
= help: have you added the `#[macro_use]` on the module/import?
40+
41+
error: cannot find macro `in_block` in this scope
42+
--> $DIR/key-value-expansion-scope.rs:9:9
43+
|
44+
LL | #[doc = in_block!()]
45+
| ^^^^^^^^
46+
|
47+
= help: have you added the `#[macro_use]` on the module/import?
48+
49+
error: cannot find macro `in_root` in this scope
50+
--> $DIR/key-value-expansion-scope.rs:11:14
51+
|
52+
LL | #![doc = in_root!()]
53+
| ^^^^^^^
54+
|
55+
= help: have you added the `#[macro_use]` on the module/import?
56+
57+
error: cannot find macro `in_mod` in this scope
58+
--> $DIR/key-value-expansion-scope.rs:12:14
59+
|
60+
LL | #![doc = in_mod!()]
61+
| ^^^^^^
62+
|
63+
= help: have you added the `#[macro_use]` on the module/import?
64+
65+
error: cannot find macro `in_mod_escape` in this scope
66+
--> $DIR/key-value-expansion-scope.rs:13:14
67+
|
68+
LL | #![doc = in_mod_escape!()]
69+
| ^^^^^^^^^^^^^
70+
|
71+
= help: have you added the `#[macro_use]` on the module/import?
72+
73+
error: cannot find macro `in_block` in this scope
74+
--> $DIR/key-value-expansion-scope.rs:14:14
75+
|
76+
LL | #![doc = in_block!()]
77+
| ^^^^^^^^
78+
|
79+
= help: have you added the `#[macro_use]` on the module/import?
80+
81+
error: cannot find macro `in_mod` in this scope
82+
--> $DIR/key-value-expansion-scope.rs:20:14
83+
|
84+
LL | #![doc = in_mod!()]
85+
| ^^^^^^
86+
|
87+
= help: have you added the `#[macro_use]` on the module/import?
88+
89+
error: cannot find macro `in_mod_escape` in this scope
90+
--> $DIR/key-value-expansion-scope.rs:32:14
91+
|
92+
LL | #![doc = in_mod_escape!()]
93+
| ^^^^^^^^^^^^^
94+
|
95+
= help: have you added the `#[macro_use]` on the module/import?
96+
97+
error: cannot find macro `in_block` in this scope
98+
--> $DIR/key-value-expansion-scope.rs:43:14
99+
|
100+
LL | #![doc = in_block!()]
101+
| ^^^^^^^^
102+
|
103+
= help: have you added the `#[macro_use]` on the module/import?
104+
105+
error: cannot find macro `in_mod` in this scope
106+
--> $DIR/key-value-expansion-scope.rs:54:9
107+
|
108+
LL | #[doc = in_mod!()]
109+
| ^^^^^^
110+
|
111+
= help: have you added the `#[macro_use]` on the module/import?
112+
113+
error: cannot find macro `in_block` in this scope
114+
--> $DIR/key-value-expansion-scope.rs:56:9
115+
|
116+
LL | #[doc = in_block!()]
117+
| ^^^^^^^^
118+
|
119+
= help: have you added the `#[macro_use]` on the module/import?
120+
121+
error: cannot find macro `in_mod` in this scope
122+
--> $DIR/key-value-expansion-scope.rs:59:14
123+
|
124+
LL | #![doc = in_mod!()]
125+
| ^^^^^^
126+
|
127+
= help: have you added the `#[macro_use]` on the module/import?
128+
129+
error: cannot find macro `in_block` in this scope
130+
--> $DIR/key-value-expansion-scope.rs:61:14
131+
|
132+
LL | #![doc = in_block!()]
133+
| ^^^^^^^^
134+
|
135+
= help: have you added the `#[macro_use]` on the module/import?
136+
137+
error: aborting due to 17 previous errors
138+

0 commit comments

Comments
 (0)