Skip to content

Commit

Permalink
Remove useless parameter to operand_from_scalar.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Mar 8, 2023
1 parent d94ec30 commit 8179b2e
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions compiler/rustc_mir_transform/src/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
scalar,
)) = *value
{
*operand = self.operand_from_scalar(
scalar,
value.layout.ty,
DUMMY_SP,
);
*operand = self.operand_from_scalar(scalar, value.layout.ty);
}
}
}
Expand Down Expand Up @@ -587,9 +583,9 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
}

/// Creates a new `Operand::Constant` from a `Scalar` value
fn operand_from_scalar(&self, scalar: Scalar, ty: Ty<'tcx>, span: Span) -> Operand<'tcx> {
fn operand_from_scalar(&self, scalar: Scalar, ty: Ty<'tcx>) -> Operand<'tcx> {
Operand::Constant(Box::new(Constant {
span,
span: DUMMY_SP,
user_ty: None,
literal: ConstantKind::from_scalar(self.tcx, scalar, ty),
}))
Expand Down Expand Up @@ -634,8 +630,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
if let Some(Right(imm)) = imm {
match *imm {
interpret::Immediate::Scalar(scalar) => {
*rval =
Rvalue::Use(self.operand_from_scalar(scalar, value.layout.ty, DUMMY_SP));
*rval = Rvalue::Use(self.operand_from_scalar(scalar, value.layout.ty));
}
Immediate::ScalarPair(..) => {
// Found a value represented as a pair. For now only do const-prop if the type
Expand Down Expand Up @@ -933,11 +928,7 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
&& self.should_const_prop(value)
{
trace!("assertion on {:?} should be {:?}", value, expected);
*cond = self.operand_from_scalar(
value_const,
self.tcx.types.bool,
DUMMY_SP,
);
*cond = self.operand_from_scalar(value_const, self.tcx.types.bool);
}
}
TerminatorKind::SwitchInt { ref mut discr, .. } => {
Expand Down

0 comments on commit 8179b2e

Please sign in to comment.