Skip to content

Commit 4cb67c0

Browse files
committed
Add a test case with $crate from other crate
1 parent 3997507 commit 4cb67c0

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

src/test/ui/proc-macro/auxiliary/dollar-crate-external.rs

+6
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ macro_rules! external {
1414
struct D($crate::S);
1515
};
1616
}
17+
18+
#[macro_export]
19+
macro_rules! issue_62325 { () => {
20+
#[print_attr]
21+
struct B(identity!($crate::S));
22+
}}

src/test/ui/proc-macro/dollar-crate-issue-62325.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// check-pass
22
// edition:2018
33
// aux-build:test-macros.rs
4+
// aux-build:dollar-crate-external.rs
45

56
// Anonymize unstable non-dummy spans while still showing dummy spans `0..0`.
67
// normalize-stdout-test "bytes\([^0]\w*\.\.(\w+)\)" -> "bytes(LO..$1)"
@@ -10,6 +11,7 @@
1011

1112
#[macro_use]
1213
extern crate test_macros;
14+
extern crate dollar_crate_external;
1315

1416
type S = u8;
1517

@@ -20,4 +22,6 @@ macro_rules! m { () => {
2022

2123
m!();
2224

25+
dollar_crate_external::issue_62325!();
26+
2327
fn main() {}

src/test/ui/proc-macro/dollar-crate-issue-62325.stdout

+56
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,59 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
5454
span: #2 bytes(LO..HI),
5555
},
5656
]
57+
PRINT-ATTR INPUT (DISPLAY): struct B(identity!(::dollar_crate_external :: S));
58+
PRINT-ATTR RE-COLLECTED (DISPLAY): struct B ( identity ! ( ::dollar_crate_external :: S ) ) ;
59+
PRINT-ATTR INPUT (DEBUG): TokenStream [
60+
Ident {
61+
ident: "struct",
62+
span: #7 bytes(LO..HI),
63+
},
64+
Ident {
65+
ident: "B",
66+
span: #7 bytes(LO..HI),
67+
},
68+
Group {
69+
delimiter: Parenthesis,
70+
stream: TokenStream [
71+
Ident {
72+
ident: "identity",
73+
span: #7 bytes(LO..HI),
74+
},
75+
Punct {
76+
ch: '!',
77+
spacing: Alone,
78+
span: #7 bytes(LO..HI),
79+
},
80+
Group {
81+
delimiter: Parenthesis,
82+
stream: TokenStream [
83+
Ident {
84+
ident: "$crate",
85+
span: #7 bytes(LO..HI),
86+
},
87+
Punct {
88+
ch: ':',
89+
spacing: Joint,
90+
span: #7 bytes(LO..HI),
91+
},
92+
Punct {
93+
ch: ':',
94+
spacing: Alone,
95+
span: #7 bytes(LO..HI),
96+
},
97+
Ident {
98+
ident: "S",
99+
span: #7 bytes(LO..HI),
100+
},
101+
],
102+
span: #7 bytes(LO..HI),
103+
},
104+
],
105+
span: #7 bytes(LO..HI),
106+
},
107+
Punct {
108+
ch: ';',
109+
spacing: Alone,
110+
span: #7 bytes(LO..HI),
111+
},
112+
]

0 commit comments

Comments
 (0)