Track labels in the HIR

This commit is contained in:
Lukas Wirth 2020-12-23 16:34:30 +01:00
parent fd1fcf2c2e
commit 262b9c3982
9 changed files with 167 additions and 68 deletions

View file

@ -4,12 +4,15 @@
//! are splitting the hir.
use hir_def::{
expr::PatId, item_scope::ItemInNs, AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId,
GenericDefId, ModuleDefId, VariantId,
expr::{LabelId, PatId},
item_scope::ItemInNs,
AdtId, AssocItemId, DefWithBodyId, EnumVariantId, FieldId, GenericDefId, ModuleDefId,
VariantId,
};
use crate::{
Adt, AssocItem, DefWithBody, Field, GenericDef, Local, MacroDef, ModuleDef, Variant, VariantDef,
Adt, AssocItem, DefWithBody, Field, GenericDef, Label, Local, MacroDef, ModuleDef, Variant,
VariantDef,
};
macro_rules! from_id {
@ -228,6 +231,12 @@ impl From<(DefWithBodyId, PatId)> for Local {
}
}
impl From<(DefWithBodyId, LabelId)> for Label {
fn from((parent, label_id): (DefWithBodyId, LabelId)) -> Self {
Label { parent, label_id }
}
}
impl From<MacroDef> for ItemInNs {
fn from(macro_def: MacroDef) -> Self {
ItemInNs::Macros(macro_def.into())