mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Simplify
This commit is contained in:
parent
1bbef5af85
commit
94e59c9c56
3 changed files with 37 additions and 27 deletions
|
@ -1793,10 +1793,7 @@ impl MacroDef {
|
|||
}
|
||||
|
||||
pub fn is_builtin_derive(&self) -> bool {
|
||||
match self.id.kind {
|
||||
MacroDefKind::BuiltInAttr(exp, _) => exp.is_derive(),
|
||||
_ => false,
|
||||
}
|
||||
matches!(self.id.kind, MacroDefKind::BuiltInAttr(exp, _) if exp.is_derive())
|
||||
}
|
||||
|
||||
pub fn is_attr(&self) -> bool {
|
||||
|
@ -2433,24 +2430,7 @@ impl Impl {
|
|||
|
||||
pub fn is_builtin_derive(self, db: &dyn HirDatabase) -> Option<InFile<ast::Attr>> {
|
||||
let src = self.source(db)?;
|
||||
let item = src.file_id.is_builtin_derive(db.upcast())?;
|
||||
let hygenic = hir_expand::hygiene::Hygiene::new(db.upcast(), item.file_id);
|
||||
|
||||
// FIXME: handle `cfg_attr`
|
||||
let attr = item
|
||||
.value
|
||||
.attrs()
|
||||
.filter_map(|it| {
|
||||
let path = ModPath::from_src(db.upcast(), it.path()?, &hygenic)?;
|
||||
if path.as_ident()?.to_smol_str() == "derive" {
|
||||
Some(it)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.last()?;
|
||||
|
||||
Some(item.with_value(attr))
|
||||
src.file_id.is_builtin_derive(db.upcast())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue