]> git.lizzy.rs Git - rust.git/commitdiff
replace DUMMY_SP on resume with span from fn
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 23 Mar 2016 00:41:07 +0000 (20:41 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 23 Mar 2016 20:42:53 +0000 (16:42 -0400)
src/librustc_mir/build/mod.rs
src/librustc_mir/build/scope.rs

index 2da2a15cbd70917a20d94b253187ddd0ec523219..d52d750b12c5b55498b5e3ecd6d6571b1fb6a706 100644 (file)
@@ -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![],
index 5aeaef06b8910425f4a79e178229229d52a18c0c..cf09333d4acfbeb2c1226bec77e04691b76cff86 100644 (file)
@@ -438,7 +438,7 @@ pub fn diverge_cleanup(&mut self) -> Option<BasicBlock> {
         // 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);