Skip to content

Commit f66fd89

Browse files
committed
replace DUMMY_SP on resume with span from fn
1 parent cb04e49 commit f66fd89

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/librustc_mir/build/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub struct Builder<'a, 'tcx: 'a> {
2222
hir: Cx<'a, 'tcx>,
2323
cfg: CFG<'tcx>,
2424

25+
fn_span: Span,
26+
2527
// the current set of scopes, updated as we traverse;
2628
// see the `scope` module for more details
2729
scopes: Vec<scope::Scope<'tcx>>,
@@ -147,6 +149,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
147149
let mut builder = Builder {
148150
hir: hir,
149151
cfg: cfg,
152+
fn_span: span,
150153
scopes: vec![],
151154
scope_data_vec: ScopeDataVec::new(),
152155
scope_auxiliary: vec![],

src/librustc_mir/build/scope.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
438438
// generate B0 <- B1 <- B2 in left-to-right order. Control flow of the generated blocks
439439
// always ends up at a block with the Resume terminator.
440440
if scopes.iter().any(|scope| !scope.drops.is_empty() || scope.free.is_some()) {
441-
Some(build_diverge_scope(hir.tcx(), cfg, &unit_temp, scopes))
441+
Some(build_diverge_scope(hir.tcx(), self.fn_span, cfg, &unit_temp, scopes))
442442
} else {
443443
None
444444
}
@@ -611,6 +611,7 @@ fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>,
611611
}
612612

613613
fn build_diverge_scope<'tcx>(tcx: &TyCtxt<'tcx>,
614+
fn_span: Span,
614615
cfg: &mut CFG<'tcx>,
615616
unit_temp: &Lvalue<'tcx>,
616617
scopes: &mut [Scope<'tcx>])
@@ -639,11 +640,11 @@ fn build_diverge_scope<'tcx>(tcx: &TyCtxt<'tcx>,
639640
// Diverging from the root scope creates a RESUME terminator.
640641
// FIXME what span to use here?
641642
let resumeblk = cfg.start_new_cleanup_block();
642-
cfg.terminate(resumeblk, scope.id, DUMMY_SP, TerminatorKind::Resume);
643+
cfg.terminate(resumeblk, scope.id, fn_span, TerminatorKind::Resume);
643644
resumeblk
644645
} else {
645646
// Diverging from any other scope chains up to the previous scope.
646-
build_diverge_scope(tcx, cfg, unit_temp, earlier_scopes)
647+
build_diverge_scope(tcx, fn_span, cfg, unit_temp, earlier_scopes)
647648
};
648649
scope.cached_block = Some(target);
649650

0 commit comments

Comments
 (0)