aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-02-13 21:11:31 +0000
committerLukas Wirth <[email protected]>2021-02-13 21:11:31 +0000
commit403a63d2b49a5dc080d10bbd6bbb48acc6e15d55 (patch)
tree6e84e6e40f498a2c7f0bf4c2c6941b62895f5f4b /crates/ide_db
parent205e72f34d26898779c8ab11c8500e74fd8ce28b (diff)
Don't classify attribute macros as their path unless it's a function with the proc_macro_attribute attribute
Diffstat (limited to 'crates/ide_db')
-rw-r--r--crates/ide_db/src/defs.rs14
1 files changed, 11 insertions, 3 deletions
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 @@
6// FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). 6// FIXME: this badly needs rename/rewrite (matklad, 2020-02-06).
7 7
8use hir::{ 8use hir::{
9 db::HirDatabase, Crate, Field, GenericParam, HasVisibility, Impl, Label, Local, MacroDef, 9 db::HirDatabase, Crate, Field, GenericParam, HasAttrs, HasVisibility, Impl, Label, Local,
10 Module, ModuleDef, Name, PathResolution, Semantics, Visibility, 10 MacroDef, Module, ModuleDef, Name, PathResolution, Semantics, Visibility,
11}; 11};
12use syntax::{ 12use syntax::{
13 ast::{self, AstNode, PathSegmentKind}, 13 ast::{self, AstNode, PathSegmentKind},
@@ -366,7 +366,15 @@ impl NameRefClass {
366 366
367 if let Some(path) = name_ref.syntax().ancestors().find_map(ast::Path::cast) { 367 if let Some(path) = name_ref.syntax().ancestors().find_map(ast::Path::cast) {
368 if let Some(resolved) = sema.resolve_path(&path) { 368 if let Some(resolved) = sema.resolve_path(&path) {
369 return Some(NameRefClass::Definition(resolved.into())); 369 if path.syntax().parent().and_then(ast::Attr::cast).is_some() {
370 if let PathResolution::Def(ModuleDef::Function(func)) = resolved {
371 if func.attrs(sema.db).by_key("proc_macro_attribute").exists() {
372 return Some(NameRefClass::Definition(resolved.into()));
373 }
374 }
375 } else {
376 return Some(NameRefClass::Definition(resolved.into()));
377 }
370 } 378 }
371 } 379 }
372 380