]> git.lizzy.rs Git - rust.git/commitdiff
rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent.
authorEduard-Mihai Burtescu <edy.burt@gmail.com>
Tue, 29 Aug 2017 16:24:49 +0000 (19:24 +0300)
committerEduard-Mihai Burtescu <edy.burt@gmail.com>
Fri, 1 Sep 2017 08:18:31 +0000 (11:18 +0300)
37 files changed:
src/librustc/cfg/construct.rs
src/librustc/cfg/graphviz.rs
src/librustc/infer/error_reporting/mod.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/region.rs
src/librustc/traits/mod.rs
src/librustc/ty/mod.rs
src/librustc/util/ppaux.rs
src/librustc_borrowck/borrowck/check_loans.rs
src/librustc_borrowck/borrowck/gather_loans/lifetime.rs
src/librustc_borrowck/borrowck/gather_loans/mod.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_borrowck/borrowck/move_data.rs
src/librustc_driver/test.rs
src/librustc_lint/builtin.rs
src/librustc_mir/build/matches/mod.rs
src/librustc_mir/build/mod.rs
src/librustc_mir/hair/cx/block.rs
src/librustc_mir/hair/cx/expr.rs
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/dropck.rs
src/librustc_typeck/check/generator_interior.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/coherence/builtin.rs
src/test/mir-opt/end_region_1.rs
src/test/mir-opt/end_region_2.rs
src/test/mir-opt/end_region_3.rs
src/test/mir-opt/end_region_4.rs
src/test/mir-opt/end_region_5.rs
src/test/mir-opt/end_region_6.rs
src/test/mir-opt/end_region_7.rs
src/test/mir-opt/end_region_8.rs
src/test/mir-opt/validate_1.rs
src/test/mir-opt/validate_3.rs
src/test/mir-opt/validate_5.rs

