Skip to content

Commit 7aaf0de

Browse files
committed
Add a test for $crate inside macro invocation
1 parent b8ec4c4 commit 7aaf0de

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//~ ERROR expected type, found `$`
2+
3+
// edition:2018
4+
// aux-build:test-macros.rs
5+
6+
// Anonymize unstable non-dummy spans while still showing dummy spans `0..0`.
7+
// normalize-stdout-test "bytes\([^0]\w*\.\.(\w+)\)" -> "bytes(LO..$1)"
8+
// normalize-stdout-test "bytes\((\w+)\.\.[^0]\w*\)" -> "bytes($1..HI)"
9+
10+
#![feature(proc_macro_hygiene)]
11+
12+
#[macro_use]
13+
extern crate test_macros;
14+
15+
type S = u8;
16+
17+
macro_rules! m { () => {
18+
#[print_attr]
19+
struct A(identity!($crate::S));
20+
}}
21+
22+
m!();
23+
24+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: expected type, found `$`
2+
3+
error: aborting due to previous error
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
PRINT-ATTR INPUT (DISPLAY): struct A(identity!($crate :: S));
2+
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( identity ! ( $ crate :: S ) ) ;
3+
PRINT-ATTR INPUT (DEBUG): TokenStream [
4+
Ident {
5+
ident: "struct",
6+
span: #0 bytes(0..0),
7+
},
8+
Ident {
9+
ident: "A",
10+
span: #0 bytes(0..0),
11+
},
12+
Group {
13+
delimiter: Parenthesis,
14+
stream: TokenStream [
15+
Ident {
16+
ident: "identity",
17+
span: #0 bytes(0..0),
18+
},
19+
Punct {
20+
ch: '!',
21+
spacing: Alone,
22+
span: #0 bytes(0..0),
23+
},
24+
Group {
25+
delimiter: Parenthesis,
26+
stream: TokenStream [
27+
Punct {
28+
ch: '$',
29+
spacing: Alone,
30+
span: #0 bytes(0..0),
31+
},
32+
Ident {
33+
ident: "crate",
34+
span: #0 bytes(0..0),
35+
},
36+
Punct {
37+
ch: ':',
38+
spacing: Joint,
39+
span: #0 bytes(0..0),
40+
},
41+
Punct {
42+
ch: ':',
43+
spacing: Alone,
44+
span: #0 bytes(0..0),
45+
},
46+
Ident {
47+
ident: "S",
48+
span: #0 bytes(0..0),
49+
},
50+
],
51+
span: #0 bytes(0..0),
52+
},
53+
],
54+
span: #0 bytes(0..0),
55+
},
56+
Punct {
57+
ch: ';',
58+
spacing: Alone,
59+
span: #0 bytes(0..0),
60+
},
61+
]

0 commit comments

Comments
 (0)