mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Use attr location for builtin macro goto-imp
This commit is contained in:
parent
86d2af9f7b
commit
d7be1a4372
3 changed files with 43 additions and 2 deletions
|
@ -112,6 +112,21 @@ impl HirFileId {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Indicate it is macro file generated for builtin derive
|
||||
pub fn is_builtin_derive(&self, db: &dyn db::AstDatabase) -> Option<InFile<ast::ModuleItem>> {
|
||||
match self.0 {
|
||||
HirFileIdRepr::FileId(_) => None,
|
||||
HirFileIdRepr::MacroFile(macro_file) => {
|
||||
let loc: MacroCallLoc = db.lookup_intern_macro(macro_file.macro_call_id);
|
||||
let item = match loc.def.kind {
|
||||
MacroDefKind::BuiltInDerive(_) => loc.kind.node(db),
|
||||
_ => return None,
|
||||
};
|
||||
Some(item.with_value(ast::ModuleItem::cast(item.value.clone())?))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue