internal: Expand the derive attribute into a pseudo expansion

This commit is contained in:
Lukas Wirth 2022-02-21 02:42:58 +01:00
parent 1fe3b2edd6
commit 7b89d5ede2
17 changed files with 178 additions and 155 deletions

View file

@ -371,10 +371,10 @@ impl SourceAnalyzer {
return builtin.map(PathResolution::BuiltinAttr);
}
return match resolve_hir_path_as_macro(db, &self.resolver, &hir_path) {
res @ Some(m) if m.is_attr() => res.map(PathResolution::Macro),
Some(m) => Some(PathResolution::Macro(m)),
// this labels any path that starts with a tool module as the tool itself, this is technically wrong
// but there is no benefit in differentiating these two cases for the time being
_ => path.first_segment().and_then(|it| it.name_ref()).and_then(|name_ref| {
None => path.first_segment().and_then(|it| it.name_ref()).and_then(|name_ref| {
match self.resolver.krate() {
Some(krate) => ToolModule::by_name(db, krate.into(), &name_ref.text()),
None => ToolModule::builtin(&name_ref.text()),