Implemented basic enum const eval

This commit is contained in:
OleStrohm 2022-08-06 18:50:21 +02:00
parent f64c95600c
commit 997fc46efa
14 changed files with 227 additions and 17 deletions

View file

@ -1,6 +1,7 @@
//! File symbol extraction.
use base_db::FileRange;
use hir_def::db::DefDatabase;
use hir_def::{
item_tree::ItemTreeNode, src::HasSource, AdtId, AssocItemId, AssocItemLoc, DefWithBodyId,
HasModule, ImplId, ItemContainerId, Lookup, MacroId, ModuleDefId, ModuleId, TraitId,
@ -244,6 +245,10 @@ impl<'a> SymbolCollector<'a> {
DefWithBodyId::ConstId(id) => Some(
id.lookup(self.db.upcast()).source(self.db.upcast()).value.name()?.text().into(),
),
DefWithBodyId::VariantId(id) => Some({
let up_db: &dyn DefDatabase = self.db.upcast();
up_db.lookup_intern_enum(id.parent).source(up_db).value.name()?.text().into()
}),
}
}