1
Fork 0

Fix binding mode problems

This commit is contained in:
Michael Goulet 2025-02-20 18:28:48 +00:00
parent e1819a889a
commit 3d5438accd
67 changed files with 154 additions and 181 deletions

View file

@ -467,7 +467,7 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> {
state.insert_place_idx(rhs, lhs, &self.map);
}
// If we expect `lhs ?= A`, we have an opportunity if we assume `constant == A`.
Rvalue::Aggregate(box ref kind, ref operands) => {
Rvalue::Aggregate(box kind, operands) => {
let agg_ty = lhs_place.ty(self.body, self.tcx).ty;
let lhs = match kind {
// Do not support unions.

View file

@ -509,7 +509,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
// other overflow checks.
AssertKind::Overflow(*bin_op, eval_to_int(op1), eval_to_int(op2))
}
AssertKind::BoundsCheck { ref len, ref index } => {
AssertKind::BoundsCheck { len, index } => {
let len = eval_to_int(len);
let index = eval_to_int(index);
AssertKind::BoundsCheck { len, index }
@ -782,10 +782,10 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
self.super_terminator(terminator, location);
match &terminator.kind {
TerminatorKind::Assert { expected, ref msg, ref cond, .. } => {
TerminatorKind::Assert { expected, msg, cond, .. } => {
self.check_assertion(*expected, msg, cond, location);
}
TerminatorKind::SwitchInt { ref discr, ref targets } => {
TerminatorKind::SwitchInt { discr, targets } => {
if let Some(ref value) = self.eval_operand(discr)
&& let Some(value_const) = self.use_ecx(|this| this.ecx.read_scalar(value))
&& let Some(constant) = value_const.to_bits(value_const.size()).discard_err()

View file

@ -51,7 +51,7 @@ impl<'tcx> Visitor<'tcx> for MentionedItemsVisitor<'_, 'tcx> {
let ty = place.ty(self.body, self.tcx).ty;
self.mentioned_items.push(Spanned { node: MentionedItem::Drop(ty), span: span() });
}
mir::TerminatorKind::InlineAsm { ref operands, .. } => {
mir::TerminatorKind::InlineAsm { operands, .. } => {
for op in operands {
match *op {
mir::InlineAsmOperand::SymFn { ref value } => {

View file

@ -568,9 +568,9 @@ fn remove_unused_definitions_helper(used_locals: &mut UsedLocals, body: &mut Bod
}
StatementKind::Assign(box (place, _)) => used_locals.is_used(place.local),
StatementKind::SetDiscriminant { ref place, .. }
| StatementKind::BackwardIncompatibleDropHint { ref place, reason: _ }
| StatementKind::Deinit(ref place) => used_locals.is_used(place.local),
StatementKind::SetDiscriminant { place, .. }
| StatementKind::BackwardIncompatibleDropHint { place, reason: _ }
| StatementKind::Deinit(place) => used_locals.is_used(place.local),
StatementKind::Nop => false,
_ => true,
};

View file

@ -24,7 +24,7 @@ impl<'tcx> crate::MirPass<'tcx> for SimplifyConstCondition {
// Simplify `assume` of a known value: either a NOP or unreachable.
if let StatementKind::Intrinsic(box ref intrinsic) = stmt.kind
&& let NonDivergingIntrinsic::Assume(discr) = intrinsic
&& let Operand::Constant(ref c) = discr
&& let Operand::Constant(c) = discr
&& let Some(constant) = c.const_.try_eval_bool(tcx, typing_env)
{
if constant {

View file

@ -89,10 +89,10 @@ impl<'tcx> crate::MirPass<'tcx> for SimplifyComparisonIntegral {
use Operand::*;
match rhs {
Rvalue::BinaryOp(_, box (ref mut left @ Move(_), Constant(_))) => {
Rvalue::BinaryOp(_, box (left @ Move(_), Constant(_))) => {
*left = Copy(opt.to_switch_on);
}
Rvalue::BinaryOp(_, box (Constant(_), ref mut right @ Move(_))) => {
Rvalue::BinaryOp(_, box (Constant(_), right @ Move(_))) => {
*right = Copy(opt.to_switch_on);
}
_ => (),