about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2017-05-07 16:49:03 +0300
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2017-05-13 17:42:59 +0300
commit9809fe0d021ebed29d13a4f7fa58c660107da384 (patch)
tree3c0c8326d9cfce60abb2b7999e911690128d54ba /src
parentbd8246be744aa3620768e5e444527968f252e4fc (diff)
downloadrust-9809fe0d021ebed29d13a4f7fa58c660107da384.tar.gz
rust-9809fe0d021ebed29d13a4f7fa58c660107da384.zip
rustc: use call_site_extent for closure environment free regions.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/mem_categorization.rs16
-rw-r--r--src/librustc_mir/build/mod.rs2
2 files changed, 2 insertions, 16 deletions
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs
index 11a364f92c3..c489689d588 100644
--- a/src/librustc/middle/mem_categorization.rs
+++ b/src/librustc/middle/mem_categorization.rs
@@ -785,26 +785,12 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
                  cmt_result: cmt_<'tcx>)
                  -> cmt_<'tcx>
     {
-        // Look up the node ID of the closure body so we can construct
-        // a free region within it
-        let fn_body_id = {
-            let fn_expr = match self.tcx().hir.find(upvar_id.closure_expr_id) {
-                Some(hir_map::NodeExpr(e)) => e,
-                _ => bug!()
-            };
-
-            match fn_expr.node {
-                hir::ExprClosure(.., body_id, _) => body_id,
-                _ => bug!()
-            }
-        };
-
         // Region of environment pointer
         let env_region = self.tcx().mk_region(ty::ReFree(ty::FreeRegion {
             // The environment of a closure is guaranteed to
             // outlive any bindings introduced in the body of the
             // closure itself.
-            scope: Some(self.tcx().item_extent(fn_body_id.node_id)),
+            scope: Some(self.tcx().call_site_extent(upvar_id.closure_expr_id)),
             bound_region: ty::BrEnv
         }));
 
diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs
index 1634aade0bc..cecfd6e4c24 100644
--- a/src/librustc_mir/build/mod.rs
+++ b/src/librustc_mir/build/mod.rs
@@ -207,7 +207,7 @@ fn closure_self_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let closure_ty = tcx.body_tables(body_id).node_id_to_type(closure_expr_id);
 
     let region = ty::ReFree(ty::FreeRegion {
-        scope: Some(tcx.item_extent(body_id.node_id)),
+        scope: Some(tcx.call_site_extent(closure_expr_id)),
         bound_region: ty::BoundRegion::BrEnv,
     });
     let region = tcx.mk_region(region);