index 1448fb7c528c6243597894df1a76270398f2f074..8908bcb88655901d0b7926d13a933bff4ee05c8d 100644 (file)
@@ -582,10 +582,10 @@ fn add_exiting_edge(&mut self,
                         target_scope: CodeExtent,
                         to_index: CFGIndex) {
         let mut data = CFGEdgeData { exiting_scopes: vec![] };
-        let mut scope = CodeExtent::Misc(from_expr.id);
+        let mut scope = CodeExtent::Misc(from_expr.hir_id.local_id);
         let region_maps = self.tcx.region_maps(self.owner_def_id);
         while scope != target_scope {
-            data.exiting_scopes.push(self.tcx.hir.node_to_hir_id(scope.node_id()).local_id);
+            data.exiting_scopes.push(scope.item_local_id());
             scope = region_maps.encl_scope(scope);
         }
         self.graph.add_edge(from_index, to_index, data);
@@ -612,7 +612,8 @@ fn find_scope_edge(&self,
             hir::ScopeTarget::Block(block_expr_id) => {
                 for b in &self.breakable_block_scopes {
                     if b.block_expr_id == self.tcx.hir.node_to_hir_id(block_expr_id).local_id {
-                        return (CodeExtent::Misc(block_expr_id), match scope_cf_kind {
+                        let scope_id = self.tcx.hir.node_to_hir_id(block_expr_id).local_id;
+                        return (CodeExtent::Misc(scope_id), match scope_cf_kind {
                             ScopeCfKind::Break => b.break_index,
                             ScopeCfKind::Continue => bug!("can't continue to block"),
                         });
@@ -623,7 +624,8 @@ fn find_scope_edge(&self,
             hir::ScopeTarget::Loop(hir::LoopIdResult::Ok(loop_id)) => {
                 for l in &self.loop_scopes {
                     if l.loop_id == self.tcx.hir.node_to_hir_id(loop_id).local_id {
-                        return (CodeExtent::Misc(loop_id), match scope_cf_kind {
+                        let scope_id = self.tcx.hir.node_to_hir_id(loop_id).local_id;
+                        return (CodeExtent::Misc(scope_id), match scope_cf_kind {
                             ScopeCfKind::Break => l.break_index,
                             ScopeCfKind::Continue => l.continue_index,
                         });
index fa034744b62e21b2c3b660e66a7e9bcc1ac97c57..9241240caf043b174a72fdd913d6c2bbf91b940d 100644 (file)
@@ -32,8 +32,9 @@ pub struct LabelledCFG<'a, 'tcx: 'a> {
 
 impl<'a, 'tcx> LabelledCFG<'a, 'tcx> {
     fn local_id_to_string(&self, local_id: hir::ItemLocalId) -> String {
+        assert!(self.cfg.owner_def_id.is_local());
         let node_id = self.tcx.hir.hir_to_node_id(hir::HirId {
-            owner: self.tcx.closure_base_def_id(self.cfg.owner_def_id).index,
+            owner: self.tcx.hir.def_index_to_hir_id(self.cfg.owner_def_id.index).owner,
             local_id
         });
         let s = self.tcx.hir.node_to_string(node_id);
index d86626c210e14ae3fea10371707b9be432a97b88..90d781c6e36649e15357bf3faf14a802da7b165a 100644 (file)
@@ -132,7 +132,7 @@ fn explain_span<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
                             prefix, scope, suffix)
                 };
                 let span = scope.span(self, region_maps);
-                let tag = match self.hir.find(scope.node_id()) {
+                let tag = match self.hir.find(scope.node_id(self, region_maps)) {
                     Some(hir_map::NodeBlock(_)) => "block",
                     Some(hir_map::NodeExpr(expr)) => match expr.node {
                         hir::ExprCall(..) => "call",
index e36e1f470eb699ed015568e68ff9025fe921f0a9..1589ba60275904dc5ea7d0e398cf0b43e4c4983a 100644 (file)
@@ -23,7 +23,7 @@
 use hir::def_id::{DefId};
 use infer::InferCtxt;
 use middle::mem_categorization as mc;
-use middle::region::RegionMaps;
+use middle::region::{CodeExtent, RegionMaps};
 use ty::{self, TyCtxt, adjustment};
 
 use hir::{self, PatKind};
@@ -298,7 +298,8 @@ pub fn consume_body(&mut self, body: &hir::Body) {
         for arg in &body.arguments {
             let arg_ty = return_if_err!(self.mc.node_ty(arg.pat.hir_id));
 
-            let fn_body_scope_r = self.tcx().node_scope_region(body.value.id);
+            let fn_body_scope_r =
+                self.tcx().mk_region(ty::ReScope(CodeExtent::Misc(body.value.hir_id.local_id)));
             let arg_cmt = self.mc.cat_rvalue(
                 arg.id,
                 arg.pat.span,
@@ -542,16 +543,17 @@ fn walk_callee(&mut self, call: &hir::Expr, callee: &hir::Expr) {
             ty::TyError => { }
             _ => {
                 let def_id = self.mc.tables.type_dependent_defs()[call.hir_id].def_id();
+                let call_scope = CodeExtent::Misc(call.hir_id.local_id);
                 match OverloadedCallType::from_method_id(self.tcx(), def_id) {
                     FnMutOverloadedCall => {
-                        let call_scope_r = self.tcx().node_scope_region(call.id);
+                        let call_scope_r = self.tcx().mk_region(ty::ReScope(call_scope));
                         self.borrow_expr(callee,
                                          call_scope_r,
                                          ty::MutBorrow,
                                          ClosureInvocation);
                     }
                     FnOverloadedCall => {
-                        let call_scope_r = self.tcx().node_scope_region(call.id);
+                        let call_scope_r = self.tcx().mk_region(ty::ReScope(call_scope));
                         self.borrow_expr(callee,
                                          call_scope_r,
                                          ty::ImmBorrow,
@@ -749,7 +751,7 @@ fn walk_autoref(&mut self,
                 // Converting from a &T to *T (or &mut T to *mut T) is
                 // treated as borrowing it for the enclosing temporary
                 // scope.
-                let r = self.tcx().node_scope_region(expr.id);
+                let r = self.tcx().mk_region(ty::ReScope(CodeExtent::Misc(expr.hir_id.local_id)));
 
                 self.delegate.borrow(expr.id,
                                      expr.span,
index 034861131e86e9fbf5b7b9eddee1ef51a5504d45..fdab71ee004419b8836ef3d44e995a302a2f2cd1 100644 (file)
@@ -861,8 +861,7 @@ fn env_deref(&self,
 
     /// Returns the lifetime of a temporary created by expr with id `id`.
     /// This could be `'static` if `id` is part of a constant expression.
-    pub fn temporary_scope(&self, id: ast::NodeId) -> ty::Region<'tcx>
-    {
+    pub fn temporary_scope(&self, id: hir::ItemLocalId) -> ty::Region<'tcx> {
         let scope = self.region_maps.temporary_scope(id);
         self.tcx.mk_region(match scope {
             Some(scope) => ty::ReScope(scope),
@@ -890,7 +889,7 @@ pub fn cat_rvalue_node(&self,
         let re = if promotable {
             self.tcx.types.re_static
         } else {
-            self.temporary_scope(id)
+            self.temporary_scope(self.tcx.hir.node_to_hir_id(id).local_id)
         };
         let ret = self.cat_rvalue(id, span, re, expr_ty);
         debug!("cat_rvalue_node ret {:?}", ret);
index 10a21a582f55439da5534cb9a76b7d4df8a04ff9..f58d1a0b41fec859e249e3f0257c0e218f3b61bf 100644 (file)
 //! Most of the documentation on regions can be found in
 //! `middle/infer/region_inference/README.md`
 
-use util::nodemap::{FxHashMap, NodeMap, NodeSet};
+use util::nodemap::{FxHashMap, FxHashSet};
 use ty;
 
+use std::collections::hash_map::Entry;
 use std::mem;
 use std::rc::Rc;
 use syntax::codemap;
 use syntax::ast;
-use syntax::ast::NodeId;
-use syntax_pos::Span;
+use syntax_pos::{Span, DUMMY_SP};
 use ty::TyCtxt;
 use ty::maps::Providers;
 
@@ -32,7 +32,6 @@
 use hir::def_id::DefId;
 use hir::intravisit::{self, Visitor, NestedVisitorMap};
 use hir::{Block, Arm, Pat, PatKind, Stmt, Expr, Local};
-use hir::map::Node;
 use mir::transform::MirSource;
 
 /// CodeExtent represents a statically-describable extent that can be
 /// generated via deriving here.
 #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Debug, Copy, RustcEncodable, RustcDecodable)]
 pub enum CodeExtent {
-    Misc(ast::NodeId),
+    Misc(hir::ItemLocalId),
 
     // extent of the call-site for a function or closure (outlives
     // the parameters as well as the body).
-    CallSiteScope(hir::BodyId),
+    CallSiteScope(hir::ItemLocalId),
 
     // extent of parameters passed to a function or closure (they
     // outlive its body)
-    ParameterScope(hir::BodyId),
+    ParameterScope(hir::ItemLocalId),
 
     // extent of destructors for temporaries of node-id
-    DestructionScope(ast::NodeId),
+    DestructionScope(hir::ItemLocalId),
 
     // extent of code following a `let id = expr;` binding in a block
     Remainder(BlockRemainder)
@@ -135,25 +134,37 @@ pub enum CodeExtent {
 #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, RustcEncodable,
          RustcDecodable, Debug, Copy)]
 pub struct BlockRemainder {
-    pub block: ast::NodeId,
+    pub block: hir::ItemLocalId,
     pub first_statement_index: u32,
 }
 
 impl CodeExtent {
-    /// Returns a node id associated with this scope.
+    /// Returns a item-local id associated with this scope.
     ///
     /// NB: likely to be replaced as API is refined; e.g. pnkfelix
     /// anticipates `fn entry_node_id` and `fn each_exit_node_id`.
-    pub fn node_id(&self) -> ast::NodeId {
+    pub fn item_local_id(&self) -> hir::ItemLocalId {
         match *self {
-            CodeExtent::Misc(node_id) => node_id,
+            CodeExtent::Misc(id) => id,
 
             // These cases all return rough approximations to the
             // precise extent denoted by `self`.
             CodeExtent::Remainder(br) => br.block,
-            CodeExtent::DestructionScope(node_id) => node_id,
-            CodeExtent::CallSiteScope(body_id) |
-            CodeExtent::ParameterScope(body_id) => body_id.node_id,
+            CodeExtent::DestructionScope(id) |
+            CodeExtent::CallSiteScope(id) |
+            CodeExtent::ParameterScope(id) => id,
+        }
+    }
+
+    pub fn node_id(&self, tcx: TyCtxt, region_maps: &RegionMaps) -> ast::NodeId {
+        match region_maps.root_body {
+            Some(hir_id) => {
+                tcx.hir.hir_to_node_id(hir::HirId {
+                    owner: hir_id.owner,
+                    local_id: self.item_local_id()
+                })
+            }
+            None => ast::DUMMY_NODE_ID
         }
     }
 
@@ -161,12 +172,13 @@ pub fn node_id(&self) -> ast::NodeId {
     /// returned span may not correspond to the span of any node id in
     /// the AST.
     pub fn span(&self, tcx: TyCtxt, region_maps: &RegionMaps) -> Span {
-        let root_node = region_maps.root_body.unwrap().node_id;
-        assert_eq!(DefId::local(tcx.hir.node_to_hir_id(self.node_id()).owner),
-                   DefId::local(tcx.hir.node_to_hir_id(root_node).owner));
-        let span = tcx.hir.span(self.node_id());
+        let node_id = self.node_id(tcx, region_maps);
+        if node_id == ast::DUMMY_NODE_ID {
+            return DUMMY_SP;
+        }
+        let span = tcx.hir.span(node_id);
         if let CodeExtent::Remainder(r) = *self {
-            if let hir::map::NodeBlock(ref blk) = tcx.hir.get(r.block) {
+            if let hir::map::NodeBlock(ref blk) = tcx.hir.get(node_id) {
                 // Want span for extent starting after the
                 // indexed statement and ending at end of
                 // `blk`; reuse span of `blk` and shift `lo`
@@ -189,9 +201,10 @@ pub fn span(&self, tcx: TyCtxt, region_maps: &RegionMaps) -> Span {
 }
 
 /// The region maps encode information about region relationships.
+#[derive(Default)]
 pub struct RegionMaps {
     /// If not empty, this body is the root of this region hierarchy.
-    root_body: Option<hir::BodyId>,
+    root_body: Option<hir::HirId>,
 
     /// The parent of the root body owner, if the latter is an
     /// an associated const or method, as impls/traits can also
@@ -208,10 +221,10 @@ pub struct RegionMaps {
 
     /// `var_map` maps from a variable or binding id to the block in
     /// which that variable is declared.
-    var_map: NodeMap<CodeExtent>,
+    var_map: FxHashMap<hir::ItemLocalId, CodeExtent>,
 
     /// maps from a node-id to the associated destruction scope (if any)
-    destruction_scopes: NodeMap<CodeExtent>,
+    destruction_scopes: FxHashMap<hir::ItemLocalId, CodeExtent>,
 
     /// `rvalue_scopes` includes entries for those expressions whose cleanup scope is
     /// larger than the default. The map goes from the expression id
@@ -221,7 +234,7 @@ pub struct RegionMaps {
     /// block (see `terminating_scopes`).
     /// In constants, None is used to indicate that certain expressions
     /// escape into 'static and should have no local cleanup scope.
-    rvalue_scopes: NodeMap<Option<CodeExtent>>,
+    rvalue_scopes: FxHashMap<hir::ItemLocalId, Option<CodeExtent>>,
 
     /// Encodes the hierarchy of fn bodies. Every fn body (including
     /// closures) forms its own distinct region hierarchy, rooted in
@@ -233,7 +246,11 @@ pub struct RegionMaps {
     /// closure defined by that fn. See the "Modeling closures"
     /// section of the README in infer::region_inference for
     /// more details.
-    fn_tree: NodeMap<ast::NodeId>,
+    closure_tree: FxHashMap<hir::ItemLocalId, hir::ItemLocalId>,
+
+    /// If there are any `yield` nested within a scope, this map
+    /// stores the `Span` of the first one.
+    yield_in_scope: FxHashMap<CodeExtent, Span>,
 }
 
 #[derive(Debug, Copy, Clone)]
@@ -244,7 +261,7 @@ pub struct Context {
     /// arranged into a tree. See the "Modeling closures" section of
     /// the README in infer::region_inference for more
     /// details.
-    root_id: Option<ast::NodeId>,
+    root_id: Option<hir::ItemLocalId>,
 
     /// the scope that contains any new variables declared
     var_parent: Option<CodeExtent>,
@@ -281,23 +298,11 @@ struct RegionResolutionVisitor<'a, 'tcx: 'a> {
     /// arbitrary amounts of stack space. Terminating scopes end
     /// up being contained in a DestructionScope that contains the
     /// destructor's execution.
-    terminating_scopes: NodeSet,
+    terminating_scopes: FxHashSet<hir::ItemLocalId>,
 }
 
 
 impl<'tcx> RegionMaps {
-    pub fn new() -> Self {
-        RegionMaps {
-            root_body: None,
-            root_parent: None,
-            scope_map: FxHashMap(),
-            destruction_scopes: FxHashMap(),
-            var_map: NodeMap(),
-            rvalue_scopes: NodeMap(),
-            fn_tree: NodeMap(),
-        }
-    }
-
     pub fn record_code_extent(&mut self,
                               child: CodeExtent,
                               parent: Option<CodeExtent>) {
@@ -320,46 +325,51 @@ pub fn each_encl_scope<E>(&self, mut e:E) where E: FnMut(CodeExtent, CodeExtent)
         }
     }
 
-    pub fn each_var_scope<E>(&self, mut e:E) where E: FnMut(&ast::NodeId, CodeExtent) {
+    pub fn each_var_scope<E>(&self, mut e:E) where E: FnMut(&hir::ItemLocalId, CodeExtent) {
         for (child, &parent) in self.var_map.iter() {
             e(child, parent)
         }
     }
 
-    pub fn opt_destruction_extent(&self, n: ast::NodeId) -> Option<CodeExtent> {
+    pub fn opt_destruction_extent(&self, n: hir::ItemLocalId) -> Option<CodeExtent> {
         self.destruction_scopes.get(&n).cloned()
     }
 
-    /// Records that `sub_fn` is defined within `sup_fn`. These ids
+    /// Records that `sub_closure` is defined within `sup_closure`. These ids
     /// should be the id of the block that is the fn body, which is
     /// also the root of the region hierarchy for that fn.
-    fn record_fn_parent(&mut self, sub_fn: ast::NodeId, sup_fn: ast::NodeId) {
-        debug!("record_fn_parent(sub_fn={:?}, sup_fn={:?})", sub_fn, sup_fn);
-        assert!(sub_fn != sup_fn);
-        let previous = self.fn_tree.insert(sub_fn, sup_fn);
+    fn record_closure_parent(&mut self,
+                             sub_closure: hir::ItemLocalId,
+                             sup_closure: hir::ItemLocalId) {
+        debug!("record_closure_parent(sub_closure={:?}, sup_closure={:?})",
+               sub_closure, sup_closure);
+        assert!(sub_closure != sup_closure);
+        let previous = self.closure_tree.insert(sub_closure, sup_closure);
         assert!(previous.is_none());
     }
 
-    fn fn_is_enclosed_by(&self, mut sub_fn: ast::NodeId, sup_fn: ast::NodeId) -> bool {
+    fn closure_is_enclosed_by(&self,
+                              mut sub_closure: hir::ItemLocalId,
+                              sup_closure: hir::ItemLocalId) -> bool {
         loop {
-            if sub_fn == sup_fn { return true; }
-            match self.fn_tree.get(&sub_fn) {
-                Some(&s) => { sub_fn = s; }
+            if sub_closure == sup_closure { return true; }
+            match self.closure_tree.get(&sub_closure) {
+                Some(&s) => { sub_closure = s; }
                 None => { return false; }
             }
         }
     }
 
-    fn record_var_scope(&mut self, var: ast::NodeId, lifetime: CodeExtent) {
+    fn record_var_scope(&mut self, var: hir::ItemLocalId, lifetime: CodeExtent) {
         debug!("record_var_scope(sub={:?}, sup={:?})", var, lifetime);
-        assert!(var != lifetime.node_id());
+        assert!(var != lifetime.item_local_id());
         self.var_map.insert(var, lifetime);
     }
 
-    fn record_rvalue_scope(&mut self, var: ast::NodeId, lifetime: Option<CodeExtent>) {
+    fn record_rvalue_scope(&mut self, var: hir::ItemLocalId, lifetime: Option<CodeExtent>) {
         debug!("record_rvalue_scope(sub={:?}, sup={:?})", var, lifetime);
         if let Some(lifetime) = lifetime {
-            assert!(var != lifetime.node_id());
+            assert!(var != lifetime.item_local_id());
         }
         self.rvalue_scopes.insert(var, lifetime);
     }
@@ -376,14 +386,14 @@ pub fn encl_scope(&self, id: CodeExtent) -> CodeExtent {
     }
 
     /// Returns the lifetime of the local variable `var_id`
-    pub fn var_scope(&self, var_id: ast::NodeId) -> CodeExtent {
+    pub fn var_scope(&self, var_id: hir::ItemLocalId) -> CodeExtent {
         match self.var_map.get(&var_id) {
             Some(&r) => r,
             None => { bug!("no enclosing scope for id {:?}", var_id); }
         }
     }
 
-    pub fn temporary_scope(&self, expr_id: ast::NodeId) -> Option<CodeExtent> {
+    pub fn temporary_scope(&self, expr_id: hir::ItemLocalId) -> Option<CodeExtent> {
         //! Returns the scope when temp created by expr_id will be cleaned up
 
         // check for a designated rvalue scope
@@ -413,7 +423,7 @@ pub fn temporary_scope(&self, expr_id: ast::NodeId) -> Option<CodeExtent> {
         return None;
     }
 
-    pub fn var_region(&self, id: ast::NodeId) -> ty::RegionKind {
+    pub fn var_region(&self, id: hir::ItemLocalId) -> ty::RegionKind {
         //! Returns the lifetime of the variable `id`.
 
         let scope = ty::ReScope(self.var_scope(id));
@@ -493,10 +503,10 @@ pub fn nearest_common_ancestor(&self,
             return match (a_root_scope, b_root_scope) {
                 (CodeExtent::DestructionScope(a_root_id),
                  CodeExtent::DestructionScope(b_root_id)) => {
-                    if self.fn_is_enclosed_by(a_root_id, b_root_id) {
+                    if self.closure_is_enclosed_by(a_root_id, b_root_id) {
                         // `a` is enclosed by `b`, hence `b` is the ancestor of everything in `a`
                         scope_b
-                    } else if self.fn_is_enclosed_by(b_root_id, a_root_id) {
+                    } else if self.closure_is_enclosed_by(b_root_id, a_root_id) {
                         // `b` is enclosed by `a`, hence `a` is the ancestor of everything in `b`
                         scope_a
                     } else {
@@ -561,20 +571,23 @@ pub fn early_free_extent<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
         let param_owner = tcx.parent_def_id(br.def_id).unwrap();
 
         let param_owner_id = tcx.hir.as_local_node_id(param_owner).unwrap();
-        let body_id = tcx.hir.maybe_body_owned_by(param_owner_id).unwrap_or_else(|| {
+        let scope = tcx.hir.maybe_body_owned_by(param_owner_id).map(|body_id| {
+            tcx.hir.body(body_id).value.hir_id.local_id
+        }).unwrap_or_else(|| {
             // The lifetime was defined on node that doesn't own a body,
             // which in practice can only mean a trait or an impl, that
             // is the parent of a method, and that is enforced below.
             assert_eq!(Some(param_owner_id), self.root_parent,
-                       "free_extent: {:?} not recognized by the region maps for {:?}",
+                       "free_extent: {:?} not recognized by the region maps for {:?} / {:?}",
                        param_owner,
-                       self.root_body.map(|body| tcx.hir.body_owner_def_id(body)));
+                       self.root_parent.map(|id| tcx.hir.local_def_id(id)),
+                       self.root_body.map(|hir_id| DefId::local(hir_id.owner)));
 
             // The trait/impl lifetime is in scope for the method's body.
-            self.root_body.unwrap()
+            self.root_body.unwrap().local_id
         });
 
-        CodeExtent::CallSiteScope(body_id)
+        CodeExtent::CallSiteScope(scope)
     }
 
     /// Assuming that the provided region was defined within this `RegionMaps`,
@@ -593,13 +606,20 @@ pub fn free_extent<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, fr: &ty::FreeRe
         assert_eq!(param_owner, fr.scope);
 
         let param_owner_id = tcx.hir.as_local_node_id(param_owner).unwrap();
-        CodeExtent::CallSiteScope(tcx.hir.body_owned_by(param_owner_id))
+        let body_id = tcx.hir.body_owned_by(param_owner_id);
+        CodeExtent::CallSiteScope(tcx.hir.body(body_id).value.hir_id.local_id)
+    }
+
+    /// Checks whether the given code extent contains a `yield`. If so,
+    /// returns `Some(span)` with the span of a yield we found.
+    pub fn yield_in_scope(&self, scope: CodeExtent) -> Option<Span> {
+        self.yield_in_scope.get(&scope).cloned()
     }
 }
 
 /// Records the lifetime of a local variable as `cx.var_parent`
 fn record_var_lifetime(visitor: &mut RegionResolutionVisitor,
-                       var_id: ast::NodeId,
+                       var_id: hir::ItemLocalId,
                        _sp: Span) {
     match visitor.cx.var_parent {
         None => {
@@ -642,7 +662,7 @@ fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk:
     // `other_argument()` has run and also the call to `quux(..)`
     // itself has returned.
 
-    visitor.enter_node_extent_with_dtor(blk.id);
+    visitor.enter_node_extent_with_dtor(blk.hir_id.local_id);
     visitor.cx.var_parent = visitor.cx.parent;
 
     {
@@ -661,7 +681,7 @@ fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk:
                 // block itself as a parent.
                 visitor.enter_code_extent(
                     CodeExtent::Remainder(BlockRemainder {
-                        block: blk.id,
+                        block: blk.hir_id.local_id,
                         first_statement_index: i as u32
                     })
                 );
@@ -676,28 +696,28 @@ fn resolve_block<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, blk:
 }
 
 fn resolve_arm<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, arm: &'tcx hir::Arm) {
-    visitor.terminating_scopes.insert(arm.body.id);
+    visitor.terminating_scopes.insert(arm.body.hir_id.local_id);
 
     if let Some(ref expr) = arm.guard {
-        visitor.terminating_scopes.insert(expr.id);
+        visitor.terminating_scopes.insert(expr.hir_id.local_id);
     }
 
     intravisit::walk_arm(visitor, arm);
 }
 
 fn resolve_pat<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, pat: &'tcx hir::Pat) {
-    visitor.record_code_extent(CodeExtent::Misc(pat.id));
+    visitor.record_code_extent(CodeExtent::Misc(pat.hir_id.local_id));
 
     // If this is a binding then record the lifetime of that binding.
     if let PatKind::Binding(..) = pat.node {
-        record_var_lifetime(visitor, pat.id, pat.span);
+        record_var_lifetime(visitor, pat.hir_id.local_id, pat.span);
     }
 
     intravisit::walk_pat(visitor, pat);
 }
 
 fn resolve_stmt<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, stmt: &'tcx hir::Stmt) {
-    let stmt_id = stmt.node.id();
+    let stmt_id = visitor.tcx.hir.node_to_hir_id(stmt.node.id()).local_id;
     debug!("resolve_stmt(stmt.id={:?})", stmt_id);
 
     // Every statement will clean up the temporaries created during
@@ -719,11 +739,11 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr:
     debug!("resolve_expr(expr.id={:?})", expr.id);
 
     let prev_cx = visitor.cx;
-    visitor.enter_node_extent_with_dtor(expr.id);
+    visitor.enter_node_extent_with_dtor(expr.hir_id.local_id);
 
     {
         let terminating_scopes = &mut visitor.terminating_scopes;
-        let mut terminating = |id: ast::NodeId| {
+        let mut terminating = |id: hir::ItemLocalId| {
             terminating_scopes.insert(id);
         };
         match expr.node {
@@ -735,27 +755,27 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr:
             hir::ExprBinary(codemap::Spanned { node: hir::BiOr, .. }, _, ref r) => {
                 // For shortcircuiting operators, mark the RHS as a terminating
                 // scope since it only executes conditionally.
-                terminating(r.id);
+                terminating(r.hir_id.local_id);
             }
 
             hir::ExprIf(ref expr, ref then, Some(ref otherwise)) => {
-                terminating(expr.id);
-                terminating(then.id);
-                terminating(otherwise.id);
+                terminating(expr.hir_id.local_id);
+                terminating(then.hir_id.local_id);
+                terminating(otherwise.hir_id.local_id);
             }
 
             hir::ExprIf(ref expr, ref then, None) => {
-                terminating(expr.id);
-                terminating(then.id);
+                terminating(expr.hir_id.local_id);
+                terminating(then.hir_id.local_id);
             }
 
             hir::ExprLoop(ref body, _, _) => {
-                terminating(body.id);
+                terminating(body.hir_id.local_id);
             }
 
             hir::ExprWhile(ref expr, ref body, _) => {
-                terminating(expr.id);
-                terminating(body.id);
+                terminating(expr.hir_id.local_id);
+                terminating(body.hir_id.local_id);
             }
 
             hir::ExprMatch(..) => {
@@ -784,6 +804,29 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr:
                 // record_superlifetime(new_cx, expr.callee_id);
             }
 
+            hir::ExprYield(..) => {
+                // Mark this expr's scope and all parent scopes as containing `yield`.
+                let mut scope = CodeExtent::Misc(expr.hir_id.local_id);
+                loop {
+                    match visitor.region_maps.yield_in_scope.entry(scope) {
+                        // Another `yield` has already been found.
+                        Entry::Occupied(_) => break,
+
+                        Entry::Vacant(entry) => {
+                            entry.insert(expr.span);
+                        }
+                    }
+
+                    // Keep traversing up while we can.
+                    match visitor.region_maps.scope_map.get(&scope) {
+                        // Don't cross from closure bodies to their parent.
+                        Some(&CodeExtent::CallSiteScope(_)) => break,
+                        Some(&superscope) => scope = superscope,
+                        None => break
+                    }
+                }
+            }
+
             _ => {}
         }
     }
@@ -1014,7 +1057,7 @@ fn record_rvalue_scope<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>
             // because in trans if we must compile e.g. `*rvalue()`
             // into a temporary, we request the temporary scope of the
             // outer expression.
-            visitor.region_maps.record_rvalue_scope(expr.id, blk_scope);
+            visitor.region_maps.record_rvalue_scope(expr.hir_id.local_id, blk_scope);
 
             match expr.node {
                 hir::ExprAddrOf(_, ref subexpr) |
@@ -1046,7 +1089,7 @@ fn enter_code_extent(&mut self, child_scope: CodeExtent) {
         self.cx.parent = Some(child_scope);
     }
 
-    fn enter_node_extent_with_dtor(&mut self, id: ast::NodeId) {
+    fn enter_node_extent_with_dtor(&mut self, id: hir::ItemLocalId) {
         // If node was previously marked as a terminating scope during the
         // recursive visit of its parent node in the AST, then we need to
         // account for the destruction scope representing the extent of
@@ -1078,16 +1121,16 @@ fn visit_body(&mut self, body: &'tcx hir::Body) {
                self.cx.parent);
 
         let outer_cx = self.cx;
-        let outer_ts = mem::replace(&mut self.terminating_scopes, NodeSet());
-        self.terminating_scopes.insert(body_id.node_id);
+        let outer_ts = mem::replace(&mut self.terminating_scopes, FxHashSet());
+        self.terminating_scopes.insert(body.value.hir_id.local_id);
 
         if let Some(root_id) = self.cx.root_id {
-            self.region_maps.record_fn_parent(body_id.node_id, root_id);
+            self.region_maps.record_closure_parent(body.value.hir_id.local_id, root_id);
         }
-        self.cx.root_id = Some(body_id.node_id);
+        self.cx.root_id = Some(body.value.hir_id.local_id);
 
-        self.enter_code_extent(CodeExtent::CallSiteScope(body_id));
-        self.enter_code_extent(CodeExtent::ParameterScope(body_id));
+        self.enter_code_extent(CodeExtent::CallSiteScope(body.value.hir_id.local_id));
+        self.enter_code_extent(CodeExtent::ParameterScope(body.value.hir_id.local_id));
 
         // The arguments and `self` are parented to the fn.
         self.cx.var_parent = self.cx.parent.take();
@@ -1153,19 +1196,20 @@ fn region_maps<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
     }
 
     let id = tcx.hir.as_local_node_id(def_id).unwrap();
-    let maps = if let Some(body) = tcx.hir.maybe_body_owned_by(id) {
+    let maps = if let Some(body_id) = tcx.hir.maybe_body_owned_by(id) {
         let mut visitor = RegionResolutionVisitor {
             tcx,
-            region_maps: RegionMaps::new(),
+            region_maps: RegionMaps::default(),
             cx: Context {
                 root_id: None,
                 parent: None,
                 var_parent: None,
             },
-            terminating_scopes: NodeSet(),
+            terminating_scopes: FxHashSet(),
         };
 
-        visitor.region_maps.root_body = Some(body);
+        let body = tcx.hir.body(body_id);
+        visitor.region_maps.root_body = Some(body.value.hir_id);
 
         // If the item is an associated const or a method,
         // record its impl/trait parent, as it can also have
@@ -1178,112 +1222,16 @@ fn region_maps<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
             _ => {}
         }
 
-        visitor.visit_body(tcx.hir.body(body));
+        visitor.visit_body(body);
 
         visitor.region_maps
     } else {
-        RegionMaps::new()
+        RegionMaps::default()
     };
 
     Rc::new(maps)
 }
 
-struct YieldFinder<'a> {
-    cache: &'a mut FxHashMap<NodeId, Option<Span>>,
-    result: Option<Span>,
-}
-
-impl<'a> YieldFinder<'a> {
-    fn lookup<F: FnOnce(&mut Self)>(&mut self, id: NodeId, f: F) {
-        // Don't traverse further if we found a yield expression
-        if self.result.is_some() {
-            return;
-        }
-
-        // See if there's an entry in the cache
-        if let Some(result) = self.cache.get(&id) {
-            self.result = *result;
-            return;
-        }
-
-        // Otherwise calculate the result and insert it into the cache
-        f(self);
-        self.cache.insert(id, self.result);
-    }
-}
-
-impl<'a, 'tcx> Visitor<'tcx> for YieldFinder<'a> {
-    fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
-        NestedVisitorMap::None
-    }
-
-    fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
-        if let hir::ExprYield(..) = expr.node {
-            self.result = Some(expr.span);
-            return;
-        }
-
-        self.lookup(expr.id, |this| {
-            intravisit::walk_expr(this, expr);
-        });
-    }
-
-    fn visit_block(&mut self, block: &'tcx hir::Block) {
-        self.lookup(block.id, |this| {
-            intravisit::walk_block(this, block);
-        });
-    }
-}
-
-impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
-    /// Checks whether the given code extent contains a `yield`. If so,
-    /// returns `Some(span)` with the span of a yield we found.
-    pub fn yield_in_extent(self,
-                          extent: CodeExtent,
-                          cache: &mut FxHashMap<NodeId, Option<Span>>) -> Option<Span> {
-        let mut finder = YieldFinder {
-            cache,
-            result: None,
-        };
-
-        match extent {
-            CodeExtent::DestructionScope(node_id) |
-            CodeExtent::Misc(node_id) => {
-                match self.hir.get(node_id) {
-                    Node::NodeItem(_) |
-                    Node::NodeTraitItem(_) |
-                    Node::NodeImplItem(_) => {
-                        let body = self.hir.body(self.hir.body_owned_by(node_id));
-                        finder.visit_body(body);
-                    }
-                    Node::NodeExpr(expr) => finder.visit_expr(expr),
-                    Node::NodeStmt(stmt) => finder.visit_stmt(stmt),
-                    Node::NodeBlock(block) => finder.visit_block(block),
-                    _ => bug!(),
-                }
-            }
-
-            CodeExtent::CallSiteScope(body_id) |
-            CodeExtent::ParameterScope(body_id) => {
-                finder.visit_body(self.hir.body(body_id))
-            }
-
-            CodeExtent::Remainder(r) => {
-                if let Node::NodeBlock(block) = self.hir.get(r.block) {
-                    for stmt in &block.stmts[(r.first_statement_index as usize + 1)..] {
-                        finder.visit_stmt(stmt);
-                    }
-                    block.expr.as_ref().map(|e| finder.visit_expr(e));
-                } else {
-                    bug!()
-                }
-            }
-        }
-
-        finder.result
-    }
-}
-
 pub fn provide(providers: &mut Providers) {
     *providers = Providers {
         region_maps,
index 019f0a709116c7622167bad613d6dca6ac164a40..35ca8eb14228379563fed15283de2c720f9d6347 100644 (file)
@@ -532,7 +532,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         debug!("normalize_param_env_or_error: normalized predicates={:?}",
             predicates);
 
-        let region_maps = RegionMaps::new();
+        let region_maps = RegionMaps::default();
         let free_regions = FreeRegionMap::new();
         infcx.resolve_regions_and_report_errors(region_context, &region_maps, &free_regions);
         let predicates = match infcx.fully_resolve(&predicates) {
index ca735599a0da64c4f8641723541540772994a3b3..1851e1b8d34bbe595469f394cfe04c43104ddd9b 100644 (file)
@@ -23,7 +23,6 @@
 use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem};
 use middle::privacy::AccessLevels;
 use middle::resolve_lifetime::ObjectLifetimeDefault;
-use middle::region::CodeExtent;
 use mir::Mir;
 use mir::GeneratorLayout;
 use traits;
@@ -2309,10 +2308,6 @@ pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
         }
     }
 
-    pub fn node_scope_region(self, id: NodeId) -> Region<'tcx> {
-        self.mk_region(ty::ReScope(CodeExtent::Misc(id)))
-    }
-
     /// Looks up the span of `impl_did` if the impl is local; otherwise returns `Err`
     /// with the name of the crate containing the impl.
     pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> {
index a5642467474b3bbb5d68e52c9265c7774f6417cb..2f5f31e0f63bc8c8646ba3427c4e459948263216 100644 (file)
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use hir::BodyId;
 use hir::def_id::DefId;
 use hir::map::definitions::DefPathData;
 use middle::region::{CodeExtent, BlockRemainder};
@@ -527,16 +526,16 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             }
             ty::ReScope(code_extent) if identify_regions() => {
                 match code_extent {
-                    CodeExtent::Misc(node_id) =>
-                        write!(f, "'{}mce", node_id.as_u32()),
-                    CodeExtent::CallSiteScope(BodyId { node_id }) =>
-                        write!(f, "'{}cce", node_id.as_u32()),
-                    CodeExtent::ParameterScope(BodyId { node_id }) =>
-                        write!(f, "'{}pce", node_id.as_u32()),
-                    CodeExtent::DestructionScope(node_id) =>
-                        write!(f, "'{}dce", node_id.as_u32()),
+                    CodeExtent::Misc(id) =>
+                        write!(f, "'{}mce", id.as_usize()),
+                    CodeExtent::CallSiteScope(id) =>
+                        write!(f, "'{}cce", id.as_usize()),
+                    CodeExtent::ParameterScope(id) =>
+                        write!(f, "'{}pce", id.as_usize()),
+                    CodeExtent::DestructionScope(id) =>
+                        write!(f, "'{}dce", id.as_usize()),
                     CodeExtent::Remainder(BlockRemainder { block, first_statement_index }) =>
-                        write!(f, "'{}_{}rce", block, first_statement_index),
+                        write!(f, "'{}_{}rce", block.as_usize(), first_statement_index),
                 }
             }
             ty::ReVar(region_vid) if identify_regions() => {
index e83c79fb4a414daefa48a8d2acac28ab40f5fbe1..7f31c53e63caf70ccc772d7360e3731447415acc 100644 (file)
@@ -246,7 +246,7 @@ pub fn each_in_scope_loan<F>(&self, scope: region::CodeExtent, mut op: F) -> boo
         //! Like `each_issued_loan()`, but only considers loans that are
         //! currently in scope.
 
-        self.each_issued_loan(self.tcx().hir.node_to_hir_id(scope.node_id()).local_id, |loan| {
+        self.each_issued_loan(scope.item_local_id(), |loan| {
             if self.bccx.region_maps.is_subscope_of(scope, loan.kill_scope) {
                 op(loan)
             } else {
@@ -467,7 +467,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
             // 3. Where does old loan expire.
 
             let previous_end_span =
-                self.tcx().hir.span(old_loan.kill_scope.node_id()).end_point();
+                old_loan.kill_scope.span(self.tcx(), &self.bccx.region_maps).end_point();
 
             let mut err = match (new_loan.kind, old_loan.kind) {
                 (ty::MutBorrow, ty::MutBorrow) => {
@@ -713,12 +713,8 @@ pub fn analyze_restrictions_on_use(&self,
 
         let mut ret = UseOk;
 
-        let node_id = self.tcx().hir.hir_to_node_id(hir::HirId {
-            owner: self.tcx().closure_base_def_id(self.bccx.owner_def_id).index,
-            local_id: expr_id
-        });
         self.each_in_scope_loan_affecting_path(
-            region::CodeExtent::Misc(node_id), use_path, |loan| {
+            region::CodeExtent::Misc(expr_id), use_path, |loan| {
             if !compatible_borrow_kinds(loan.kind, borrow_kind) {
                 ret = UseWhileBorrowed(loan.loan_path.clone(), loan.span);
                 false
@@ -837,11 +833,7 @@ fn check_assignment(&self,
 
         // Check that we don't invalidate any outstanding loans
         if let Some(loan_path) = opt_loan_path(&assignee_cmt) {
-            let node_id = self.tcx().hir.hir_to_node_id(hir::HirId {
-                owner: self.tcx().closure_base_def_id(self.bccx.owner_def_id).index,
-                local_id: assignment_id
-            });
-            let scope = region::CodeExtent::Misc(node_id);
+            let scope = region::CodeExtent::Misc(assignment_id);
             self.each_in_scope_loan_affecting_path(scope, &loan_path, |loan| {
                 self.report_illegal_mutation(assignment_span, &loan_path, loan);
                 false
index 22de3c759139d8bf3aac6e9c32cb553e445574f9..461f1d6a43283930a7addae2b77a0bb1e737de27 100644 (file)
@@ -115,8 +115,9 @@ fn scope(&self, cmt: &mc::cmt<'tcx>) -> ty::Region<'tcx> {
                 self.bccx.tcx.mk_region(ty::ReScope(self.item_scope))
             }
             Categorization::Local(local_id) => {
+                let hir_id = self.bccx.tcx.hir.node_to_hir_id(local_id);
                 self.bccx.tcx.mk_region(ty::ReScope(
-                    self.bccx.region_maps.var_scope(local_id)))
+                    self.bccx.region_maps.var_scope(hir_id.local_id)))
             }
             Categorization::StaticItem |
             Categorization::Deref(_, mc::UnsafePtr(..)) => {
index e14edc43904eac7813b3c79dac14b8983eab433f..5689a30fd38c0c26b82ea614b3d780ecd0bb4bab 100644 (file)
@@ -43,7 +43,7 @@ pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
     let mut glcx = GatherLoanCtxt {
         bccx,
         all_loans: Vec::new(),
-        item_ub: region::CodeExtent::Misc(body.node_id),
+        item_ub: region::CodeExtent::Misc(bccx.tcx.hir.body(body).value.hir_id.local_id),
         move_data: MoveData::default(),
         move_error_collector: move_error::MoveErrorCollector::new(),
     };
@@ -126,7 +126,8 @@ fn borrow(&mut self,
                bk={:?}, loan_cause={:?})",
                borrow_id, cmt, loan_region,
                bk, loan_cause);
-        self.guarantee_valid(borrow_id,
+        let hir_id = self.bccx.tcx.hir.node_to_hir_id(borrow_id);
+        self.guarantee_valid(hir_id.local_id,
                              borrow_span,
                              cmt,
                              bk,
@@ -291,13 +292,13 @@ fn guarantee_assignment_valid(&mut self,
     /// reports an error.  This may entail taking out loans, which will be added to the
     /// `req_loan_map`.
     fn guarantee_valid(&mut self,
-                       borrow_id: ast::NodeId,
+                       borrow_id: hir::ItemLocalId,
                        borrow_span: Span,
                        cmt: mc::cmt<'tcx>,
                        req_kind: ty::BorrowKind,
                        loan_region: ty::Region<'tcx>,
                        cause: euv::LoanCause) {
-        debug!("guarantee_valid(borrow_id={}, cmt={:?}, \
+        debug!("guarantee_valid(borrow_id={:?}, cmt={:?}, \
                 req_mutbl={:?}, loan_region={:?})",
                borrow_id,
                cmt,
@@ -396,7 +397,7 @@ fn guarantee_valid(&mut self,
             }
         };
 
-        debug!("guarantee_valid(borrow_id={}), loan={:?}",
+        debug!("guarantee_valid(borrow_id={:?}), loan={:?}",
                borrow_id, loan);
 
         // let loan_path = loan.loan_path;
index e4384935e373320dc9b0b7c10cb2820949dc312e..25aac92c13d8572773e07dd7455c7a923dc1e838 100644 (file)
@@ -36,7 +36,6 @@
 use rustc::middle::free_region::RegionRelations;
 use rustc::ty::{self, TyCtxt};
 use rustc::ty::maps::Providers;
-use rustc::util::nodemap::FxHashMap;
 use rustc_mir::util::borrowck_errors::{BorrowckErrors, Origin};
 
 use std::fmt;
@@ -167,10 +166,9 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc
                              id_range,
                              all_loans.len());
     for (loan_idx, loan) in all_loans.iter().enumerate() {
-        loan_dfcx.add_gen(this.tcx.hir.node_to_hir_id(loan.gen_scope.node_id()).local_id,
-                          loan_idx);
+        loan_dfcx.add_gen(loan.gen_scope.item_local_id(), loan_idx);
         loan_dfcx.add_kill(KillFrom::ScopeEnd,
-                           this.tcx.hir.node_to_hir_id(loan.kill_scope.node_id()).local_id,
+                           loan.kill_scope.item_local_id(),
                            loan_idx);
     }
     loan_dfcx.add_kills_from_flow_exits(cfg);
@@ -366,10 +364,14 @@ fn closure_to_block(closure_id: DefIndex,
 impl<'a, 'tcx> LoanPath<'tcx> {
     pub fn kill_scope(&self, bccx: &BorrowckCtxt<'a, 'tcx>) -> region::CodeExtent {
         match self.kind {
-            LpVar(local_id) => bccx.region_maps.var_scope(local_id),
+            LpVar(local_id) => {
+                let hir_id = bccx.tcx.hir.node_to_hir_id(local_id);
+                bccx.region_maps.var_scope(hir_id.local_id)
+            }
             LpUpvar(upvar_id) => {
                 let block_id = closure_to_block(upvar_id.closure_expr_id, bccx.tcx);
-                region::CodeExtent::Misc(block_id)
+                let hir_id = bccx.tcx.hir.node_to_hir_id(block_id);
+                region::CodeExtent::Misc(hir_id.local_id)
             }
             LpDowncast(ref base, _) |
             LpExtend(ref base, ..) => base.kill_scope(bccx),
@@ -643,7 +645,7 @@ pub fn report_use_of_moved_value(&self,
         // Get type of value and span where it was previously
         // moved.
         let node_id = self.tcx.hir.hir_to_node_id(hir::HirId {
-            owner: self.tcx.closure_base_def_id(self.owner_def_id).index,
+            owner: self.body.value.hir_id.owner,
             local_id: the_move.id
         });
         let (move_span, move_note) = match the_move.kind {
@@ -818,7 +820,7 @@ fn report_bckerr(&self, err: &BckError<'tcx>) {
                 debug!("err_out_of_scope: self.body.is_generator = {:?}",
                        self.body.is_generator);
                 let maybe_borrow_across_yield = if self.body.is_generator {
-                    let body_extent = region::CodeExtent::Misc(self.body.id().node_id);
+                    let body_extent = region::CodeExtent::Misc(self.body.value.hir_id.local_id);
                     debug!("err_out_of_scope: body_extent = {:?}", body_extent);
                     debug!("err_out_of_scope: super_scope = {:?}", super_scope);
                     debug!("err_out_of_scope: sub_scope = {:?}", sub_scope);
@@ -844,7 +846,7 @@ fn report_bckerr(&self, err: &BckError<'tcx>) {
                                 // block remainder that starts with
                                 // `let a`) for a yield. We can cite
                                 // that for the user.
-                                self.tcx.yield_in_extent(value_extent, &mut FxHashMap())
+                                self.region_maps.yield_in_scope(value_extent)
                             } else {
                                 None
                             }
@@ -966,8 +968,14 @@ fn report_bckerr(&self, err: &BckError<'tcx>) {
                     }
                 }
 
-                if let Some(_) = statement_scope_span(self.tcx, super_scope) {
-                    db.note("consider using a `let` binding to increase its lifetime");
+                if let ty::ReScope(scope) = *super_scope {
+                    let node_id = scope.node_id(self.tcx, &self.region_maps);
+                    match self.tcx.hir.find(node_id) {
+                        Some(hir_map::NodeStmt(_)) => {
+                            db.note("consider using a `let` binding to increase its lifetime");
+                        }
+                        _ => {}
+                    }
                 }
 
                 db.emit();
@@ -1386,18 +1394,6 @@ pub fn cmt_to_path_or_string(&self, cmt: &mc::cmt<'tcx>) -> String {
     }
 }
 
-fn statement_scope_span(tcx: TyCtxt, region: ty::Region) -> Option<Span> {
-    match *region {
-        ty::ReScope(scope) => {
-            match tcx.hir.find(scope.node_id()) {
-                Some(hir_map::NodeStmt(stmt)) => Some(stmt.span),
-                _ => None
-            }
-        }
-        _ => None
-    }
-}
-
 impl BitwiseOperator for LoanDataFlowOperator {
     #[inline]
     fn join(&self, succ: usize, pred: usize) -> usize {
index 79a4a4f9f4d5b02d2a2bdf61effa47c460da33bb..7915eccbf74451cc447b6d779d949979b03250f2 100644 (file)
@@ -485,8 +485,7 @@ fn add_gen_kills(&self,
                 LpVar(..) | LpUpvar(..) | LpDowncast(..) => {
                     let kill_scope = path.loan_path.kill_scope(bccx);
                     let path = *self.path_map.borrow().get(&path.loan_path).unwrap();
-                    self.kill_moves(path,
-                                    bccx.tcx.hir.node_to_hir_id(kill_scope.node_id()).local_id,
+                    self.kill_moves(path, kill_scope.item_local_id(),
                                     KillFrom::ScopeEnd, dfcx_moves);
                 }
                 LpExtend(..) => {}
@@ -501,8 +500,7 @@ fn add_gen_kills(&self,
                 LpVar(..) | LpUpvar(..) | LpDowncast(..) => {
                     let kill_scope = lp.kill_scope(bccx);
                     dfcx_assign.add_kill(KillFrom::ScopeEnd,
-                                         bccx.tcx.hir.node_to_hir_id(kill_scope.node_id())
-                                            .local_id,
+                                         kill_scope.item_local_id(),
                                          assignment_index);
                 }
                 LpExtend(..) => {
index b187cdaa480ed17fff846ff205846c7827f78178..247f51b1da4437ee4a8c785a307428f97a17a687 100644 (file)
@@ -50,7 +50,7 @@ struct Env<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
 }
 
 struct RH<'a> {
-    id: ast::NodeId,
+    id: hir::ItemLocalId,
     sub: &'a [RH<'a>],
 }
 
@@ -157,7 +157,7 @@ fn test_env<F>(source_string: &str,
                              "test_crate",
                              |tcx| {
         tcx.infer_ctxt().enter(|infcx| {
-            let mut region_maps = RegionMaps::new();
+            let mut region_maps = RegionMaps::default();
             body(Env {
                 infcx: &infcx,
                 region_maps: &mut region_maps,
@@ -188,21 +188,19 @@ pub fn create_simple_region_hierarchy(&mut self) {
         // creates a region hierarchy where 1 is root, 10 and 11 are
         // children of 1, etc
 
-        let node = ast::NodeId::from_u32;
-        let dscope = CodeExtent::DestructionScope(node(1));
+        let dscope = CodeExtent::DestructionScope(hir::ItemLocalId(1));
         self.region_maps.record_code_extent(dscope, None);
         self.create_region_hierarchy(&RH {
-                                         id: node(1),
-                                         sub: &[RH {
-                                                    id: node(10),
-                                                    sub: &[],
-                                                },
-                                                RH {
-                                                    id: node(11),
-                                                    sub: &[],
-                                                }],
-                                     },
-                                     dscope);
+            id: hir::ItemLocalId(1),
+            sub: &[RH {
+                id: hir::ItemLocalId(10),
+                sub: &[],
+            },
+            RH {
+                id: hir::ItemLocalId(11),
+                sub: &[],
+            }],
+        }, dscope);
     }
 
     #[allow(dead_code)] // this seems like it could be useful, even if we don't use it now
@@ -335,7 +333,7 @@ pub fn t_rptr_late_bound_with_debruijn(&self,
     }
 
     pub fn t_rptr_scope(&self, id: u32) -> Ty<'tcx> {
-        let r = ty::ReScope(CodeExtent::Misc(ast::NodeId::from_u32(id)));
+        let r = ty::ReScope(CodeExtent::Misc(hir::ItemLocalId(id)));
         self.infcx.tcx.mk_imm_ref(self.infcx.tcx.mk_region(r), self.tcx().types.isize)
     }
 
index 0fe30dcabb00de89dca3b5ef48984b79b1c1f552..52b645638b86f37377a2829c9e2c729af1036500 100644 (file)
@@ -854,7 +854,7 @@ fn check_fn(&mut self,
             let local_id = cfg.graph.node_data(idx).id();
             if local_id != hir::DUMMY_ITEM_LOCAL_ID {
                 let node_id = cx.tcx.hir.hir_to_node_id(hir::HirId {
-                    owner: cx.tcx.closure_base_def_id(cfg.owner_def_id).index,
+                    owner: body.value.hir_id.owner,
                     local_id
                 });
                 let self_recursive = match method {
index fb345e944969af1c56b388baf09e098f5cbcd0d5..fc6eca466a811b43015bccc7886f15a062f42e3d 100644 (file)
@@ -202,7 +202,8 @@ pub fn storage_live_binding(&mut self, block: BasicBlock, var: NodeId, span: Spa
     pub fn schedule_drop_for_binding(&mut self, var: NodeId, span: Span) {
         let local_id = self.var_indices[&var];
         let var_ty = self.local_decls[local_id].ty;
-        let extent = self.hir.region_maps.var_scope(var);
+        let hir_id = self.hir.tcx().hir.node_to_hir_id(var);
+        let extent = self.hir.region_maps.var_scope(hir_id.local_id);
         self.schedule_drop(span, extent, &Lvalue::Local(local_id), var_ty);
     }
 
index 904e30a01eba68791894f69df05735a08a35e59a..5cced32f7e69bae9f2b94c33ababc0577cdba52b 100644 (file)
@@ -355,8 +355,8 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
         arguments.len(),
         return_ty);
 
-    let call_site_extent = CodeExtent::CallSiteScope(body.id());
-    let arg_extent = CodeExtent::ParameterScope(body.id());
+    let call_site_extent = CodeExtent::CallSiteScope(body.value.hir_id.local_id);
+    let arg_extent = CodeExtent::ParameterScope(body.value.hir_id.local_id);
     let mut block = START_BLOCK;
     let source_info = builder.source_info(span);
     unpack!(block = builder.in_scope((call_site_extent, source_info), block, |builder| {
index d38c72c37e80f97ab4927b07a20d9765d6014935..8a87751d846c8922446a65ff615f769a254e06d4 100644 (file)
@@ -13,7 +13,6 @@
 use hair::cx::to_ref::ToRef;
 use rustc::middle::region::{BlockRemainder, CodeExtent};
 use rustc::hir;
-use syntax::ast;
 
 impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
     type Output = Block<'tcx>;
@@ -21,11 +20,11 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
     fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Block<'tcx> {
         // We have to eagerly translate the "spine" of the statements
         // in order to get the lexical scoping correctly.
-        let stmts = mirror_stmts(cx, self.id, &*self.stmts);
-        let opt_destruction_extent = cx.region_maps.opt_destruction_extent(self.id);
+        let stmts = mirror_stmts(cx, self.hir_id.local_id, &*self.stmts);
+        let opt_destruction_extent = cx.region_maps.opt_destruction_extent(self.hir_id.local_id);
         Block {
             targeted_by_break: self.targeted_by_break,
-            extent: CodeExtent::Misc(self.id),
+            extent: CodeExtent::Misc(self.hir_id.local_id),
             opt_destruction_extent,
             span: self.span,
             stmts,
@@ -35,24 +34,25 @@ fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Block<'tcx> {
 }
 
 fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
-                                block_id: ast::NodeId,
+                                block_id: hir::ItemLocalId,
                                 stmts: &'tcx [hir::Stmt])
                                 -> Vec<StmtRef<'tcx>> {
     let mut result = vec![];
     for (index, stmt) in stmts.iter().enumerate() {
-        let opt_dxn_ext = cx.region_maps.opt_destruction_extent(stmt.node.id());
+        let hir_id = cx.tcx.hir.node_to_hir_id(stmt.node.id());
+        let opt_dxn_ext = cx.region_maps.opt_destruction_extent(hir_id.local_id);
         match stmt.node {
-            hir::StmtExpr(ref expr, id) |
-            hir::StmtSemi(ref expr, id) => {
+            hir::StmtExpr(ref expr, _) |
+            hir::StmtSemi(ref expr, _) => {
                 result.push(StmtRef::Mirror(Box::new(Stmt {
                     kind: StmtKind::Expr {
-                        scope: CodeExtent::Misc(id),
+                        scope: CodeExtent::Misc(hir_id.local_id),
                         expr: expr.to_ref(),
                     },
                     opt_destruction_extent: opt_dxn_ext,
                 })))
             }
-            hir::StmtDecl(ref decl, id) => {
+            hir::StmtDecl(ref decl, _) => {
                 match decl.node {
                     hir::DeclItem(..) => {
                         // ignore for purposes of the MIR
@@ -70,7 +70,7 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                         result.push(StmtRef::Mirror(Box::new(Stmt {
                             kind: StmtKind::Let {
                                 remainder_scope: remainder_extent,
-                                init_scope: CodeExtent::Misc(id),
+                                init_scope: CodeExtent::Misc(hir_id.local_id),
                                 pattern,
                                 initializer: local.init.to_ref(),
                             },
@@ -88,7 +88,7 @@ pub fn to_expr_ref<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                                    block: &'tcx hir::Block)
                                    -> ExprRef<'tcx> {
     let block_ty = cx.tables().node_id_to_type(block.hir_id);
-    let temp_lifetime = cx.region_maps.temporary_scope(block.id);
+    let temp_lifetime = cx.region_maps.temporary_scope(block.hir_id.local_id);
     let expr = Expr {
         ty: block_ty,
         temp_lifetime,
index 553da2c978fe728ba37bc80d3eb6acaa916f6aa9..a877c61a47a912b35531d310e24c8a054cee789a 100644 (file)
@@ -25,8 +25,8 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
     type Output = Expr<'tcx>;
 
     fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Expr<'tcx> {
-        let temp_lifetime = cx.region_maps.temporary_scope(self.id);
-        let expr_extent = CodeExtent::Misc(self.id);
+        let temp_lifetime = cx.region_maps.temporary_scope(self.hir_id.local_id);
+        let expr_extent = CodeExtent::Misc(self.hir_id.local_id);
 
         debug!("Expr::make_mirror(): id={}, span={:?}", self.id, self.span);
 
@@ -52,7 +52,7 @@ fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Expr<'tcx> {
         };
 
         // Finally, create a destruction scope, if any.
-        if let Some(extent) = cx.region_maps.opt_destruction_extent(self.id) {
+        if let Some(extent) = cx.region_maps.opt_destruction_extent(self.hir_id.local_id) {
             expr = Expr {
                 temp_lifetime,
                 ty: expr.ty,
@@ -125,7 +125,7 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
             // Convert this to a suitable `&foo` and
             // then an unsafe coercion. Limit the region to be just this
             // expression.
-            let region = ty::ReScope(CodeExtent::Misc(hir_expr.id));
+            let region = ty::ReScope(CodeExtent::Misc(hir_expr.hir_id.local_id));
             let region = cx.tcx.mk_region(region);
             expr = Expr {
                 temp_lifetime,
@@ -160,7 +160,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                                           expr: &'tcx hir::Expr)
                                           -> Expr<'tcx> {
     let expr_ty = cx.tables().expr_ty(expr);
-    let temp_lifetime = cx.region_maps.temporary_scope(expr.id);
+    let temp_lifetime = cx.region_maps.temporary_scope(expr.hir_id.local_id);
 
     let kind = match expr.node {
         // Here comes the interesting stuff:
@@ -487,7 +487,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
             match dest.target_id {
                 hir::ScopeTarget::Block(target_id) |
                 hir::ScopeTarget::Loop(hir::LoopIdResult::Ok(target_id)) => ExprKind::Break {
-                    label: CodeExtent::Misc(target_id),
+                    label: CodeExtent::Misc(cx.tcx.hir.node_to_hir_id(target_id).local_id),
                     value: value.to_ref(),
                 },
                 hir::ScopeTarget::Loop(hir::LoopIdResult::Err(err)) =>
@@ -498,7 +498,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
             match dest.target_id {
                 hir::ScopeTarget::Block(_) => bug!("cannot continue to blocks"),
                 hir::ScopeTarget::Loop(hir::LoopIdResult::Ok(loop_id)) => ExprKind::Continue {
-                    label: CodeExtent::Misc(loop_id),
+                    label: CodeExtent::Misc(cx.tcx.hir.node_to_hir_id(loop_id).local_id),
                 },
                 hir::ScopeTarget::Loop(hir::LoopIdResult::Err(err)) =>
                     bug!("invalid loop id for continue: {}", err)
@@ -585,7 +585,7 @@ fn method_callee<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                                  expr: &hir::Expr,
                                  custom_callee: Option<(DefId, &'tcx Substs<'tcx>)>)
                                  -> Expr<'tcx> {
-    let temp_lifetime = cx.region_maps.temporary_scope(expr.id);
+    let temp_lifetime = cx.region_maps.temporary_scope(expr.hir_id.local_id);
     let (def_id, substs) = custom_callee.unwrap_or_else(|| {
         (cx.tables().type_dependent_defs()[expr.hir_id].def_id(),
          cx.tables().node_substs(expr.hir_id))
@@ -676,7 +676,7 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                                expr: &'tcx hir::Expr,
                                def: Def)
                                -> ExprKind<'tcx> {
-    let temp_lifetime = cx.region_maps.temporary_scope(expr.id);
+    let temp_lifetime = cx.region_maps.temporary_scope(expr.hir_id.local_id);
 
     match def {
         Def::Local(def_id) => {
@@ -867,7 +867,7 @@ fn overloaded_lvalue<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
 
     // construct the complete expression `foo()` for the overloaded call,
     // which will yield the &T type
-    let temp_lifetime = cx.region_maps.temporary_scope(expr.id);
+    let temp_lifetime = cx.region_maps.temporary_scope(expr.hir_id.local_id);
     let fun = method_callee(cx, expr, custom_callee);
     let ref_expr = Expr {
         temp_lifetime,
@@ -896,7 +896,7 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         closure_expr_id: cx.tcx.hir.local_def_id(closure_expr.id).index,
     };
     let upvar_capture = cx.tables().upvar_capture(upvar_id);
-    let temp_lifetime = cx.region_maps.temporary_scope(closure_expr.id);
+    let temp_lifetime = cx.region_maps.temporary_scope(closure_expr.hir_id.local_id);
     let var_ty = cx.tables()
                    .node_id_to_type(cx.tcx.hir.node_to_hir_id(var_node_id));
     let captured_var = Expr {
index bf134f9547d3817893097baf4148f04abcabd9bc..a4bbedfb26b3874036b07693b7b3cf33ab6f57bc 100644 (file)
@@ -340,7 +340,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             // region obligations that get overlooked.  The right
             // thing to do is the code below. But we keep this old
             // pass around temporarily.
-            let region_maps = RegionMaps::new();
+            let region_maps = RegionMaps::default();
             let mut free_regions = FreeRegionMap::new();
             free_regions.relate_free_regions_from_predicates(&param_env.caller_bounds);
             infcx.resolve_regions_and_report_errors(impl_m.def_id, &region_maps, &free_regions);
index 72ff9eb6f5b0d48ee3bdbc2abda3a9ad7057702f..fd7dd052cd16d524cf99daf90fdef0bbe29e3dbb 100644 (file)
@@ -114,7 +114,7 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>(
             return Err(ErrorReported);
         }
 
-        let region_maps = RegionMaps::new();
+        let region_maps = RegionMaps::default();
         let free_regions = FreeRegionMap::new();
         infcx.resolve_regions_and_report_errors(drop_impl_did, &region_maps, &free_regions);
         Ok(())
index 46948b687d26dd09eba98862d45023b4b1b528bc..60762134f0ffd884920c38c397bf9b2a57e6e46b 100644 (file)
 use rustc::hir::{self, Body, Pat, PatKind, Expr};
 use rustc::middle::region::{RegionMaps, CodeExtent};
 use rustc::ty::Ty;
-use syntax::ast::NodeId;
-use syntax::codemap::Span;
 use std::rc::Rc;
 use super::FnCtxt;
 use util::nodemap::FxHashMap;
 
 struct InteriorVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
     fcx: &'a FnCtxt<'a, 'gcx, 'tcx>,
-    cache: FxHashMap<NodeId, Option<Span>>,
     types: FxHashMap<Ty<'tcx>, usize>,
     region_maps: Rc<RegionMaps>,
 }
@@ -36,7 +33,7 @@ fn record(&mut self, ty: Ty<'tcx>, scope: Option<CodeExtent>, expr: Option<&'tcx
         use syntax_pos::DUMMY_SP;
 
         let live_across_yield = scope.map_or(Some(DUMMY_SP), |s| {
-            self.fcx.tcx.yield_in_extent(s, &mut self.cache)
+            self.region_maps.yield_in_scope(s)
         });
 
         if let Some(span) = live_across_yield {
@@ -62,7 +59,6 @@ pub fn resolve_interior<'a, 'gcx, 'tcx>(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>,
     let mut visitor = InteriorVisitor {
         fcx,
         types: FxHashMap(),
-        cache: FxHashMap(),
         region_maps: fcx.tcx.region_maps(def_id),
     };
     intravisit::walk_body(&mut visitor, body);
@@ -97,7 +93,7 @@ fn visit_body(&mut self, _body: &'tcx Body) {
 
     fn visit_pat(&mut self, pat: &'tcx Pat) {
         if let PatKind::Binding(..) = pat.node {
-            let scope = self.region_maps.var_scope(pat.id);
+            let scope = self.region_maps.var_scope(pat.hir_id.local_id);
             let ty = self.fcx.tables.borrow().pat_ty(pat);
             self.record(ty, Some(scope), None);
         }
@@ -106,7 +102,7 @@ fn visit_pat(&mut self, pat: &'tcx Pat) {
     }
 
     fn visit_expr(&mut self, expr: &'tcx Expr) {
-        let scope = self.region_maps.temporary_scope(expr.id);
+        let scope = self.region_maps.temporary_scope(expr.hir_id.local_id);
         let ty = self.fcx.tables.borrow().expr_ty_adjusted(expr);
         self.record(ty, scope, Some(expr));
 
index bd362c3535373d622c0ae2a13a3b857b435e06e3..2fa80a10d12e48929b44a7007cee197c7d713816 100644 (file)
@@ -606,8 +606,9 @@ fn new(infcx: InferCtxt<'a, 'gcx, 'tcx>, def_id: DefId) -> Self {
         let tcx = infcx.tcx;
         let item_id = tcx.hir.as_local_node_id(def_id);
         let body_id = item_id.and_then(|id| tcx.hir.maybe_body_owned_by(id));
-        let implicit_region_bound = body_id.map(|body| {
-            tcx.mk_region(ty::ReScope(CodeExtent::CallSiteScope(body)))
+        let implicit_region_bound = body_id.map(|body_id| {
+            let body = tcx.hir.body(body_id);
+            tcx.mk_region(ty::ReScope(CodeExtent::CallSiteScope(body.value.hir_id.local_id)))
         });
 
         Inherited {
index 377908b1ab9d40e2f2059f74f9f09de29b58ff51..0cd38a49adef206772a6fc4851ad8772f4a30bc5 100644 (file)
@@ -305,7 +305,7 @@ fn visit_fn_body(&mut self,
 
         let body_id = body.id();
 
-        let call_site = CodeExtent::CallSiteScope(body_id);
+        let call_site = CodeExtent::CallSiteScope(body.value.hir_id.local_id);
         let old_call_site_scope = self.set_call_site_scope(Some(call_site));
 
         let fn_sig = {
@@ -330,7 +330,7 @@ fn visit_fn_body(&mut self,
 
         let old_body_id = self.set_body_id(body_id.node_id);
         self.relate_free_regions(&fn_sig_tys[..], body_id.node_id, span);
-        self.link_fn_args(CodeExtent::Misc(body_id.node_id), &body.arguments);
+        self.link_fn_args(CodeExtent::Misc(body.value.hir_id.local_id), &body.arguments);
         self.visit_body(body);
         self.visit_region_obligations(body_id.node_id);
 
@@ -610,11 +610,11 @@ fn constrain_bindings_in_pat(&mut self, pat: &hir::Pat) {
             // that the lifetime of any regions that appear in a
             // variable's type enclose at least the variable's scope.
 
-            let var_scope = self.region_maps.var_scope(id);
+            let hir_id = self.tcx.hir.node_to_hir_id(id);
+            let var_scope = self.region_maps.var_scope(hir_id.local_id);
             let var_region = self.tcx.mk_region(ty::ReScope(var_scope));
 
             let origin = infer::BindingTypeIsNotValidAtDecl(span);
-            let hir_id = self.tcx.hir.node_to_hir_id(id);
             self.type_of_node_must_outlive(origin, hir_id, var_region);
 
             let typ = self.resolve_node_type(hir_id);
@@ -668,7 +668,7 @@ fn visit_expr(&mut self, expr: &'gcx hir::Expr) {
         // scope of that expression. This also guarantees basic WF.
         let expr_ty = self.resolve_node_type(expr.hir_id);
         // the region corresponding to this expression
-        let expr_region = self.tcx.node_scope_region(expr.id);
+        let expr_region = self.tcx.mk_region(ty::ReScope(CodeExtent::Misc(expr.hir_id.local_id)));
         self.type_must_outlive(infer::ExprTypeIsNotInScope(expr_ty, expr.span),
                                expr_ty, expr_region);
 
@@ -950,7 +950,7 @@ fn constrain_call<'b, I: Iterator<Item=&'b hir::Expr>>(&mut self,
         // call occurs.
         //
         // FIXME(#6268) to support nested method calls, should be callee_id
-        let callee_scope = CodeExtent::Misc(call_expr.id);
+        let callee_scope = CodeExtent::Misc(call_expr.hir_id.local_id);
         let callee_region = self.tcx.mk_region(ty::ReScope(callee_scope));
 
         debug!("callee_region={:?}", callee_region);
@@ -1002,7 +1002,7 @@ fn constrain_adjustments(&mut self, expr: &hir::Expr) -> mc::McResult<mc::cmt<'t
         // expression.
         self.check_safety_of_rvalue_destructor_if_necessary(cmt.clone(), expr.span);
 
-        let expr_region = self.tcx.node_scope_region(expr.id);
+        let expr_region = self.tcx.mk_region(ty::ReScope(CodeExtent::Misc(expr.hir_id.local_id)));
         for adjustment in adjustments {
             debug!("constrain_adjustments: adjustment={:?}, cmt={:?}",
                    adjustment, cmt);
@@ -1095,7 +1095,7 @@ fn constrain_index(&mut self,
         debug!("constrain_index(index_expr=?, indexed_ty={}",
                self.ty_to_string(indexed_ty));
 
-        let r_index_expr = ty::ReScope(CodeExtent::Misc(index_expr.id));
+        let r_index_expr = ty::ReScope(CodeExtent::Misc(index_expr.hir_id.local_id));
         if let ty::TyRef(r_ptr, mt) = indexed_ty.sty {
             match mt.ty.sty {
                 ty::TySlice(_) | ty::TyStr => {
@@ -1232,7 +1232,7 @@ fn link_autoref(&self,
             }
 
             adjustment::AutoBorrow::RawPtr(m) => {
-                let r = self.tcx.node_scope_region(expr.id);
+                let r = self.tcx.mk_region(ty::ReScope(CodeExtent::Misc(expr.hir_id.local_id)));
                 self.link_region(expr.span, r, ty::BorrowKind::from_mutbl(m), expr_cmt);
             }
         }
index 9305eff1436520e7b3ee0bebf1c2e21c4e105198..9cf15e2145d36ff811b202b43b817b98cf17c0ab 100644 (file)
@@ -390,7 +390,7 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         }
 
         // Finally, resolve all regions.
-        let region_maps = RegionMaps::new();
+        let region_maps = RegionMaps::default();
         let mut free_regions = FreeRegionMap::new();
         free_regions.relate_free_regions_from_predicates(&param_env.caller_bounds);
         infcx.resolve_regions_and_report_errors(impl_did, &region_maps, &free_regions);
index 55dac4440275fbe0a277d6772d55d546a54efbc9..7be677c184b735a9478bbc7e9b6d86ed55afb18a 100644 (file)
@@ -22,16 +22,16 @@ fn main() {
 // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
 //     let mut _0: ();
 //     let _1: i32;
-//     let _2: &'6_1rce i32;
+//     let _2: &'10_1rce i32;
 //
 //     bb0: {
 //         StorageLive(_1);
 //         _1 = const 3i32;
 //         StorageLive(_2);
-//         _2 = &'6_1rce _1;
+//         _2 = &'10_1rce _1;
 //         _0 = ();
 //         StorageDead(_2);
-//         EndRegion('6_1rce);
+//         EndRegion('10_1rce);
 //         StorageDead(_1);
 //         return;
 //     }
index a1386ec47a13bd91231ef0601c944a40ef9c4c69..2cb9b38e7bb94928390385e5b2d9c2abb88393e8 100644 (file)
@@ -27,8 +27,8 @@ fn main() {
 // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
 //     let mut _0: ();
 //     let _2: bool;
-//     let _3: &'7_1rce bool;
-//     let _7: &'7_3rce bool;
+//     let _3: &'23_1rce bool;
+//     let _7: &'23_3rce bool;
 //     let mut _4: ();
 //     let mut _5: bool;
 //     bb0: {
@@ -38,7 +38,7 @@ fn main() {
 //         StorageLive(_2);
 //         _2 = const true;
 //         StorageLive(_3);
-//         _3 = &'7_1rce _2;
+//         _3 = &'23_1rce _2;
 //         StorageLive(_5);
 //         _5 = _2;
 //         switchInt(_5) -> [0u8: bb3, otherwise: bb2];
@@ -47,19 +47,19 @@ fn main() {
 //         _0 = ();
 //         StorageDead(_5);
 //         StorageDead(_3);
-//         EndRegion('7_1rce);
+//         EndRegion('23_1rce);
 //         StorageDead(_2);
 //         return;
 //     }
 //     bb3: {
 //         StorageDead(_5);
 //         StorageLive(_7);
-//         _7 = &'7_3rce _2;
+//         _7 = &'23_3rce _2;
 //         _1 = ();
 //         StorageDead(_7);
-//         EndRegion('7_3rce);
+//         EndRegion('23_3rce);
 //         StorageDead(_3);
-//         EndRegion('7_1rce);
+//         EndRegion('23_1rce);
 //         StorageDead(_2);
 //         goto -> bb1;
 //     }
index b3d2809e76cebfc6ca97e9effaa222e8bcd293ba..001bb9c1a02849749695657b121e35df195e4557 100644 (file)
@@ -28,8 +28,8 @@ fn main() {
 // START rustc.node4.SimplifyCfg-qualify-consts.after.mir
 //     let mut _0: ();
 //     let mut _1: bool;
-//     let _3: &'9_1rce bool;
-//     let _7: &'9_3rce bool;
+//     let _3: &'26_1rce bool;
+//     let _7: &'26_3rce bool;
 //     let mut _2: ();
 //     let mut _4: ();
 //     let mut _5: bool;
@@ -41,7 +41,7 @@ fn main() {
 //     bb1: {
 //         _1 = const true;
 //         StorageLive(_3);
-//         _3 = &'9_1rce _1;
+//         _3 = &'26_1rce _1;
 //         StorageLive(_5);
 //         _5 = _1;
 //         switchInt(_5) -> [0u8: bb3, otherwise: bb2];
@@ -50,7 +50,7 @@ fn main() {
 //         _0 = ();
 //         StorageDead(_5);
 //         StorageDead(_3);
-//         EndRegion('9_1rce);
+//         EndRegion('26_1rce);
 //         StorageDead(_1);
 //         return;
 //     }
@@ -58,12 +58,12 @@ fn main() {
 //         _4 = ();
 //         StorageDead(_5);
 //         StorageLive(_7);
-//         _7 = &'9_3rce _1;
+//         _7 = &'26_3rce _1;
 //         _2 = ();
 //         StorageDead(_7);
-//         EndRegion('9_3rce);
+//         EndRegion('26_3rce);
 //         StorageDead(_3);
-//         EndRegion('9_1rce);
+//         EndRegion('26_1rce);
 //         goto -> bb1;
 //     }
 // END rustc.node4.SimplifyCfg-qualify-consts.after.mir
index 0b34231b4eec6b0fc84ce5752619e1466f1a3427..8c854ce87a2c6b100b2e398f73190633b420aa72 100644 (file)
@@ -33,8 +33,8 @@ fn foo(i: i32) {
 //     let mut _0: ();
 //     let _1: D;
 //     let _2: i32;
-//     let _3: &'6_2rce i32;
-//     let _6: &'6_4rce i32;
+//     let _3: &'26_2rce i32;
+//     let _6: &'26_4rce i32;
 //     let mut _4: ();
 //     let mut _5: i32;
 //     bb0: {
@@ -43,7 +43,7 @@ fn foo(i: i32) {
 //         StorageLive(_2);
 //         _2 = const 0i32;
 //         StorageLive(_3);
-//         _3 = &'6_2rce _2;
+//         _3 = &'26_2rce _2;
 //         StorageLive(_5);
 //         _5 = (*_3);
 //         _4 = const foo(_5) -> [return: bb1, unwind: bb3];
@@ -51,12 +51,12 @@ fn foo(i: i32) {
 //     bb1: {
 //         StorageDead(_5);
 //         StorageLive(_6);
-//         _6 = &'6_4rce _2;
+//         _6 = &'26_4rce _2;
 //         _0 = ();
 //         StorageDead(_6);
-//         EndRegion('6_4rce);
+//         EndRegion('26_4rce);
 //         StorageDead(_3);
-//         EndRegion('6_2rce);
+//         EndRegion('26_2rce);
 //         StorageDead(_2);
 //         drop(_1) -> bb4;
 //     }
@@ -64,7 +64,7 @@ fn foo(i: i32) {
 //         resume;
 //     }
 //     bb3: {
-//         EndRegion('6_2rce);
+//         EndRegion('26_2rce);
 //         drop(_1) -> bb2;
 //     }
 //     bb4: {
index e51bb9350db60520aa52886a4f811606c84ffec5..ae1b4e2e83abb9ed22d052a6f4b73e1f2edb9859 100644 (file)
@@ -31,21 +31,21 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
 //     let mut _0: ();
 //     let _1: D;
 //     let mut _2: ();
-//     let mut _3: [closure@NodeId(18) d:&'19mce D];
-//     let mut _4: &'19mce D;
+//     let mut _3: [closure@NodeId(18) d:&'14mce D];
+//     let mut _4: &'14mce D;
 //     bb0: {
 //         StorageLive(_1);
 //         _1 = D::{{constructor}}(const 0i32,);
 //         StorageLive(_3);
 //         StorageLive(_4);
-//         _4 = &'19mce _1;
+//         _4 = &'14mce _1;
 //         _3 = [closure@NodeId(18)] { d: _4 };
 //         StorageDead(_4);
 //         _2 = const foo(_3) -> [return: bb1, unwind: bb3];
 //     }
 //     bb1: {
 //         StorageDead(_3);
-//         EndRegion('19mce);
+//         EndRegion('14mce);
 //         _0 = ();
 //         drop(_1) -> bb4;
 //     }
@@ -53,7 +53,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
 //         resume;
 //     }
 //     bb3: {
-//         EndRegion('19mce);
+//         EndRegion('14mce);
 //         drop(_1) -> bb2;
 //     }
 //     bb4: {
@@ -64,13 +64,13 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
 // END rustc.node4.SimplifyCfg-qualify-consts.after.mir
 
 // START rustc.node18.SimplifyCfg-qualify-consts.after.mir
-// fn main::{{closure}}(_1: [closure@NodeId(18) d:&'19mce D]) -> i32 {
+// fn main::{{closure}}(_1: [closure@NodeId(18) d:&'14mce D]) -> i32 {
 //    let mut _0: i32;
 //    let mut _2: i32;
 //
 //    bb0: {
 //        StorageLive(_2);
-//        _2 = ((*(_1.0: &'19mce D)).0: i32);
+//        _2 = ((*(_1.0: &'14mce D)).0: i32);
 //        _0 = _2;
 //        StorageDead(_2);
 //        return;
index c55e6d105cbdc3fe9c8d4c5ba83ca1568f172731..8054b64400669c05f5cebf9d4a920ec6a612b1b9 100644 (file)
@@ -31,21 +31,21 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
 //     let mut _0: ();
 //     let _1: D;
 //     let mut _2: ();
-//     let mut _3: [closure@NodeId(22) d:&'23mce D];
-//     let mut _4: &'23mce D;
+//     let mut _3: [closure@NodeId(22) d:&'19mce D];
+//     let mut _4: &'19mce D;
 //     bb0: {
 //         StorageLive(_1);
 //         _1 = D::{{constructor}}(const 0i32,);
 //         StorageLive(_3);
 //         StorageLive(_4);
-//         _4 = &'23mce _1;
+//         _4 = &'19mce _1;
 //         _3 = [closure@NodeId(22)] { d: _4 };
 //         StorageDead(_4);
 //         _2 = const foo(_3) -> [return: bb1, unwind: bb3];
 //     }
 //     bb1: {
 //         StorageDead(_3);
-//         EndRegion('23mce);
+//         EndRegion('19mce);
 //         _0 = ();
 //         drop(_1) -> bb4;
 //     }
@@ -53,7 +53,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
 //         resume;
 //     }
 //     bb3: {
-//         EndRegion('23mce);
+//         EndRegion('19mce);
 //         drop(_1) -> bb2;
 //     }
 //     bb4: {
@@ -63,20 +63,20 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
 // END rustc.node4.SimplifyCfg-qualify-consts.after.mir
 
 // START rustc.node22.SimplifyCfg-qualify-consts.after.mir
-// fn main::{{closure}}(_1: [closure@NodeId(22) d:&'23mce D]) -> i32 {
+// fn main::{{closure}}(_1: [closure@NodeId(22) d:&'19mce D]) -> i32 {
 //     let mut _0: i32;
-//     let _2: &'14_0rce D;
+//     let _2: &'15_0rce D;
 //     let mut _3: i32;
 //
 //     bb0: {
 //         StorageLive(_2);
-//         _2 = &'14_0rce (*(_1.0: &'23mce D));
+//         _2 = &'15_0rce (*(_1.0: &'19mce D));
 //         StorageLive(_3);
 //         _3 = ((*_2).0: i32);
 //         _0 = _3;
 //         StorageDead(_3);
 //         StorageDead(_2);
-//         EndRegion('14_0rce);
+//         EndRegion('15_0rce);
 //         return;
 //     }
 // END rustc.node22.SimplifyCfg-qualify-consts.after.mir
index 9c8e3ec08d498956b271f04d2e54ef62e85f3011..d68439087615b93d80361aea7f3e32bce5d9b10b 100644 (file)
@@ -74,18 +74,18 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
 // START rustc.node22.SimplifyCfg-qualify-consts.after.mir
 // fn main::{{closure}}(_1: [closure@NodeId(22) d:D]) -> i32 {
 //     let mut _0: i32;
-//     let _2: &'14_0rce D;
+//     let _2: &'15_0rce D;
 //     let mut _3: i32;
 //
 //     bb0: {
 //         StorageLive(_2);
-//         _2 = &'14_0rce (_1.0: D);
+//         _2 = &'15_0rce (_1.0: D);
 //         StorageLive(_3);
 //         _3 = ((*_2).0: i32);
 //         _0 = _3;
 //         StorageDead(_3);
 //         StorageDead(_2);
-//         EndRegion('14_0rce);
+//         EndRegion('15_0rce);
 //         drop(_1) -> bb1;
 //     }
 //     bb1: {
index b4dbec5cd2dd7ec5e159feb418640a8459f54303..8d7050941e7ebfe060b9bc8ebce967d544aae4ac 100644 (file)
@@ -31,15 +31,15 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
 // fn main() -> () {
 //    let mut _0: ();
 //    let _1: D;
-//    let _2: &'6_1rce D;
+//    let _2: &'21_1rce D;
 //    let mut _3: ();
-//    let mut _4: [closure@NodeId(22) r:&'6_1rce D];
-//    let mut _5: &'6_1rce D;
+//    let mut _4: [closure@NodeId(22) r:&'21_1rce D];
+//    let mut _5: &'21_1rce D;
 //    bb0: {
 //        StorageLive(_1);
 //        _1 = D::{{constructor}}(const 0i32,);
 //        StorageLive(_2);
-//        _2 = &'6_1rce _1;
+//        _2 = &'21_1rce _1;
 //        StorageLive(_4);
 //        StorageLive(_5);
 //        _5 = _2;
@@ -51,14 +51,14 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
 //        StorageDead(_4);
 //        _0 = ();
 //        StorageDead(_2);
-//        EndRegion('6_1rce);
+//        EndRegion('21_1rce);
 //        drop(_1) -> bb4;
 //    }
 //    bb2: {
 //        resume;
 //    }
 //    bb3: {
-//        EndRegion('6_1rce);
+//        EndRegion('21_1rce);
 //        drop(_1) -> bb2;
 //    }
 //    bb4: {
@@ -69,13 +69,13 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
 // END rustc.node4.SimplifyCfg-qualify-consts.after.mir
 
 // START rustc.node22.SimplifyCfg-qualify-consts.after.mir
-// fn main::{{closure}}(_1: [closure@NodeId(22) r:&'6_1rce D]) -> i32 {
+// fn main::{{closure}}(_1: [closure@NodeId(22) r:&'21_1rce D]) -> i32 {
 //     let mut _0: i32;
 //     let mut _2: i32;
 //
 //     bb0: {
 //         StorageLive(_2);
-//         _2 = ((*(_1.0: &'6_1rce D)).0: i32);
+//         _2 = ((*(_1.0: &'21_1rce D)).0: i32);
 //         _0 = _2;
 //         StorageDead(_2);
 //         return;
index 677c92ea71b7a78a64241da9c9fe7cd7afe13c39..9c528da8b348dda7bc3481a2f9dbada0a6a1e120 100644 (file)
@@ -37,19 +37,19 @@ fn main() {
 // START rustc.node23.EraseRegions.after.mir
 // fn main() -> () {
 //     bb0: {
-//         Validate(Suspend(ReScope(Misc(NodeId(34)))), [_1: i32]);
+//         Validate(Suspend(ReScope(Misc(ItemLocalId(10)))), [_1: i32]);
 //         _6 = &ReErased mut _1;
-//         Validate(Acquire, [(*_6): i32/ReScope(Misc(NodeId(34)))]);
-//         Validate(Suspend(ReScope(Misc(NodeId(34)))), [(*_6): i32/ReScope(Misc(NodeId(34)))]);
+//         Validate(Acquire, [(*_6): i32/ReScope(Misc(ItemLocalId(10)))]);
+//         Validate(Suspend(ReScope(Misc(ItemLocalId(10)))), [(*_6): i32/ReScope(Misc(ItemLocalId(10)))]);
 //         _5 = &ReErased mut (*_6);
-//         Validate(Acquire, [(*_5): i32/ReScope(Misc(NodeId(34)))]);
-//         Validate(Release, [_2: (), _3: &ReScope(Misc(NodeId(34))) Test, _5: &ReScope(Misc(NodeId(34))) mut i32]);
+//         Validate(Acquire, [(*_5): i32/ReScope(Misc(ItemLocalId(10)))]);
+//         Validate(Release, [_2: (), _3: &ReScope(Misc(ItemLocalId(10))) Test, _5: &ReScope(Misc(ItemLocalId(10))) mut i32]);
 //         _2 = const Test::foo(_3, _5) -> bb1;
 //     }
 //
 //     bb1: {
 //         Validate(Acquire, [_2: ()]);
-//         EndRegion(ReScope(Misc(NodeId(34))));
+//         EndRegion(ReScope(Misc(ItemLocalId(10))));
 //         return;
 //     }
 // }
@@ -61,15 +61,15 @@ fn main() {
 //         StorageLive(_3);
 //         _3 = _2;
 //         StorageLive(_4);
-//         Validate(Suspend(ReScope(Remainder(BlockRemainder { block: NodeId(41), first_statement_index: 0 }))), [(*_3): i32]);
+//         Validate(Suspend(ReScope(Remainder(BlockRemainder { block: ItemLocalId(22), first_statement_index: 0 }))), [(*_3): i32]);
 //         _4 = &ReErased (*_3);
-//         Validate(Acquire, [(*_4): i32/ReScope(Remainder(BlockRemainder { block: NodeId(41), first_statement_index: 0 })) (imm)]);
+//         Validate(Acquire, [(*_4): i32/ReScope(Remainder(BlockRemainder { block: ItemLocalId(22), first_statement_index: 0 })) (imm)]);
 //         StorageLive(_5);
 //         _5 = (*_4);
 //         _0 = _5;
 //         StorageDead(_5);
 //         StorageDead(_4);
-//         EndRegion(ReScope(Remainder(BlockRemainder { block: NodeId(41), first_statement_index: 0 })));
+//         EndRegion(ReScope(Remainder(BlockRemainder { block: ItemLocalId(22), first_statement_index: 0 })));
 //         StorageDead(_3);
 //         return;
 //     }
index 9140cf5768f5918db6a91f2f7ba1f2edc2defa62..cd556564b7913d39bfaf8fc6e073f46044b279e3 100644 (file)
@@ -32,18 +32,18 @@ fn _unused2(x: *const i32) -> i32 { unsafe { *x }}
 // fn main() -> () {
 //     let mut _5: &ReErased i32;
 //     bb0: {
-//         Validate(Suspend(ReScope(Misc(NodeId(46)))), [((*_2).0: i32): i32/ReScope(Remainder(BlockRemainder { block: NodeId(18), first_statement_index: 3 })) (imm)]);
+//         Validate(Suspend(ReScope(Misc(ItemLocalId(17)))), [((*_2).0: i32): i32/ReScope(Remainder(BlockRemainder { block: ItemLocalId(19), first_statement_index: 3 })) (imm)]);
 //         _5 = &ReErased ((*_2).0: i32);
-//         Validate(Acquire, [(*_5): i32/ReScope(Misc(NodeId(46))) (imm)]);
-//         Validate(Suspend(ReScope(Misc(NodeId(46)))), [(*_5): i32/ReScope(Misc(NodeId(46))) (imm)]);
+//         Validate(Acquire, [(*_5): i32/ReScope(Misc(ItemLocalId(17))) (imm)]);
+//         Validate(Suspend(ReScope(Misc(ItemLocalId(17)))), [(*_5): i32/ReScope(Misc(ItemLocalId(17))) (imm)]);
 //         _4 = &ReErased (*_5);
-//         Validate(Acquire, [(*_4): i32/ReScope(Misc(NodeId(46))) (imm)]);
-//         Validate(Release, [_3: (), _4: &ReScope(Misc(NodeId(46))) i32]);
+//         Validate(Acquire, [(*_4): i32/ReScope(Misc(ItemLocalId(17))) (imm)]);
+//         Validate(Release, [_3: (), _4: &ReScope(Misc(ItemLocalId(17))) i32]);
 //         _3 = const foo(_4) -> bb1;
 //     }
 //     bb1: {
-//         EndRegion(ReScope(Misc(NodeId(46))));
-//         EndRegion(ReScope(Remainder(BlockRemainder { block: NodeId(18), first_statement_index: 3 })));
+//         EndRegion(ReScope(Misc(ItemLocalId(17))));
+//         EndRegion(ReScope(Remainder(BlockRemainder { block: ItemLocalId(19), first_statement_index: 3 })));
 //         return;
 //     }
 // }
index 0182e6e2964452c5627f49503ace6d7b5eff7498..224f4ce2effe3294cd47269c84c8a74c1311ed95 100644 (file)
@@ -50,12 +50,12 @@ fn main() {
 //         _3 = _2;
 //         StorageLive(_4);
 //         StorageLive(_5);
-//         Validate(Suspend(ReScope(Misc(NodeId(44)))), [(*_3): i32]);
+//         Validate(Suspend(ReScope(Misc(ItemLocalId(9)))), [(*_3): i32]);
 //         _5 = &ReErased mut (*_3);
-//         Validate(Acquire, [(*_5): i32/ReScope(Misc(NodeId(44)))]);
+//         Validate(Acquire, [(*_5): i32/ReScope(Misc(ItemLocalId(9)))]);
 //         _4 = _5 as *mut i32 (Misc);
 //         StorageDead(_5);
-//         EndRegion(ReScope(Misc(NodeId(44))));
+//         EndRegion(ReScope(Misc(ItemLocalId(9))));
 //         Validate(Release, [_0: bool, _4: *mut i32]);
 //         _0 = const write_42(_4) -> bb1;
 //     }