@@ -2,7 +2,6 @@ use rustc_index::vec::{Idx, IndexVec};
2
2
use rustc_middle:: mir:: * ;
3
3
use rustc_middle:: ty:: Ty ;
4
4
use rustc_span:: Span ;
5
- use std:: collections:: VecDeque ;
6
5
7
6
/// This struct represents a patch to MIR, which can add
8
7
/// new statements and basic blocks and patch over block
@@ -143,8 +142,7 @@ impl<'tcx> MirPatch<'tcx> {
143
142
let mut delta = 0 ;
144
143
let mut last_bb = START_BLOCK ;
145
144
let mut terminator_targets = Vec :: new ( ) ;
146
- let mut inf_and_stmt: VecDeque < ( SourceInfo , StatementKind < ' _ > ) > = VecDeque :: new ( ) ;
147
-
145
+ let mut statements: Vec < Statement < ' _ > > = Vec :: new ( ) ;
148
146
for ( mut loc, stmt) in new_statements {
149
147
if loc. block != last_bb {
150
148
delta = 0 ;
@@ -161,7 +159,7 @@ impl<'tcx> MirPatch<'tcx> {
161
159
let successors = term. successors ( ) . clone ( ) ;
162
160
163
161
for i in successors {
164
- inf_and_stmt . push_back ( ( source_info, stmt. clone ( ) ) ) ;
162
+ statements . push ( Statement { source_info, kind : stmt. clone ( ) } ) ;
165
163
terminator_targets. push ( i. clone ( ) ) ;
166
164
}
167
165
delta += 1 ;
@@ -174,11 +172,11 @@ impl<'tcx> MirPatch<'tcx> {
174
172
delta += 1 ;
175
173
}
176
174
177
- for target in terminator_targets. iter ( ) {
178
- let inf_and_stmt = inf_and_stmt . pop_front ( ) . unwrap ( ) ;
175
+ for target in terminator_targets. iter ( ) . rev ( ) {
176
+ let stmt = statements . pop ( ) . unwrap ( ) ;
179
177
body[ * target]
180
178
. statements
181
- . insert ( 0 , Statement { source_info : inf_and_stmt . 0 , kind : inf_and_stmt . 1 } ) ;
179
+ . insert ( 0 , stmt ) ;
182
180
}
183
181
}
184
182
0 commit comments