Skip to content

Commit 9e0bf2b

Browse files
committed
Move state fixup into a different method.
1 parent 7ff69b4 commit 9e0bf2b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

compiler/rustc_mir_transform/src/const_prop.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ use rustc_index::vec::IndexVec;
1313
use rustc_middle::mir::visit::{
1414
MutVisitor, MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor,
1515
};
16-
use rustc_middle::mir::{
17-
BasicBlock, BinOp, Body, Constant, ConstantKind, Local, LocalDecl, LocalKind, Location,
18-
Operand, Place, Rvalue, SourceInfo, Statement, StatementKind, Terminator, TerminatorKind, UnOp,
19-
RETURN_PLACE,
20-
};
16+
use rustc_middle::mir::*;
2117
use rustc_middle::ty::layout::{LayoutError, LayoutOf, LayoutOfHelpers, TyAndLayout};
2218
use rustc_middle::ty::InternalSubsts;
2319
use rustc_middle::ty::{self, ConstKind, Instance, ParamEnv, Ty, TyCtxt, TypeVisitable};
@@ -1076,7 +1072,7 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
10761072
let source_info = terminator.source_info;
10771073
self.source_info = Some(source_info);
10781074
self.super_terminator(terminator, location);
1079-
// Do NOT early return in this function, it does some crucial fixup of the state at the end!
1075+
10801076
match &mut terminator.kind {
10811077
TerminatorKind::Assert { expected, ref mut cond, .. } => {
10821078
if let Some(ref value) = self.eval_operand(&cond) {
@@ -1131,6 +1127,10 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
11311127
// gated on `mir_opt_level=3`.
11321128
TerminatorKind::Call { .. } => {}
11331129
}
1130+
}
1131+
1132+
fn visit_basic_block_data(&mut self, block: BasicBlock, data: &mut BasicBlockData<'tcx>) {
1133+
self.super_basic_block_data(block, data);
11341134

11351135
// We remove all Locals which are restricted in propagation to their containing blocks and
11361136
// which were modified in the current block.

0 commit comments

Comments
 (0)