Skip to content

Commit 7d6fcbc

Browse files
bors[bot]Veykril
andauthored
Merge #10944
10944: internal: Prefer resolution of inert attributes r=Veykril a=Veykril Fixes #10942 bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents 6f84bbf + 89e1d19 commit 7d6fcbc

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

crates/hir/src/source_analyzer.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -335,17 +335,16 @@ impl SourceAnalyzer {
335335
}
336336
}
337337
} else if is_path_of_attr {
338-
let res = resolve_hir_path_as_macro(db, &self.resolver, &hir_path);
339-
return match res {
340-
Some(_) => res.map(PathResolution::Macro),
341-
None => path.as_single_name_ref().and_then(|name_ref| {
342-
if let builtin @ Some(_) = BuiltinAttr::by_name(&name_ref.text()) {
343-
builtin.map(PathResolution::BuiltinAttr)
344-
} else if let tool @ Some(_) = ToolModule::by_name(&name_ref.text()) {
345-
tool.map(PathResolution::ToolModule)
346-
} else {
347-
None
348-
}
338+
let name_ref = path.as_single_name_ref();
339+
let builtin =
340+
name_ref.as_ref().map(ast::NameRef::text).as_deref().and_then(BuiltinAttr::by_name);
341+
if let builtin @ Some(_) = builtin {
342+
return builtin.map(PathResolution::BuiltinAttr);
343+
}
344+
return match resolve_hir_path_as_macro(db, &self.resolver, &hir_path) {
345+
res @ Some(m) if m.is_attr() => res.map(PathResolution::Macro),
346+
_ => name_ref.and_then(|name_ref| {
347+
ToolModule::by_name(&name_ref.text()).map(PathResolution::ToolModule)
349348
}),
350349
};
351350
}

0 commit comments

Comments
 (0)