Skip to content

Commit 4970393

Browse files
committed
Temp: Cleanup 4 (resume block)
1 parent f6d79ae commit 4970393

File tree

1 file changed

+11
-30
lines changed

1 file changed

+11
-30
lines changed

src/librustc_mir/build/scope.rs

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,7 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
11521152
&mut self.scopes.unwind_drops,
11531153
self.fn_span,
11541154
should_abort,
1155+
&mut None,
11551156
);
11561157
}
11571158
}
@@ -1175,12 +1176,9 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
11751176
}
11761177

11771178
// Build the drop tree for unwinding in the normal control flow paths.
1178-
let resume_block = Self::build_unwind_tree(
1179-
cfg,
1180-
&mut self.scopes.unwind_drops,
1181-
fn_span,
1182-
should_abort,
1183-
);
1179+
let resume_block = &mut None;
1180+
let unwind_drops = &mut self.scopes.unwind_drops;
1181+
Self::build_unwind_tree(cfg, unwind_drops, fn_span, should_abort, resume_block);
11841182

11851183
// Build the drop tree for unwinding when dropping a suspended
11861184
// generator.
@@ -1194,51 +1192,34 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
11941192
drops.entry_points.push((drop_data.1, blocks[drop_idx].unwrap()));
11951193
}
11961194
}
1197-
let mut blocks = IndexVec::from_elem(None, &drops.drops);
1198-
blocks[ROOT_NODE] = resume_block;
1199-
drops.build_mir::<Unwind>(cfg, &mut blocks);
1200-
if let (None, Some(new_resume_block)) = (resume_block, blocks[ROOT_NODE]) {
1201-
let terminator = if should_abort {
1202-
TerminatorKind::Abort
1203-
} else {
1204-
TerminatorKind::Resume
1205-
};
1206-
cfg.terminate(
1207-
new_resume_block,
1208-
SourceInfo {
1209-
scope: OUTERMOST_SOURCE_SCOPE,
1210-
span: fn_span
1211-
},
1212-
terminator,
1213-
);
1214-
}
1195+
Self::build_unwind_tree(cfg, drops, fn_span, should_abort, resume_block);
12151196
}
12161197

12171198
fn build_unwind_tree(
12181199
cfg: &mut CFG<'tcx>,
12191200
drops: &mut DropTree,
12201201
fn_span: Span,
12211202
should_abort: bool,
1222-
) -> Option<BasicBlock> {
1203+
resume_block: &mut Option<BasicBlock>,
1204+
) {
12231205
let mut blocks = IndexVec::from_elem(None, &drops.drops);
1206+
blocks[ROOT_NODE] = *resume_block;
12241207
drops.build_mir::<Unwind>(cfg, &mut blocks);
1225-
if let Some(resume_block) = blocks[ROOT_NODE] {
1208+
if let (None, Some(resume)) = (*resume_block, blocks[ROOT_NODE]) {
12261209
let terminator = if should_abort {
12271210
TerminatorKind::Abort
12281211
} else {
12291212
TerminatorKind::Resume
12301213
};
12311214
cfg.terminate(
1232-
resume_block,
1215+
resume,
12331216
SourceInfo {
12341217
scope: OUTERMOST_SOURCE_SCOPE,
12351218
span: fn_span
12361219
},
12371220
terminator,
12381221
);
1239-
Some(resume_block)
1240-
} else {
1241-
None
1222+
*resume_block = blocks[ROOT_NODE];
12421223
}
12431224
}
12441225
}

0 commit comments

Comments
 (0)