Skip to content

Commit 16a28ca

Browse files
committed
fix: Fix IDE features breaking in some attr macros
1 parent e5d5c7b commit 16a28ca

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/tools/rust-analyzer/crates/hir-expand/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,8 @@ impl ExpansionInfo {
710710
self.expanded.clone()
711711
}
712712

713-
pub fn call_node(&self) -> InFile<Option<SyntaxNode>> {
714-
self.arg.with_value(self.arg.value.as_ref().and_then(SyntaxNode::parent))
713+
pub fn arg(&self) -> InFile<Option<&SyntaxNode>> {
714+
self.arg.as_ref().map(|it| it.as_ref())
715715
}
716716

717717
pub fn call_file(&self) -> HirFileId {

src/tools/rust-analyzer/crates/hir/src/semantics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ impl<'db> SemanticsImpl<'db> {
772772
let exp_info = macro_file.expansion_info(self.db.upcast());
773773

774774
let InMacroFile { file_id, value } = exp_info.expanded();
775-
if let InFile { file_id, value: Some(value) } = exp_info.call_node() {
775+
if let InFile { file_id, value: Some(value) } = exp_info.arg() {
776776
self.cache(value.ancestors().last().unwrap(), file_id);
777777
}
778778
self.cache(value, file_id.into());
@@ -786,7 +786,7 @@ impl<'db> SemanticsImpl<'db> {
786786
// FIXME: uncached parse
787787
// Create the source analyzer for the macro call scope
788788
let Some(sa) = expansion_info
789-
.call_node()
789+
.arg()
790790
.value
791791
.and_then(|it| self.analyze_no_infer(&it.ancestors().last().unwrap()))
792792
else {
@@ -1145,7 +1145,7 @@ impl<'db> SemanticsImpl<'db> {
11451145
.expansion_info_cache
11461146
.entry(macro_file)
11471147
.or_insert_with(|| macro_file.expansion_info(self.db.upcast()));
1148-
expansion_info.call_node().transpose()
1148+
expansion_info.arg().map(|node| node?.parent()).transpose()
11491149
})
11501150
}
11511151
}

src/tools/rust-analyzer/crates/hir/src/semantics/source_to_def.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ impl SourceToDefCtx<'_, '_> {
434434
.entry(macro_file)
435435
.or_insert_with(|| macro_file.expansion_info(this.db.upcast()));
436436

437-
expansion_info.call_node().map(|node| node?.parent()).transpose()
437+
expansion_info.arg().map(|node| node?.parent()).transpose()
438438
}
439439
};
440440
let mut node = node.cloned();

0 commit comments

Comments
 (0)