diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_def/src/body/tests.rs | 28 | ||||
-rw-r--r-- | crates/hir_def/src/test_db.rs | 11 |
2 files changed, 37 insertions, 2 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 | } | ||
diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs index 00fe711fe..59c788b18 100644 --- a/crates/hir_def/src/test_db.rs +++ b/crates/hir_def/src/test_db.rs | |||
@@ -157,9 +157,16 @@ impl TestDB { | |||
157 | db.diagnostics(|d| { | 157 | db.diagnostics(|d| { |
158 | let src = d.display_source(); | 158 | let src = d.display_source(); |
159 | let root = db.parse_or_expand(src.file_id).unwrap(); | 159 | let root = db.parse_or_expand(src.file_id).unwrap(); |
160 | // FIXME: macros... | 160 | |
161 | // Place all diagnostics emitted in macro files on the original caller. | ||
162 | // Note that this does *not* match IDE behavior. | ||
163 | let mut src = src.map(|ptr| ptr.to_node(&root)); | ||
164 | while let Some(exp) = src.file_id.call_node(db) { | ||
165 | src = exp; | ||
166 | } | ||
167 | |||
161 | let file_id = src.file_id.original_file(db); | 168 | let file_id = src.file_id.original_file(db); |
162 | let range = src.value.to_node(&root).text_range(); | 169 | let range = src.value.text_range(); |
163 | let message = d.message().to_owned(); | 170 | let message = d.message().to_owned(); |
164 | actual.entry(file_id).or_default().push((range, message)); | 171 | actual.entry(file_id).or_default().push((range, message)); |
165 | }); | 172 | }); |