File tree 1 file changed +5
-7
lines changed
compiler/rustc_middle/src/mir
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -141,8 +141,7 @@ impl<'tcx> MirPatch<'tcx> {
141
141
142
142
let mut delta = 0 ;
143
143
let mut last_bb = START_BLOCK ;
144
- let mut terminator_targets = Vec :: new ( ) ;
145
- let mut statements: Vec < Statement < ' _ > > = Vec :: new ( ) ;
144
+ let mut stmts_and_targets: Vec < ( Statement < ' _ > , BasicBlock ) > = Vec :: new ( ) ;
146
145
for ( mut loc, stmt) in new_statements {
147
146
if loc. block != last_bb {
148
147
delta = 0 ;
@@ -159,8 +158,8 @@ impl<'tcx> MirPatch<'tcx> {
159
158
let successors = term. successors ( ) . clone ( ) ;
160
159
161
160
for i in successors {
162
- statements . push ( Statement { source_info , kind : stmt . clone ( ) } ) ;
163
- terminator_targets . push ( i. clone ( ) ) ;
161
+ stmts_and_targets
162
+ . push ( ( Statement { source_info , kind : stmt . clone ( ) } , i. clone ( ) ) ) ;
164
163
}
165
164
delta += 1 ;
166
165
continue ;
@@ -172,9 +171,8 @@ impl<'tcx> MirPatch<'tcx> {
172
171
delta += 1 ;
173
172
}
174
173
175
- for target in terminator_targets. iter ( ) . rev ( ) {
176
- let stmt = statements. pop ( ) . unwrap ( ) ;
177
- body[ * target] . statements . insert ( 0 , stmt) ;
174
+ for ( stmt, target) in stmts_and_targets. iter ( ) . rev ( ) {
175
+ body[ * target] . statements . insert ( 0 , stmt. clone ( ) ) ;
178
176
}
179
177
}
180
178
You can’t perform that action at this time.
0 commit comments