Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/mir/lower/pattern_matching.rs')
-rw-r--r--crates/hir-ty/src/mir/lower/pattern_matching.rs47
1 files changed, 32 insertions, 15 deletions
diff --git a/crates/hir-ty/src/mir/lower/pattern_matching.rs b/crates/hir-ty/src/mir/lower/pattern_matching.rs
index abfa7aee04..b3c1f6f387 100644
--- a/crates/hir-ty/src/mir/lower/pattern_matching.rs
+++ b/crates/hir-ty/src/mir/lower/pattern_matching.rs
@@ -5,10 +5,10 @@ use hir_def::{AssocItemId, hir::ExprId, signatures::VariantFields};
use crate::{
BindingMode,
mir::{
- LocalId, MutBorrowKind,
+ LocalId, MutBorrowKind, Operand, OperandKind,
lower::{
BasicBlockId, BinOp, BindingId, BorrowKind, Either, Expr, FieldId, Idx, Interner,
- MemoryMap, MirLowerCtx, MirLowerError, MirSpan, Mutability, Operand, Pat, PatId, Place,
+ MemoryMap, MirLowerCtx, MirLowerError, MirSpan, Mutability, Pat, PatId, Place,
PlaceElem, ProjectionElem, RecordFieldPat, ResolveValueResult, Result, Rvalue,
Substitution, SwitchTargets, TerminatorKind, TupleFieldId, TupleId, TyBuilder, TyKind,
ValueNs, VariantId,
@@ -217,10 +217,14 @@ impl MirLowerCtx<'_> {
self.push_assignment(
current,
discr,
- Rvalue::CheckedBinaryOp(binop, lv, Operand::Copy(cond_place)),
+ Rvalue::CheckedBinaryOp(
+ binop,
+ lv,
+ Operand { kind: OperandKind::Copy(cond_place), span: None },
+ ),
pattern.into(),
);
- let discr = Operand::Copy(discr);
+ let discr = Operand { kind: OperandKind::Copy(discr), span: None };
self.set_terminator(
current,
TerminatorKind::SwitchInt {
@@ -262,7 +266,10 @@ impl MirLowerCtx<'_> {
self.set_terminator(
current,
TerminatorKind::SwitchInt {
- discr: Operand::Copy(place_len),
+ discr: Operand {
+ kind: OperandKind::Copy(place_len),
+ span: None,
+ },
targets: SwitchTargets::static_if(
pattern_len as u128,
next,
@@ -282,10 +289,14 @@ impl MirLowerCtx<'_> {
self.push_assignment(
current,
discr,
- Rvalue::CheckedBinaryOp(BinOp::Le, c, Operand::Copy(place_len)),
+ Rvalue::CheckedBinaryOp(
+ BinOp::Le,
+ c,
+ Operand { kind: OperandKind::Copy(place_len), span: None },
+ ),
pattern.into(),
);
- let discr = Operand::Copy(discr);
+ let discr = Operand { kind: OperandKind::Copy(discr), span: None };
self.set_terminator(
current,
TerminatorKind::SwitchInt {
@@ -407,8 +418,8 @@ impl MirLowerCtx<'_> {
tmp2,
Rvalue::CheckedBinaryOp(
BinOp::Eq,
- Operand::Copy(tmp),
- Operand::Copy(cond_place),
+ Operand { kind: OperandKind::Copy(tmp), span: None },
+ Operand { kind: OperandKind::Copy(cond_place), span: None },
),
span,
);
@@ -417,7 +428,7 @@ impl MirLowerCtx<'_> {
self.set_terminator(
current,
TerminatorKind::SwitchInt {
- discr: Operand::Copy(tmp2),
+ discr: Operand { kind: OperandKind::Copy(tmp2), span: None },
targets: SwitchTargets::static_if(1, next, else_target),
},
span,
@@ -486,7 +497,7 @@ impl MirLowerCtx<'_> {
self.push_assignment(
current,
lhs_place,
- Operand::Copy(cond_place).into(),
+ Operand { kind: OperandKind::Copy(cond_place), span: None }.into(),
expr.into(),
);
(current, current_else)
@@ -523,7 +534,9 @@ impl MirLowerCtx<'_> {
current,
target_place.into(),
match mode {
- BindingMode::Move => Operand::Copy(cond_place).into(),
+ BindingMode::Move => {
+ Operand { kind: OperandKind::Copy(cond_place), span: None }.into()
+ }
BindingMode::Ref(Mutability::Not) => Rvalue::Ref(BorrowKind::Shared, cond_place),
BindingMode::Ref(Mutability::Mut) => {
Rvalue::Ref(BorrowKind::Mut { kind: MutBorrowKind::Default }, cond_place)
@@ -547,10 +560,14 @@ impl MirLowerCtx<'_> {
self.push_assignment(
current,
discr,
- Rvalue::CheckedBinaryOp(BinOp::Eq, c, Operand::Copy(cond_place)),
+ Rvalue::CheckedBinaryOp(
+ BinOp::Eq,
+ c,
+ Operand { kind: OperandKind::Copy(cond_place), span: None },
+ ),
pattern.into(),
);
- let discr = Operand::Copy(discr);
+ let discr = Operand { kind: OperandKind::Copy(discr), span: None };
self.set_terminator(
current,
TerminatorKind::SwitchInt {
@@ -583,7 +600,7 @@ impl MirLowerCtx<'_> {
self.set_terminator(
current,
TerminatorKind::SwitchInt {
- discr: Operand::Copy(tmp),
+ discr: Operand { kind: OperandKind::Copy(tmp), span: None },
targets: SwitchTargets::static_if(e, next, *else_target),
},
span,