replace DUMMY_SP on resume with span from fn
This commit is contained in:
parent
cb04e495dc
commit
f66fd8972f
@ -22,6 +22,8 @@ pub struct Builder<'a, 'tcx: 'a> {
|
|||||||
hir: Cx<'a, 'tcx>,
|
hir: Cx<'a, 'tcx>,
|
||||||
cfg: CFG<'tcx>,
|
cfg: CFG<'tcx>,
|
||||||
|
|
||||||
|
fn_span: Span,
|
||||||
|
|
||||||
// the current set of scopes, updated as we traverse;
|
// the current set of scopes, updated as we traverse;
|
||||||
// see the `scope` module for more details
|
// see the `scope` module for more details
|
||||||
scopes: Vec<scope::Scope<'tcx>>,
|
scopes: Vec<scope::Scope<'tcx>>,
|
||||||
@ -147,6 +149,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
|
|||||||
let mut builder = Builder {
|
let mut builder = Builder {
|
||||||
hir: hir,
|
hir: hir,
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
|
fn_span: span,
|
||||||
scopes: vec![],
|
scopes: vec![],
|
||||||
scope_data_vec: ScopeDataVec::new(),
|
scope_data_vec: ScopeDataVec::new(),
|
||||||
scope_auxiliary: vec![],
|
scope_auxiliary: vec![],
|
||||||
|
@ -438,7 +438,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
|
|||||||
// generate B0 <- B1 <- B2 in left-to-right order. Control flow of the generated blocks
|
// generate B0 <- B1 <- B2 in left-to-right order. Control flow of the generated blocks
|
||||||
// always ends up at a block with the Resume terminator.
|
// always ends up at a block with the Resume terminator.
|
||||||
if scopes.iter().any(|scope| !scope.drops.is_empty() || scope.free.is_some()) {
|
if scopes.iter().any(|scope| !scope.drops.is_empty() || scope.free.is_some()) {
|
||||||
Some(build_diverge_scope(hir.tcx(), cfg, &unit_temp, scopes))
|
Some(build_diverge_scope(hir.tcx(), self.fn_span, cfg, &unit_temp, scopes))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -611,6 +611,7 @@ fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn build_diverge_scope<'tcx>(tcx: &TyCtxt<'tcx>,
|
fn build_diverge_scope<'tcx>(tcx: &TyCtxt<'tcx>,
|
||||||
|
fn_span: Span,
|
||||||
cfg: &mut CFG<'tcx>,
|
cfg: &mut CFG<'tcx>,
|
||||||
unit_temp: &Lvalue<'tcx>,
|
unit_temp: &Lvalue<'tcx>,
|
||||||
scopes: &mut [Scope<'tcx>])
|
scopes: &mut [Scope<'tcx>])
|
||||||
@ -639,11 +640,11 @@ fn build_diverge_scope<'tcx>(tcx: &TyCtxt<'tcx>,
|
|||||||
// Diverging from the root scope creates a RESUME terminator.
|
// Diverging from the root scope creates a RESUME terminator.
|
||||||
// FIXME what span to use here?
|
// FIXME what span to use here?
|
||||||
let resumeblk = cfg.start_new_cleanup_block();
|
let resumeblk = cfg.start_new_cleanup_block();
|
||||||
cfg.terminate(resumeblk, scope.id, DUMMY_SP, TerminatorKind::Resume);
|
cfg.terminate(resumeblk, scope.id, fn_span, TerminatorKind::Resume);
|
||||||
resumeblk
|
resumeblk
|
||||||
} else {
|
} else {
|
||||||
// Diverging from any other scope chains up to the previous scope.
|
// Diverging from any other scope chains up to the previous scope.
|
||||||
build_diverge_scope(tcx, cfg, unit_temp, earlier_scopes)
|
build_diverge_scope(tcx, fn_span, cfg, unit_temp, earlier_scopes)
|
||||||
};
|
};
|
||||||
scope.cached_block = Some(target);
|
scope.cached_block = Some(target);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user