Added consteval tests

This commit is contained in:
OleStrohm 2022-08-07 18:22:18 +02:00
parent 2f84b6e2e5
commit ad0a6bf1a3
6 changed files with 46 additions and 11 deletions

View file

@ -952,6 +952,10 @@ impl Enum {
pub fn ty(self, db: &dyn HirDatabase) -> Type {
Type::from_def(db, self.id)
}
pub fn is_data_carrying(self, db: &dyn HirDatabase) -> bool {
self.variants(db).iter().all(|v| matches!(v.kind(db), StructKind::Unit))
}
}
impl HasVisibility for Enum {
@ -996,7 +1000,6 @@ impl Variant {
}
pub fn value(self, db: &dyn HirDatabase) -> Option<Expr> {
// TODO(ole): Handle missing exprs (+1 to the prev)
self.source(db)?.value.expr()
}