diff options
author | Jonas Schievink <[email protected]> | 2020-12-08 16:16:18 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-12-08 16:16:18 +0000 |
commit | 678c74430b099e1f615069d99674926a0b7ff892 (patch) | |
tree | 1972263d897d8b9afa1f0735d69d27cb5929b1db /crates/hir_def | |
parent | 0ce0d6893b3eb2670c9bed19b810ea070272d78e (diff) |
Handle macros in `TestDB::check_diagnostics`
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/test_db.rs | 11 |
1 files changed, 9 insertions, 2 deletions
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 | }); |