Skip to content

Commit bf511c1

Browse files
committed
Tidy fix
1 parent 15e0098 commit bf511c1

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

compiler/rustc_mir/src/transform/const_goto.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,20 @@ impl<'tcx> MirPass<'tcx> for ConstGoto {
5252

5353
impl<'a, 'tcx> Visitor<'tcx> for ConstGotoOptimizationFinder<'a, 'tcx> {
5454
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
55-
let _:Option<_> = try {
55+
let _: Option<_> = try {
5656
let target = terminator.kind.as_goto()?;
5757
// We only apply this optimization if the last statement is a const assignment
58-
let last_statement =
59-
self.body.basic_blocks()[location.block].statements.last()?;
58+
let last_statement = self.body.basic_blocks()[location.block].statements.last()?;
6059

61-
if let Some(box (place, Rvalue::Use(op))) = last_statement.kind.as_assign(){
60+
if let Some(box (place, Rvalue::Use(op))) = last_statement.kind.as_assign() {
6261
let _const = op.constant()?;
6362
// We found a constant being assigned to `place`.
6463
// Now check that the target of this Goto switches on this place.
6564
let target_bb = &self.body.basic_blocks()[target];
66-
67-
// FIXME(simonvandel): We are conservative here when we don't allow
65+
66+
// FIXME(simonvandel): We are conservative here when we don't allow
6867
// any statements in the target basic block.
69-
// This could probably be relaxed to allow `StorageDead`s which could be
68+
// This could probably be relaxed to allow `StorageDead`s which could be
7069
// copied to the predecessor of this block.
7170
if !target_bb.statements.is_empty() {
7271
None?
@@ -77,15 +76,12 @@ impl<'a, 'tcx> Visitor<'tcx> for ConstGotoOptimizationFinder<'a, 'tcx> {
7776
if discr.place() == Some(*place) {
7877
// We now know that the Switch matches on the const place, and it is statementless
7978
// Now find which value in the Switch matches the const value.
80-
let const_value = _const.literal.try_eval_bits(
81-
self.tcx,
82-
self.param_env,
83-
switch_ty,
84-
)?;
79+
let const_value =
80+
_const.literal.try_eval_bits(self.tcx, self.param_env, switch_ty)?;
8581
let found_value_idx_option = targets
8682
.iter()
8783
.enumerate()
88-
.find(|(_, (value,_))| const_value == *value)
84+
.find(|(_, (value, _))| const_value == *value)
8985
.map(|(idx, _)| idx);
9086

9187
let target_to_use_in_goto =

0 commit comments

Comments
 (0)