Skip to content

Commit 70e67d6

Browse files
committed
fat vec
1 parent 831ebfc commit 70e67d6

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/rustc_middle/src/mir/patch.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ impl<'tcx> MirPatch<'tcx> {
141141

142142
let mut delta = 0;
143143
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();
146145
for (mut loc, stmt) in new_statements {
147146
if loc.block != last_bb {
148147
delta = 0;
@@ -159,8 +158,8 @@ impl<'tcx> MirPatch<'tcx> {
159158
let successors = term.successors().clone();
160159

161160
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()));
164163
}
165164
delta += 1;
166165
continue;
@@ -172,9 +171,8 @@ impl<'tcx> MirPatch<'tcx> {
172171
delta += 1;
173172
}
174173

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());
178176
}
179177
}
180178

0 commit comments

Comments
 (0)