Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/ide-db/src/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,14 @@ impl<'db> NameRefClass<'db> {
if let Some(macro_def) = sema.resolve_macro_call(&macro_call) {
return Some(NameRefClass::Definition(Definition::Macro(macro_def), None));
}

// When in a macro call context, prefer macro namespace resolution over type/value
// namespaces. This ensures that if a macro and a module have the same name,
// we correctly classify the path as a macro when used in a macro invocation.
if let Some(res) = sema.resolve_path_per_ns(&path).and_then(|res| res.macro_ns) {
return Some(NameRefClass::Definition(res.into(), None));
}
// Fallback to normal path resolution.
}
return sema
.resolve_path_with_subst(&path)
Expand Down