From da5027138d93c59aeb25aab5021276969f074992 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 8 Dec 2020 19:11:12 +0100 Subject: Fix logic for determining macro calls I believe this currently goes back all the way to the initial user-written call, but that seems better than the current broken behavior. --- crates/hir_expand/src/lib.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'crates/hir_expand/src/lib.rs') diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs index 3edcadf0d..1a9428514 100644 --- a/crates/hir_expand/src/lib.rs +++ b/crates/hir_expand/src/lib.rs @@ -457,17 +457,15 @@ impl<'a> InFile<&'a SyntaxNode> { return FileRange { file_id: range.file_id.original_file(db), range: range.value }; } - // Fall back to whole macro call - if let Some(expansion) = self.file_id.expansion_info(db) { - if let Some(call_node) = expansion.call_node() { - return FileRange { - file_id: call_node.file_id.original_file(db), - range: call_node.value.text_range(), - }; - } + // Fall back to whole macro call. + let mut node = self.cloned(); + while let Some(call_node) = node.file_id.call_node(db) { + node = call_node; } - FileRange { file_id: self.file_id.original_file(db), range: self.value.text_range() } + let orig_file = node.file_id.original_file(db); + assert_eq!(node.file_id, orig_file.into()); + FileRange { file_id: orig_file, range: node.value.text_range() } } } -- cgit v1.2.3