Adopt even more custom types in the new solver

A lot of simplification and fun.
This commit is contained in:
Chayim Refael Friedman 2025-09-09 22:32:07 +03:00
parent 9621689e47
commit d03fd874d0
12 changed files with 221 additions and 223 deletions

View file

@ -84,6 +84,15 @@ impl LangItemTarget {
_ => None,
}
}
pub fn as_adt(self) -> Option<AdtId> {
match self {
LangItemTarget::Union(it) => Some(it.into()),
LangItemTarget::EnumId(it) => Some(it.into()),
LangItemTarget::Struct(it) => Some(it.into()),
_ => None,
}
}
}
/// Salsa query. This will look for lang items in a specific crate.
@ -289,6 +298,10 @@ impl LangItem {
lang_item(db, start_crate, self).and_then(|t| t.as_trait())
}
pub fn resolve_adt(self, db: &dyn DefDatabase, start_crate: Crate) -> Option<AdtId> {
lang_item(db, start_crate, self).and_then(|t| t.as_adt())
}
pub fn resolve_enum(self, db: &dyn DefDatabase, start_crate: Crate) -> Option<EnumId> {
lang_item(db, start_crate, self).and_then(|t| t.as_enum())
}