HIR ExternCrateDecl

This commit is contained in:
Lukas Wirth 2023-06-15 12:28:40 +02:00
parent 0bde3fc77e
commit 9476fdaaa9
10 changed files with 75 additions and 16 deletions

View file

@ -831,6 +831,7 @@ pub enum AttrDefId {
ImplId(ImplId),
GenericParamId(GenericParamId),
ExternBlockId(ExternBlockId),
ExternCrateId(ExternCrateId),
}
impl_from!(
@ -845,7 +846,8 @@ impl_from!(
TypeAliasId,
MacroId(Macro2Id, MacroRulesId, ProcMacroId),
ImplId,
GenericParamId
GenericParamId,
ExternCrateId
for AttrDefId
);
@ -937,6 +939,12 @@ impl HasModule for AdtId {
}
}
impl HasModule for ExternCrateId {
fn module(&self, db: &dyn db::DefDatabase) -> ModuleId {
self.lookup(db).container
}
}
impl HasModule for VariantId {
fn module(&self, db: &dyn db::DefDatabase) -> ModuleId {
match self {
@ -1060,6 +1068,7 @@ impl AttrDefId {
.krate
}
AttrDefId::MacroId(it) => it.module(db).krate,
AttrDefId::ExternCrateId(it) => it.lookup(db).container.krate,
}
}
}