aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-08 18:13:54 +0000
committerGitHub <[email protected]>2020-12-08 18:13:54 +0000
commit87e35006362686b281caf46550c0fff35cddefb4 (patch)
tree67b9f5e41749a89b85b3f4ce49fec62b4a85da82 /crates/hir_def
parentb01981e6364a9de26a52adefac10e7aebfb85874 (diff)
parentda5027138d93c59aeb25aab5021276969f074992 (diff)
Merge #6765
6765: Fix file range computation in macros r=jonas-schievink a=jonas-schievink This also aligns the diagnostics behavior of `TestDB` with the one from the real IDE (by making the logic from `semantics.rs` a method on `InFile<&SyntaxNode>`), which makes bugs like this easier to find. This should fix the misplaced diagnostics seen in https://github.com/rust-analyzer/rust-analyzer/issues/6747 and other issues. bors r+ Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def')
-rw-r--r--crates/hir_def/src/test_db.rs12
1 files changed, 3 insertions, 9 deletions
diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs
index 59c788b18..f8b150850 100644
--- a/crates/hir_def/src/test_db.rs
+++ b/crates/hir_def/src/test_db.rs
@@ -158,17 +158,11 @@ impl TestDB {
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 160
161 // Place all diagnostics emitted in macro files on the original caller. 161 let node = src.map(|ptr| ptr.to_node(&root));
162 // Note that this does *not* match IDE behavior. 162 let frange = node.as_ref().original_file_range(db);
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 163
168 let file_id = src.file_id.original_file(db);
169 let range = src.value.text_range();
170 let message = d.message().to_owned(); 164 let message = d.message().to_owned();
171 actual.entry(file_id).or_default().push((range, message)); 165 actual.entry(frange.file_id).or_default().push((frange.range, message));
172 }); 166 });
173 167
174 for (file_id, diags) in actual.iter_mut() { 168 for (file_id, diags) in actual.iter_mut() {