mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Move fn to proc-macro conversion to name classification
This commit is contained in:
parent
cef8a17ea5
commit
0d3cd90d08
@ -1550,14 +1550,27 @@ fn func() {}
|
||||
|
||||
FileId(0) 16..24
|
||||
"#]],
|
||||
)
|
||||
);
|
||||
check(
|
||||
r#"
|
||||
#[proc_macro_attribute]
|
||||
fn func$0() {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
func Attribute FileId(0) 0..36 27..31
|
||||
|
||||
(no references)
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
#[test]
|
||||
fn derive() {
|
||||
check(
|
||||
r#"
|
||||
//- proc_macros: derive_identity
|
||||
//- minicore: derive
|
||||
|
||||
#[derive(proc_macros::DeriveIdentity$0)]
|
||||
struct Foo;
|
||||
|
@ -225,7 +225,12 @@ impl NameClass {
|
||||
Definition::Macro(sema.to_def(&ast::Macro::MacroDef(it))?)
|
||||
}
|
||||
ast::Item::Const(it) => Definition::Const(sema.to_def(&it)?),
|
||||
ast::Item::Fn(it) => Definition::Function(sema.to_def(&it)?),
|
||||
ast::Item::Fn(it) => {
|
||||
let def = sema.to_def(&it)?;
|
||||
def.as_proc_macro(sema.db)
|
||||
.map(Definition::Macro)
|
||||
.unwrap_or(Definition::Function(def))
|
||||
}
|
||||
ast::Item::Module(it) => Definition::Module(sema.to_def(&it)?),
|
||||
ast::Item::Static(it) => Definition::Static(sema.to_def(&it)?),
|
||||
ast::Item::Trait(it) => Definition::Trait(sema.to_def(&it)?),
|
||||
|
@ -309,14 +309,13 @@ impl Definition {
|
||||
}
|
||||
|
||||
pub fn usages<'a>(self, sema: &'a Semantics<RootDatabase>) -> FindUsages<'a> {
|
||||
let def = match self {
|
||||
def @ Definition::Function(f) => {
|
||||
// search for proc-macro usages if this function describes a proc macro
|
||||
f.as_proc_macro(sema.db).map(Definition::Macro).unwrap_or(def)
|
||||
}
|
||||
def => def,
|
||||
};
|
||||
FindUsages { def, sema, scope: None, include_self_kw_refs: None, search_self_mod: false }
|
||||
FindUsages {
|
||||
def: self,
|
||||
sema,
|
||||
scope: None,
|
||||
include_self_kw_refs: None,
|
||||
search_self_mod: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user