about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-03-22 20:41:07 -0400
committerNiko Matsakis <niko@alum.mit.edu>2016-03-23 16:42:53 -0400
commitf66fd8972f16f7a38f57c9953f1f6972a917c905 (patch)
tree4d3943074cf3a67b7e4ce8088dc99d0483aa37ee
parentcb04e495dc7a34cc708246dad7bb8b844216fd3e (diff)
downloadrust-f66fd8972f16f7a38f57c9953f1f6972a917c905.tar.gz
rust-f66fd8972f16f7a38f57c9953f1f6972a917c905.zip
replace DUMMY_SP on resume with span from fn
-rw-r--r--src/librustc_mir/build/mod.rs3
-rw-r--r--src/librustc_mir/build/scope.rs7
2 files changed, 7 insertions, 3 deletions
diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs
index 2da2a15cbd7..d52d750b12c 100644
--- a/src/librustc_mir/build/mod.rs
+++ b/src/librustc_mir/build/mod.rs
@@ -22,6 +22,8 @@ pub struct Builder<'a, 'tcx: 'a> {
     hir: Cx<'a, 'tcx>,
     cfg: CFG<'tcx>,
 
+    fn_span: Span,
+
     // the current set of scopes, updated as we traverse;
     // see the `scope` module for more details
     scopes: Vec<scope::Scope<'tcx>>,
@@ -147,6 +149,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
     let mut builder = Builder {
         hir: hir,
         cfg: cfg,
+        fn_span: span,
         scopes: vec![],
         scope_data_vec: ScopeDataVec::new(),
         scope_auxiliary: vec![],
diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs
index 5aeaef06b89..cf09333d4ac 100644
--- a/src/librustc_mir/build/scope.rs
+++ b/src/librustc_mir/build/scope.rs
@@ -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
         // always ends up at a block with the Resume terminator.
         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 {
             None
         }
@@ -611,6 +611,7 @@ fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>,
 }
 
 fn build_diverge_scope<'tcx>(tcx: &TyCtxt<'tcx>,
+                             fn_span: Span,
                              cfg: &mut CFG<'tcx>,
                              unit_temp: &Lvalue<'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.
         // FIXME what span to use here?
         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
     } else {
         // 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);