From 403a63d2b49a5dc080d10bbd6bbb48acc6e15d55 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 13 Feb 2021 22:11:31 +0100 Subject: Don't classify attribute macros as their path unless it's a function with the proc_macro_attribute attribute --- crates/ide_db/src/defs.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'crates/ide_db/src') diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs index a8091dbee..ff612b7d0 100644 --- a/crates/ide_db/src/defs.rs +++ b/crates/ide_db/src/defs.rs @@ -6,8 +6,8 @@ // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). use hir::{ - db::HirDatabase, Crate, Field, GenericParam, HasVisibility, Impl, Label, Local, MacroDef, - Module, ModuleDef, Name, PathResolution, Semantics, Visibility, + db::HirDatabase, Crate, Field, GenericParam, HasAttrs, HasVisibility, Impl, Label, Local, + MacroDef, Module, ModuleDef, Name, PathResolution, Semantics, Visibility, }; use syntax::{ ast::{self, AstNode, PathSegmentKind}, @@ -366,7 +366,15 @@ impl NameRefClass { if let Some(path) = name_ref.syntax().ancestors().find_map(ast::Path::cast) { if let Some(resolved) = sema.resolve_path(&path) { - return Some(NameRefClass::Definition(resolved.into())); + if path.syntax().parent().and_then(ast::Attr::cast).is_some() { + if let PathResolution::Def(ModuleDef::Function(func)) = resolved { + if func.attrs(sema.db).by_key("proc_macro_attribute").exists() { + return Some(NameRefClass::Definition(resolved.into())); + } + } + } else { + return Some(NameRefClass::Definition(resolved.into())); + } } } -- cgit v1.2.3