mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
Adopt even more custom types in the new solver
A lot of simplification and fun.
This commit is contained in:
parent
9621689e47
commit
d03fd874d0
12 changed files with 221 additions and 223 deletions
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue