Merge commit 'e36a20c24f' into ra-sync-and-pms-component

This commit is contained in:
Amos Wenger 2022-07-26 11:53:50 +02:00
parent dfe84494c1
commit a1f1b95d00
48 changed files with 627 additions and 213 deletions

View file

@ -2252,6 +2252,32 @@ impl Local {
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct DeriveHelper {
pub(crate) derive: MacroId,
pub(crate) idx: usize,
}
impl DeriveHelper {
pub fn derive(&self) -> Macro {
Macro { id: self.derive.into() }
}
pub fn name(&self, db: &dyn HirDatabase) -> Name {
match self.derive {
MacroId::Macro2Id(_) => None,
MacroId::MacroRulesId(_) => None,
MacroId::ProcMacroId(proc_macro) => db
.proc_macro_data(proc_macro)
.helpers
.as_ref()
.and_then(|it| it.get(self.idx))
.cloned(),
}
.unwrap_or_else(|| Name::missing())
}
}
// FIXME: Wrong name? This is could also be a registered attribute
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct BuiltinAttr {