diff options
author | Jonas Schievink <[email protected]> | 2020-12-08 16:17:30 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-12-08 16:17:30 +0000 |
commit | 6c1d29256902d16c520fe076ce06cb91d934b62f (patch) | |
tree | 2fbc102f1178485ab3111e669508de7f3a2e0779 /crates/hir_def | |
parent | 678c74430b099e1f615069d99674926a0b7ff892 (diff) |
Add test for `$crate` in builtin macros
Fixes #6716
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/body/tests.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index 6dba9817d..de77d5fc9 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs | |||
@@ -134,3 +134,31 @@ fn f() { | |||
134 | "#, | 134 | "#, |
135 | ); | 135 | ); |
136 | } | 136 | } |
137 | |||
138 | #[test] | ||
139 | fn dollar_crate_in_builtin_macro() { | ||
140 | check_diagnostics( | ||
141 | r#" | ||
142 | #[macro_export] | ||
143 | #[rustc_builtin_macro] | ||
144 | macro_rules! format_args {} | ||
145 | |||
146 | #[macro_export] | ||
147 | macro_rules! arg { | ||
148 | () => {} | ||
149 | } | ||
150 | |||
151 | #[macro_export] | ||
152 | macro_rules! outer { | ||
153 | () => { | ||
154 | $crate::format_args!( "", $crate::arg!(1) ) | ||
155 | }; | ||
156 | } | ||
157 | |||
158 | fn f() { | ||
159 | outer!(); | ||
160 | //^^^^^^^^ leftover tokens | ||
161 | } | ||
162 | "#, | ||
163 | ) | ||
164 | } | ||