about summary refs log tree commit diff
path: root/src/tools/rust-analyzer
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2024-06-20 10:56:17 +0200
committerLukas Wirth <lukastw97@gmail.com>2024-06-20 11:00:19 +0200
commit16a28cacc2f60cbc2b45a4d0dd4db0daa2df58e5 (patch)
treef8ddffc906a867fb4c58335fad4222689a1bada2 /src/tools/rust-analyzer
parente5d5c7b20ad3e74b85fe9c3af2852595ae8a345a (diff)
downloadrust-16a28cacc2f60cbc2b45a4d0dd4db0daa2df58e5.tar.gz
rust-16a28cacc2f60cbc2b45a4d0dd4db0daa2df58e5.zip
fix: Fix IDE features breaking in some attr macros
Diffstat (limited to 'src/tools/rust-analyzer')
-rw-r--r--src/tools/rust-analyzer/crates/hir-expand/src/lib.rs4
-rw-r--r--src/tools/rust-analyzer/crates/hir/src/semantics.rs6
-rw-r--r--src/tools/rust-analyzer/crates/hir/src/semantics/source_to_def.rs2
3 files changed, 6 insertions, 6 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-expand/src/lib.rs b/src/tools/rust-analyzer/crates/hir-expand/src/lib.rs
index 8859b47e4c3..34921628ed3 100644
--- a/src/tools/rust-analyzer/crates/hir-expand/src/lib.rs
+++ b/src/tools/rust-analyzer/crates/hir-expand/src/lib.rs
@@ -710,8 +710,8 @@ impl ExpansionInfo {
         self.expanded.clone()
     }
 
-    pub fn call_node(&self) -> InFile<Option<SyntaxNode>> {
-        self.arg.with_value(self.arg.value.as_ref().and_then(SyntaxNode::parent))
+    pub fn arg(&self) -> InFile<Option<&SyntaxNode>> {
+        self.arg.as_ref().map(|it| it.as_ref())
     }
 
     pub fn call_file(&self) -> HirFileId {
diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics.rs b/src/tools/rust-analyzer/crates/hir/src/semantics.rs
index 358f10d3b89..5167dbf89b8 100644
--- a/src/tools/rust-analyzer/crates/hir/src/semantics.rs
+++ b/src/tools/rust-analyzer/crates/hir/src/semantics.rs
@@ -772,7 +772,7 @@ impl<'db> SemanticsImpl<'db> {
                             let exp_info = macro_file.expansion_info(self.db.upcast());
 
                             let InMacroFile { file_id, value } = exp_info.expanded();
-                            if let InFile { file_id, value: Some(value) } = exp_info.call_node() {
+                            if let InFile { file_id, value: Some(value) } = exp_info.arg() {
                                 self.cache(value.ancestors().last().unwrap(), file_id);
                             }
                             self.cache(value, file_id.into());
@@ -786,7 +786,7 @@ impl<'db> SemanticsImpl<'db> {
             // FIXME: uncached parse
             // Create the source analyzer for the macro call scope
             let Some(sa) = expansion_info
-                .call_node()
+                .arg()
                 .value
                 .and_then(|it| self.analyze_no_infer(&it.ancestors().last().unwrap()))
             else {
@@ -1145,7 +1145,7 @@ impl<'db> SemanticsImpl<'db> {
                             .expansion_info_cache
                             .entry(macro_file)
                             .or_insert_with(|| macro_file.expansion_info(self.db.upcast()));
-                        expansion_info.call_node().transpose()
+                        expansion_info.arg().map(|node| node?.parent()).transpose()
                     })
                 }
             }
diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics/source_to_def.rs b/src/tools/rust-analyzer/crates/hir/src/semantics/source_to_def.rs
index 13dba8805ac..247d0abb0f3 100644
--- a/src/tools/rust-analyzer/crates/hir/src/semantics/source_to_def.rs
+++ b/src/tools/rust-analyzer/crates/hir/src/semantics/source_to_def.rs
@@ -434,7 +434,7 @@ impl SourceToDefCtx<'_, '_> {
                     .entry(macro_file)
                     .or_insert_with(|| macro_file.expansion_info(this.db.upcast()));
 
-                expansion_info.call_node().map(|node| node?.parent()).transpose()
+                expansion_info.arg().map(|node| node?.parent()).transpose()
             }
         };
         let mut node = node.cloned();