Skip to content

Commit 9b9f59c

Browse files
authored
Merge pull request #22510 from flodiebold/mir-salsa-projections
internal: Align MIR ProjectionElem more with rustc's version and simplify it
2 parents 6c0c0d7 + 71a9c63 commit 9b9f59c

8 files changed

Lines changed: 380 additions & 264 deletions

File tree

crates/hir-def/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,14 @@ pub enum VariantId {
10171017
impl_from!(EnumVariantId, StructId, UnionId for VariantId);
10181018

10191019
impl VariantId {
1020+
pub fn from_non_enum(adt_id: AdtId) -> Option<Self> {
1021+
Some(match adt_id {
1022+
AdtId::StructId(struct_id) => struct_id.into(),
1023+
AdtId::UnionId(union_id) => union_id.into(),
1024+
AdtId::EnumId(_) => return None,
1025+
})
1026+
}
1027+
10201028
pub fn fields(self, db: &dyn DefDatabase) -> &VariantFields {
10211029
VariantFields::of(db, self)
10221030
}

0 commit comments

Comments
 (0)