Add a test case with $crate from other crate · rust-lang/rust@4cb67c0 (original) (raw)

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -14,3 +14,9 @@ macro_rules! external {
14 14 struct D($crate::S);
15 15 };
16 16 }
17 +
18 +#[macro_export]
19 +macro_rules! issue_62325 { () => {
20 + #[print_attr]
21 +struct B(identity!($crate::S));
22 +}}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
1 1 // check-pass
2 2 // edition:2018
3 3 // aux-build:test-macros.rs
4 +// aux-build:dollar-crate-external.rs
4 5
5 6 // Anonymize unstable non-dummy spans while still showing dummy spans `0..0`.
6 7 // normalize-stdout-test "bytes\([^0]\w*\.\.(\w+)\)" -> "bytes(LO..$1)"
@@ -10,6 +11,7 @@
10 11
11 12 #[macro_use]
12 13 extern crate test_macros;
14 +extern crate dollar_crate_external;
13 15
14 16 type S = u8;
15 17
@@ -20,4 +22,6 @@ macro_rules! m { () => {
20 22
21 23 m!();
22 24
25 +dollar_crate_external::issue_62325!();
26 +
23 27 fn main() {}
Original file line number Diff line number Diff line change
@@ -54,3 +54,59 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
54 54 span: #2 bytes(LO..HI),
55 55 },
56 56 ]
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 +]