@@ -2,7 +2,6 @@ use rustc_index::vec::{Idx, IndexVec};
22use rustc_middle:: mir:: * ;
33use rustc_middle:: ty:: Ty ;
44use rustc_span:: Span ;
5- use std:: collections:: VecDeque ;
65
76/// This struct represents a patch to MIR, which can add
87/// new statements and basic blocks and patch over block
@@ -143,8 +142,7 @@ impl<'tcx> MirPatch<'tcx> {
143142 let mut delta = 0 ;
144143 let mut last_bb = START_BLOCK ;
145144 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 ( ) ;
148146 for ( mut loc, stmt) in new_statements {
149147 if loc. block != last_bb {
150148 delta = 0 ;
@@ -161,7 +159,7 @@ impl<'tcx> MirPatch<'tcx> {
161159 let successors = term. successors ( ) . clone ( ) ;
162160
163161 for i in successors {
164- inf_and_stmt . push_back ( ( source_info, stmt. clone ( ) ) ) ;
162+ statements . push ( Statement { source_info, kind : stmt. clone ( ) } ) ;
165163 terminator_targets. push ( i. clone ( ) ) ;
166164 }
167165 delta += 1 ;
@@ -174,11 +172,11 @@ impl<'tcx> MirPatch<'tcx> {
174172 delta += 1 ;
175173 }
176174
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 ( ) ;
179177 body[ * target]
180178 . statements
181- . insert ( 0 , Statement { source_info : inf_and_stmt . 0 , kind : inf_and_stmt . 1 } ) ;
179+ . insert ( 0 , stmt ) ;
182180 }
183181 }
184182
0 commit comments