Skip to content

Commit 7c0c4cd

Browse files
committed
Pass span through diverge_cleanup down to build_diverge_scope where it
can be used for building the diverge path's terminator.
1 parent a658bb2 commit 7c0c4cd

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/librustc_mir/build/expr/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
234234
.collect();
235235

236236
let success = this.cfg.start_new_block();
237-
let cleanup = this.diverge_cleanup();
237+
let cleanup = this.diverge_cleanup(expr_span);
238238
this.cfg.terminate(block, source_info, TerminatorKind::Call {
239239
func: fun,
240240
args: args,

src/librustc_mir/build/matches/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
306306
let bool_ty = self.hir.bool_ty();
307307
let eq_result = self.temp(bool_ty, test.span);
308308
let eq_block = self.cfg.start_new_block();
309-
let cleanup = self.diverge_cleanup();
309+
let cleanup = self.diverge_cleanup(test.span);
310310
self.cfg.terminate(block, source_info, TerminatorKind::Call {
311311
func: Operand::Constant(box Constant {
312312
span: test.span,

src/librustc_mir/build/scope.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
330330
debug!("pop_scope({:?}, {:?})", extent, block);
331331
// We need to have `cached_block`s available for all the drops, so we call diverge_cleanup
332332
// to make sure all the `cached_block`s are filled in.
333-
self.diverge_cleanup();
333+
self.diverge_cleanup(extent.1.span);
334334
let scope = self.scopes.pop().unwrap();
335335
assert_eq!(scope.extent, extent.0);
336336
unpack!(block = build_scope_drops(&mut self.cfg,
@@ -607,7 +607,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
607607
/// This path terminates in Resume. Returns the start of the path.
608608
/// See module comment for more details. None indicates there’s no
609609
/// cleanup to do at this point.
610-
pub fn diverge_cleanup(&mut self) -> Option<BasicBlock> {
610+
pub fn diverge_cleanup(&mut self, span: Span) -> Option<BasicBlock> {
611611
if !self.scopes.iter().any(|scope| scope.needs_cleanup) {
612612
return None;
613613
}
@@ -641,7 +641,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
641641
};
642642

643643
for scope in scopes.iter_mut().filter(|s| s.needs_cleanup) {
644-
target = build_diverge_scope(hir.tcx(), cfg, &unit_temp, scope, target);
644+
target = build_diverge_scope(hir.tcx(), cfg, &unit_temp, span, scope, target);
645645
}
646646
Some(target)
647647
}
@@ -657,7 +657,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
657657
}
658658
let source_info = self.source_info(span);
659659
let next_target = self.cfg.start_new_block();
660-
let diverge_target = self.diverge_cleanup();
660+
let diverge_target = self.diverge_cleanup(span);
661661
self.cfg.terminate(block, source_info,
662662
TerminatorKind::Drop {
663663
location: location,
@@ -675,7 +675,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
675675
value: Operand<'tcx>) -> BlockAnd<()> {
676676
let source_info = self.source_info(span);
677677
let next_target = self.cfg.start_new_block();
678-
let diverge_target = self.diverge_cleanup();
678+
let diverge_target = self.diverge_cleanup(span);
679679
self.cfg.terminate(block, source_info,
680680
TerminatorKind::DropAndReplace {
681681
location: location,
@@ -698,7 +698,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
698698
let source_info = self.source_info(span);
699699

700700
let success_block = self.cfg.start_new_block();
701-
let cleanup = self.diverge_cleanup();
701+
let cleanup = self.diverge_cleanup(span);
702702

703703
self.cfg.terminate(block, source_info,
704704
TerminatorKind::Assert {
@@ -767,6 +767,7 @@ fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>,
767767
fn build_diverge_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
768768
cfg: &mut CFG<'tcx>,
769769
unit_temp: &Lvalue<'tcx>,
770+
span: Span,
770771
scope: &mut Scope<'tcx>,
771772
mut target: BasicBlock)
772773
-> BasicBlock

0 commit comments

Comments
 (0)