Skip to content

Commit 569f01c

Browse files
committed
pattern match directly on constant
1 parent 1fe09b0 commit 569f01c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/rustc_mir/src/transform/const_goto.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ impl<'a, 'tcx> Visitor<'tcx> for ConstGotoOptimizationFinder<'a, 'tcx> {
5757
// We only apply this optimization if the last statement is a const assignment
5858
let last_statement = self.body.basic_blocks()[location.block].statements.last()?;
5959

60-
if let Some((place, Rvalue::Use(op))) = last_statement.kind.as_assign() {
61-
let _const = op.constant()?;
60+
if let (place, Rvalue::Use(Operand::Constant(_const))) =
61+
last_statement.kind.as_assign()?
62+
{
6263
// We found a constant being assigned to `place`.
6364
// Now check that the target of this Goto switches on this place.
6465
let target_bb = &self.body.basic_blocks()[target];

0 commit comments

Comments
 (0)