]> git.lizzy.rs Git - rust.git/commitdiff
hir: remove NodeId from Expr
authorljedrz <ljedrz@gmail.com>
Sun, 24 Feb 2019 08:33:17 +0000 (09:33 +0100)
committerljedrz <ljedrz@gmail.com>
Sun, 24 Feb 2019 16:09:37 +0000 (17:09 +0100)
44 files changed:
src/librustc/cfg/construct.rs
src/librustc/hir/lowering.rs
src/librustc/hir/map/blocks.rs
src/librustc/hir/map/mod.rs
src/librustc/hir/mod.rs
src/librustc/ich/impls_hir.rs
src/librustc/lint/mod.rs
src/librustc/middle/dead.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/liveness.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/stability.rs
src/librustc/traits/mod.rs
src/librustc/ty/mod.rs
src/librustc_borrowck/borrowck/check_loans.rs
src/librustc_borrowck/borrowck/gather_loans/mod.rs
src/librustc_driver/pretty.rs
src/librustc_lint/builtin.rs
src/librustc_lint/types.rs
src/librustc_lint/unused.rs
src/librustc_metadata/encoder.rs
src/librustc_mir/hair/cx/block.rs
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/cx/mod.rs
src/librustc_mir/hair/pattern/check_match.rs
src/librustc_mir/hair/pattern/mod.rs
src/librustc_passes/rvalue_promotion.rs
src/librustc_privacy/lib.rs
src/librustc_save_analysis/dump_visitor.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/callee.rs
src/librustc_typeck/check/cast.rs
src/librustc_typeck/check/closure.rs
src/librustc_typeck/check/coercion.rs
src/librustc_typeck/check/demand.rs
src/librustc_typeck/check/method/mod.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/op.rs
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/check/upvar.rs
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/collect.rs

index 9eeae6eeb5f34819f73d44f8c79b0771ab296632..30a0477467d8016ff94d58cebc0a5174a2175239 100644 (file)
@@ -398,7 +398,7 @@ fn call<'b, I: Iterator<Item=&'b hir::Expr>>(&mut self,
             args: I) -> CFGIndex {
         let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
         let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
-        let m = self.tcx.hir().get_module_parent(call_expr.id);
+        let m = self.tcx.hir().get_module_parent_by_hir_id(call_expr.hir_id);
         if self.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(call_expr)) {
             self.add_unreachable_node()
         } else {
index 769cfbe5b4c6dfa30c10809e0525ae8e293ad2b3..0211dd7287563d911148e0b2283f788d1fd53d11 100644 (file)
@@ -963,7 +963,6 @@ fn make_async_expr(
         let closure_hir_id = self.lower_node_id(closure_node_id).hir_id;
         let decl = self.lower_fn_decl(&decl, None, /* impl trait allowed */ false, None);
         let generator = hir::Expr {
-            id: closure_node_id,
             hir_id: closure_hir_id,
             node: hir::ExprKind::Closure(capture_clause, decl, body_id, span,
                 Some(hir::GeneratorMovability::Static)),
@@ -3932,10 +3931,9 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                     let mut block = this.lower_block(body, true).into_inner();
                     let tail = block.expr.take().map_or_else(
                         || {
-                            let LoweredNodeId { node_id, hir_id } = this.next_id();
+                            let LoweredNodeId { node_id: _, hir_id } = this.next_id();
                             let span = this.sess.source_map().end_point(unstable_span);
                             hir::Expr {
-                                id: node_id,
                                 span,
                                 node: hir::ExprKind::Tup(hir_vec![]),
                                 attrs: ThinVec::new(),
@@ -4120,10 +4118,9 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                 let struct_path = self.std_path(e.span, &struct_path, None, is_unit);
                 let struct_path = hir::QPath::Resolved(None, P(struct_path));
 
-                let LoweredNodeId { node_id, hir_id } = self.lower_node_id(e.id);
+                let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(e.id);
 
                 return hir::Expr {
-                    id: node_id,
                     hir_id,
                     node: if is_unit {
                         hir::ExprKind::Path(struct_path)
@@ -4473,9 +4470,8 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                     self.lower_label(opt_label),
                     hir::LoopSource::ForLoop,
                 );
-                let LoweredNodeId { node_id, hir_id } = self.lower_node_id(e.id);
+                let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(e.id);
                 let loop_expr = P(hir::Expr {
-                    id: node_id,
                     hir_id,
                     node: loop_expr,
                     span: e.span,
@@ -4620,10 +4616,9 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
             ExprKind::Mac(_) => panic!("Shouldn't exist here"),
         };
 
-        let LoweredNodeId { node_id, hir_id } = self.lower_node_id(e.id);
+        let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(e.id);
 
         hir::Expr {
-            id: node_id,
             hir_id,
             node: kind,
             span: e.span,
@@ -4895,9 +4890,8 @@ fn expr_tuple(&mut self, sp: Span, exprs: hir::HirVec<hir::Expr>) -> P<hir::Expr
     }
 
     fn expr(&mut self, span: Span, node: hir::ExprKind, attrs: ThinVec<Attribute>) -> hir::Expr {
-        let LoweredNodeId { node_id, hir_id } = self.next_id();
+        let LoweredNodeId { node_id: _, hir_id } = self.next_id();
         hir::Expr {
-            id: node_id,
             hir_id,
             node,
             span,
index 6919628c7675552c18863a5724712dca46295ab7..1114ef52bbc0c8aba1e10c5a599809fde89ed8d9 100644 (file)
@@ -75,10 +75,10 @@ pub enum Code<'a> {
 }
 
 impl<'a> Code<'a> {
-    pub fn id(&self) -> NodeId {
+    pub fn id(&self) -> ast::HirId {
         match *self {
             Code::FnLike(node) => node.id(),
-            Code::Expr(block) => block.id,
+            Code::Expr(block) => block.hir_id,
         }
     }
 
@@ -104,7 +104,7 @@ struct ItemFnParts<'a> {
     vis:      &'a ast::Visibility,
     generics: &'a ast::Generics,
     body:     ast::BodyId,
-    id:       NodeId,
+    id:       ast::HirId,
     span:     Span,
     attrs:    &'a [Attribute],
 }
@@ -114,13 +114,13 @@ struct ItemFnParts<'a> {
 struct ClosureParts<'a> {
     decl: &'a FnDecl,
     body: ast::BodyId,
-    id: NodeId,
+    id: ast::HirId,
     span: Span,
     attrs: &'a [Attribute],
 }
 
 impl<'a> ClosureParts<'a> {
-    fn new(d: &'a FnDecl, b: ast::BodyId, id: NodeId, s: Span, attrs: &'a [Attribute]) -> Self {
+    fn new(d: &'a FnDecl, b: ast::BodyId, id: ast::HirId, s: Span, attrs: &'a [Attribute]) -> Self {
         ClosureParts {
             decl: d,
             body: b,
@@ -168,7 +168,7 @@ pub fn span(self) -> Span {
                     |c: ClosureParts<'_>| c.span)
     }
 
-    pub fn id(self) -> NodeId {
+    pub fn id(self) -> ast::HirId {
         self.handle(|i: ItemFnParts<'_>| i.id,
                     |id, _, _: &'a ast::MethodSig, _, _, _, _| id,
                     |c: ClosureParts<'_>| c.id)
@@ -213,7 +213,7 @@ pub fn kind(self) -> FnKind<'a> {
 
     fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
         I: FnOnce(ItemFnParts<'a>) -> A,
-        M: FnOnce(NodeId,
+        M: FnOnce(ast::HirId,
                   Ident,
                   &'a ast::MethodSig,
                   Option<&'a ast::Visibility>,
@@ -227,7 +227,7 @@ fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
             map::Node::Item(i) => match i.node {
                 ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
                     item_fn(ItemFnParts {
-                        id: i.id,
+                        id: i.hir_id,
                         ident: i.ident,
                         decl: &decl,
                         body: block,
@@ -241,21 +241,21 @@ fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
             },
             map::Node::TraitItem(ti) => match ti.node {
                 ast::TraitItemKind::Method(ref sig, ast::TraitMethod::Provided(body)) => {
-                    method(ti.id, ti.ident, sig, None, body, ti.span, &ti.attrs)
+                    method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
                 }
                 _ => bug!("trait method FnLikeNode that is not fn-like"),
             },
             map::Node::ImplItem(ii) => {
                 match ii.node {
                     ast::ImplItemKind::Method(ref sig, body) => {
-                        method(ii.id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
+                        method(ii.hir_id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
                     }
                     _ => bug!("impl method FnLikeNode that is not fn-like")
                 }
             },
             map::Node::Expr(e) => match e.node {
                 ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) =>
-                    closure(ClosureParts::new(&decl, block, e.id, e.span, &e.attrs)),
+                    closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs)),
                 _ => bug!("expr FnLikeNode that is not fn-like"),
             },
             _ => bug!("other FnLikeNode that is not fn-like"),
index 5339d0fa0ecd0b42c1bfa466eccb4906cf539812..41e48e46ea5b6116d76cc4f62d397099e6cb6663 100644 (file)
@@ -799,7 +799,7 @@ fn walk_parent_nodes<F, F2>(&self,
     ///     false
     /// }
     /// ```
-    pub fn get_return_block(&self, id: NodeId) -> Option<NodeId> {
+    pub fn get_return_block(&self, id: HirId) -> Option<HirId> {
         let match_fn = |node: &Node<'_>| {
             match *node {
                 Node::Item(_) |
@@ -822,7 +822,10 @@ pub fn get_return_block(&self, id: NodeId) -> Option<NodeId> {
             }
         };
 
-        self.walk_parent_nodes(id, match_fn, match_non_returning_block).ok()
+        let node_id = self.hir_to_node_id(id);
+        self.walk_parent_nodes(node_id, match_fn, match_non_returning_block)
+            .ok()
+            .map(|return_node_id| self.node_to_hir_id(return_node_id))
     }
 
     /// Retrieves the `NodeId` for `id`'s parent item, or `id` itself if no
index 53a63735cefba161b137de6b1d42f8b10e963e74..497825e203e231e8633f44b9d04e2ed922d4ca6d 100644 (file)
@@ -1333,7 +1333,6 @@ pub struct AnonConst {
 /// An expression
 #[derive(Clone, RustcEncodable, RustcDecodable)]
 pub struct Expr {
-    pub id: NodeId,
     pub span: Span,
     pub node: ExprKind,
     pub attrs: ThinVec<Attribute>,
@@ -1436,7 +1435,7 @@ pub fn is_place_expr(&self) -> bool {
 
 impl fmt::Debug for Expr {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(f, "expr({}: {})", self.id,
+        write!(f, "expr({}: {})", self.hir_id,
                print::to_string(print::NO_ANN, |s| s.print_expr(self)))
     }
 }
index e12a1bc7f191759fef1ff7d560366b1d99ebd7c8..d1161dda1e2ff592c04f5a7469634e0cc38620a0 100644 (file)
@@ -559,7 +559,6 @@ fn hash_stable<W: StableHasherResult>(&self,
                                           hasher: &mut StableHasher<W>) {
         hcx.while_hashing_hir_bodies(true, |hcx| {
             let hir::Expr {
-                id: _,
                 hir_id: _,
                 ref span,
                 ref node,
index 6c60f3f5a80a3de29d435881076fe0111bfe1d41..dd003e44bea09d8bba7acb41ca40af89e46ac595 100644 (file)
@@ -723,7 +723,7 @@ fn lint_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cnum: CrateNum)
     };
     let krate = tcx.hir().krate();
 
-    builder.with_lint_attrs(ast::CRATE_NODE_ID, &krate.attrs, |builder| {
+    builder.with_lint_attrs(hir::CRATE_HIR_ID, &krate.attrs, |builder| {
         intravisit::walk_crate(builder, krate);
     });
 
@@ -737,13 +737,13 @@ struct LintLevelMapBuilder<'a, 'tcx: 'a> {
 
 impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> {
     fn with_lint_attrs<F>(&mut self,
-                          id: ast::NodeId,
+                          id: hir::HirId,
                           attrs: &[ast::Attribute],
                           f: F)
         where F: FnOnce(&mut Self)
     {
         let push = self.levels.push(attrs);
-        self.levels.register_id(self.tcx.hir().definitions().node_to_hir_id(id));
+        self.levels.register_id(id);
         f(self);
         self.levels.pop(push);
     }
@@ -755,25 +755,25 @@ fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'thi
     }
 
     fn visit_item(&mut self, it: &'tcx hir::Item) {
-        self.with_lint_attrs(it.id, &it.attrs, |builder| {
+        self.with_lint_attrs(it.hir_id, &it.attrs, |builder| {
             intravisit::walk_item(builder, it);
         });
     }
 
     fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem) {
-        self.with_lint_attrs(it.id, &it.attrs, |builder| {
+        self.with_lint_attrs(it.hir_id, &it.attrs, |builder| {
             intravisit::walk_foreign_item(builder, it);
         })
     }
 
     fn visit_expr(&mut self, e: &'tcx hir::Expr) {
-        self.with_lint_attrs(e.id, &e.attrs, |builder| {
+        self.with_lint_attrs(e.hir_id, &e.attrs, |builder| {
             intravisit::walk_expr(builder, e);
         })
     }
 
     fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
-        self.with_lint_attrs(s.id, &s.attrs, |builder| {
+        self.with_lint_attrs(s.hir_id, &s.attrs, |builder| {
             intravisit::walk_struct_field(builder, s);
         })
     }
@@ -782,25 +782,25 @@ fn visit_variant(&mut self,
                      v: &'tcx hir::Variant,
                      g: &'tcx hir::Generics,
                      item_id: hir::HirId) {
-        self.with_lint_attrs(v.node.data.id(), &v.node.attrs, |builder| {
+        self.with_lint_attrs(v.node.data.hir_id(), &v.node.attrs, |builder| {
             intravisit::walk_variant(builder, v, g, item_id);
         })
     }
 
     fn visit_local(&mut self, l: &'tcx hir::Local) {
-        self.with_lint_attrs(l.id, &l.attrs, |builder| {
+        self.with_lint_attrs(l.hir_id, &l.attrs, |builder| {
             intravisit::walk_local(builder, l);
         })
     }
 
     fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
-        self.with_lint_attrs(trait_item.id, &trait_item.attrs, |builder| {
+        self.with_lint_attrs(trait_item.hir_id, &trait_item.attrs, |builder| {
             intravisit::walk_trait_item(builder, trait_item);
         });
     }
 
     fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
-        self.with_lint_attrs(impl_item.id, &impl_item.attrs, |builder| {
+        self.with_lint_attrs(impl_item.hir_id, &impl_item.attrs, |builder| {
             intravisit::walk_impl_item(builder, impl_item);
         });
     }
index 878d93c66cc24ac09fc611a9d7d442eee59cad6c..201a779ee1827adef9f99b6939f81db110bc0d6d 100644 (file)
@@ -99,10 +99,10 @@ fn lookup_and_handle_method(&mut self, id: hir::HirId) {
         }
     }
 
-    fn handle_field_access(&mut self, lhs: &hir::Expr, node_id: ast::NodeId) {
+    fn handle_field_access(&mut self, lhs: &hir::Expr, hir_id: hir::HirId) {
         match self.tables.expr_ty_adjusted(lhs).sty {
             ty::Adt(def, _) => {
-                let index = self.tcx.field_index(node_id, self.tables);
+                let index = self.tcx.field_index(hir_id, self.tables);
                 self.insert_def_id(def.non_enum_variant().fields[index].did);
             }
             ty::Tuple(..) => {}
@@ -120,7 +120,7 @@ fn handle_field_pattern_match(&mut self, lhs: &hir::Pat, def: Def,
             if let PatKind::Wild = pat.node.pat.node {
                 continue;
             }
-            let index = self.tcx.field_index(pat.node.id, self.tables);
+            let index = self.tcx.field_index(pat.node.hir_id, self.tables);
             self.insert_def_id(variant.fields[index].did);
         }
     }
@@ -190,7 +190,7 @@ fn visit_node(&mut self, node: Node<'tcx>) {
     fn mark_as_used_if_union(&mut self, adt: &ty::AdtDef, fields: &hir::HirVec<hir::Field>) {
         if adt.is_union() && adt.non_enum_variant().fields.len() > 1 && adt.did.is_local() {
             for field in fields {
-                let index = self.tcx.field_index(field.id, self.tables);
+                let index = self.tcx.field_index(field.hir_id, self.tables);
                 self.insert_def_id(adt.non_enum_variant().fields[index].did);
             }
         }
@@ -232,7 +232,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
                 self.lookup_and_handle_method(expr.hir_id);
             }
             hir::ExprKind::Field(ref lhs, ..) => {
-                self.handle_field_access(&lhs, expr.id);
+                self.handle_field_access(&lhs, expr.hir_id);
             }
             hir::ExprKind::Struct(_, ref fields, _) => {
                 if let ty::Adt(ref adt, _) = self.tables.expr_ty(expr).sty {
index 29cb40a9a67318104b2f4ed73f4f4bb8803ca552..7fc01e302a7d2c22e131117fed35a817fa166994 100644 (file)
@@ -33,7 +33,7 @@ pub trait Delegate<'tcx> {
     // The value found at `cmt` is either copied or moved, depending
     // on mode.
     fn consume(&mut self,
-               consume_id: ast::NodeId,
+               consume_id: hir::HirId,
                consume_span: Span,
                cmt: &mc::cmt_<'tcx>,
                mode: ConsumeMode);
@@ -65,7 +65,7 @@ fn consume_pat(&mut self,
     // The value found at `borrow` is being borrowed at the point
     // `borrow_id` for the region `loan_region` with kind `bk`.
     fn borrow(&mut self,
-              borrow_id: ast::NodeId,
+              borrow_id: hir::HirId,
               borrow_span: Span,
               cmt: &mc::cmt_<'tcx>,
               loan_region: ty::Region<'tcx>,
@@ -79,7 +79,7 @@ fn decl_without_init(&mut self,
 
     // The path at `cmt` is being assigned to.
     fn mutate(&mut self,
-              assignment_id: ast::NodeId,
+              assignment_id: hir::HirId,
               assignment_span: Span,
               assignee_cmt: &mc::cmt_<'tcx>,
               mode: MutateMode);
@@ -329,7 +329,7 @@ fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> {
     }
 
     fn delegate_consume(&mut self,
-                        consume_id: ast::NodeId,
+                        consume_id: hir::HirId,
                         consume_span: Span,
                         cmt: &mc::cmt_<'tcx>) {
         debug!("delegate_consume(consume_id={}, cmt={:?})",
@@ -349,7 +349,7 @@ pub fn consume_expr(&mut self, expr: &hir::Expr) {
         debug!("consume_expr(expr={:?})", expr);
 
         let cmt = return_if_err!(self.mc.cat_expr(expr));
-        self.delegate_consume(expr.id, expr.span, &cmt);
+        self.delegate_consume(expr.hir_id, expr.span, &cmt);
         self.walk_expr(expr);
     }
 
@@ -359,7 +359,7 @@ fn mutate_expr(&mut self,
                    expr: &hir::Expr,
                    mode: MutateMode) {
         let cmt = return_if_err!(self.mc.cat_expr(expr));
-        self.delegate.mutate(assignment_expr.id, span, &cmt, mode);
+        self.delegate.mutate(assignment_expr.hir_id, span, &cmt, mode);
         self.walk_expr(expr);
     }
 
@@ -372,7 +372,7 @@ fn borrow_expr(&mut self,
                expr, r, bk);
 
         let cmt = return_if_err!(self.mc.cat_expr(expr));
-        self.delegate.borrow(expr.id, expr.span, &cmt, r, bk, cause);
+        self.delegate.borrow(expr.hir_id, expr.span, &cmt, r, bk, cause);
 
         self.walk_expr(expr)
     }
@@ -662,7 +662,7 @@ fn walk_struct_expr(&mut self,
                 // Consume those fields of the with expression that are needed.
                 for (f_index, with_field) in adt.non_enum_variant().fields.iter().enumerate() {
                     let is_mentioned = fields.iter().any(|f| {
-                        self.tcx().field_index(f.id, self.mc.tables) == f_index
+                        self.tcx().field_index(f.hir_id, self.mc.tables) == f_index
                     });
                     if !is_mentioned {
                         let cmt_field = self.mc.cat_field(
@@ -672,7 +672,7 @@ fn walk_struct_expr(&mut self,
                             with_field.ident,
                             with_field.ty(self.tcx(), substs)
                         );
-                        self.delegate_consume(with_expr.id, with_expr.span, &cmt_field);
+                        self.delegate_consume(with_expr.hir_id, with_expr.span, &cmt_field);
                     }
                 }
             }
@@ -711,7 +711,7 @@ fn walk_adjustment(&mut self, expr: &hir::Expr) {
                 adjustment::Adjust::Unsize => {
                     // Creating a closure/fn-pointer or unsizing consumes
                     // the input and stores it into the resulting rvalue.
-                    self.delegate_consume(expr.id, expr.span, &cmt);
+                    self.delegate_consume(expr.hir_id, expr.span, &cmt);
                 }
 
                 adjustment::Adjust::Deref(None) => {}
@@ -723,7 +723,7 @@ fn walk_adjustment(&mut self, expr: &hir::Expr) {
                 // this is an autoref of `x`.
                 adjustment::Adjust::Deref(Some(ref deref)) => {
                     let bk = ty::BorrowKind::from_mutbl(deref.mutbl);
-                    self.delegate.borrow(expr.id, expr.span, &cmt, deref.region, bk, AutoRef);
+                    self.delegate.borrow(expr.hir_id, expr.span, &cmt, deref.region, bk, AutoRef);
                 }
 
                 adjustment::Adjust::Borrow(ref autoref) => {
@@ -741,14 +741,14 @@ fn walk_autoref(&mut self,
                     expr: &hir::Expr,
                     cmt_base: &mc::cmt_<'tcx>,
                     autoref: &adjustment::AutoBorrow<'tcx>) {
-        debug!("walk_autoref(expr.id={} cmt_base={:?} autoref={:?})",
-               expr.id,
+        debug!("walk_autoref(expr.hir_id={} cmt_base={:?} autoref={:?})",
+               expr.hir_id,
                cmt_base,
                autoref);
 
         match *autoref {
             adjustment::AutoBorrow::Ref(r, m) => {
-                self.delegate.borrow(expr.id,
+                self.delegate.borrow(expr.hir_id,
                                      expr.span,
                                      cmt_base,
                                      r,
@@ -757,8 +757,8 @@ fn walk_autoref(&mut self,
             }
 
             adjustment::AutoBorrow::RawPtr(m) => {
-                debug!("walk_autoref: expr.id={} cmt_base={:?}",
-                       expr.id,
+                debug!("walk_autoref: expr.hir_id={} cmt_base={:?}",
+                       expr.hir_id,
                        cmt_base);
 
                 // Converting from a &T to *T (or &mut T to *mut T) is
@@ -770,7 +770,7 @@ fn walk_autoref(&mut self,
                         data: region::ScopeData::Node
                     }));
 
-                self.delegate.borrow(expr.id,
+                self.delegate.borrow(expr.hir_id,
                                      expr.span,
                                      cmt_base,
                                      r,
@@ -864,7 +864,7 @@ fn walk_pat(&mut self, cmt_discr: mc::cmt<'tcx>, pat: &hir::Pat, match_mode: Mat
                     // binding being produced.
                     let def = Def::Local(canonical_id);
                     if let Ok(ref binding_cmt) = mc.cat_def(pat.hir_id, pat.span, pat_ty, def) {
-                        delegate.mutate(pat.id, pat.span, binding_cmt, MutateMode::Init);
+                        delegate.mutate(pat.hir_id, pat.span, binding_cmt, MutateMode::Init);
                     }
 
                     // It is also a borrow or copy/move of the value being matched.
@@ -872,7 +872,7 @@ fn walk_pat(&mut self, cmt_discr: mc::cmt<'tcx>, pat: &hir::Pat, match_mode: Mat
                         ty::BindByReference(m) => {
                             if let ty::Ref(r, _, _) = pat_ty.sty {
                                 let bk = ty::BorrowKind::from_mutbl(m);
-                                delegate.borrow(pat.id, pat.span, &cmt_pat, r, bk, RefBinding);
+                                delegate.borrow(pat.hir_id, pat.span, &cmt_pat, r, bk, RefBinding);
                             }
                         }
                         ty::BindByValue(..) => {
@@ -920,10 +920,11 @@ fn walk_pat(&mut self, cmt_discr: mc::cmt<'tcx>, pat: &hir::Pat, match_mode: Mat
     fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
         debug!("walk_captures({:?})", closure_expr);
 
-        self.tcx().with_freevars(closure_expr.id, |freevars| {
+        let closure_node_id = self.tcx().hir().hir_to_node_id(closure_expr.hir_id);
+        let closure_def_id = self.tcx().hir().local_def_id(closure_node_id);
+        self.tcx().with_freevars(closure_node_id, |freevars| {
             for freevar in freevars {
                 let var_hir_id = self.tcx().hir().node_to_hir_id(freevar.var_id());
-                let closure_def_id = self.tcx().hir().local_def_id(closure_expr.id);
                 let upvar_id = ty::UpvarId {
                     var_path: ty::UpvarPath { hir_id: var_hir_id },
                     closure_expr_id: closure_def_id.to_local(),
@@ -938,10 +939,10 @@ fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
                                                 self.param_env,
                                                 &cmt_var,
                                                 CaptureMove);
-                        self.delegate.consume(closure_expr.id, freevar.span, &cmt_var, mode);
+                        self.delegate.consume(closure_expr.hir_id, freevar.span, &cmt_var, mode);
                     }
                     ty::UpvarCapture::ByRef(upvar_borrow) => {
-                        self.delegate.borrow(closure_expr.id,
+                        self.delegate.borrow(closure_expr.hir_id,
                                              fn_decl_span,
                                              &cmt_var,
                                              upvar_borrow.region,
index 8cbc4bff3e15b4e23f3234cda8bbb207c61a94f7..76933a6e3484b02194d3341ba3b2bd0b6748c696 100644 (file)
@@ -265,7 +265,7 @@ struct IrMaps<'a, 'tcx: 'a> {
     num_vars: usize,
     live_node_map: HirIdMap<LiveNode>,
     variable_map: HirIdMap<Variable>,
-    capture_info_map: NodeMap<Rc<Vec<CaptureInfo>>>,
+    capture_info_map: HirIdMap<Rc<Vec<CaptureInfo>>>,
     var_kinds: Vec<VarKind>,
     lnks: Vec<LiveNodeKind>,
 }
@@ -344,8 +344,8 @@ fn variable_is_shorthand(&self, var: Variable) -> bool {
         }
     }
 
-    fn set_captures(&mut self, node_id: NodeId, cs: Vec<CaptureInfo>) {
-        self.capture_info_map.insert(node_id, Rc::new(cs));
+    fn set_captures(&mut self, hir_id: HirId, cs: Vec<CaptureInfo>) {
+        self.capture_info_map.insert(hir_id, Rc::new(cs));
     }
 
     fn lnk(&self, ln: LiveNode) -> LiveNodeKind {
@@ -460,7 +460,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
     match expr.node {
       // live nodes required for uses or definitions of variables:
       hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
-        debug!("expr {}: path that leads to {:?}", expr.id, path.def);
+        debug!("expr {}: path that leads to {:?}", expr.hir_id, path.def);
         if let Def::Local(..) = path.def {
             ir.add_live_node_for_node(expr.hir_id, ExprNode(expr.span));
         }
@@ -476,7 +476,8 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
         // in better error messages than just pointing at the closure
         // construction site.
         let mut call_caps = Vec::new();
-        ir.tcx.with_freevars(expr.id, |freevars| {
+        let node_id = ir.tcx.hir().hir_to_node_id(expr.hir_id);
+        ir.tcx.with_freevars(node_id, |freevars| {
             call_caps.extend(freevars.iter().filter_map(|fv| {
                 if let Def::Local(rv) = fv.def {
                     let fv_ln = ir.add_live_node(FreeVarNode(fv.span));
@@ -487,7 +488,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
                 }
             }));
         });
-        ir.set_captures(expr.id, call_caps);
+        ir.set_captures(expr.hir_id, call_caps);
 
         intravisit::walk_expr(ir, expr);
       }
@@ -925,7 +926,8 @@ fn acc(&mut self, ln: LiveNode, var: Variable, acc: u32) {
     }
 
     fn compute(&mut self, body: &hir::Expr) -> LiveNode {
-        debug!("compute: using id for body, {}", self.ir.tcx.hir().node_to_pretty_string(body.id));
+        debug!("compute: using id for body, {}",
+               self.ir.tcx.hir().hir_to_pretty_string(body.hir_id));
 
         // the fallthrough exit is only for those cases where we do not
         // explicitly return:
@@ -940,7 +942,7 @@ fn compute(&mut self, body: &hir::Expr) -> LiveNode {
                    for ln_idx in 0..self.ir.num_live_nodes {
                         debug!("{:?}", self.ln_str(LiveNode(ln_idx as u32)));
                    }
-                   body.id
+                   body.hir_id
                },
                entry_ln);
 
@@ -1003,7 +1005,7 @@ fn propagate_through_opt_expr(&mut self,
 
     fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
                               -> LiveNode {
-        debug!("propagate_through_expr: {}", self.ir.tcx.hir().node_to_pretty_string(expr.id));
+        debug!("propagate_through_expr: {}", self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id));
 
         match expr.node {
             // Interesting cases with control flow or which gen/kill
@@ -1017,11 +1019,11 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
 
             hir::ExprKind::Closure(..) => {
                 debug!("{} is an ExprKind::Closure",
-                       self.ir.tcx.hir().node_to_pretty_string(expr.id));
+                       self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id));
 
                 // the construction of a closure itself is not important,
                 // but we have to consider the closed over variables.
-                let caps = self.ir.capture_info_map.get(&expr.id).cloned().unwrap_or_else(||
+                let caps = self.ir.capture_info_map.get(&expr.hir_id).cloned().unwrap_or_else(||
                     span_bug!(expr.span, "no registered caps"));
 
                 caps.iter().rev().fold(succ, |succ, cap| {
@@ -1170,7 +1172,7 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
             }
 
             hir::ExprKind::Call(ref f, ref args) => {
-                let m = self.ir.tcx.hir().get_module_parent(expr.id);
+                let m = self.ir.tcx.hir().get_module_parent_by_hir_id(expr.hir_id);
                 let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
                     self.s.exit_ln
                 } else {
@@ -1181,7 +1183,7 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
             }
 
             hir::ExprKind::MethodCall(.., ref args) => {
-                let m = self.ir.tcx.hir().get_module_parent(expr.id);
+                let m = self.ir.tcx.hir().get_module_parent_by_hir_id(expr.hir_id);
                 let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
                     self.s.exit_ln
                 } else {
@@ -1387,17 +1389,17 @@ fn propagate_through_loop(&mut self,
             }
         }
         debug!("propagate_through_loop: using id for loop body {} {}",
-               expr.id, self.ir.tcx.hir().hir_to_pretty_string(body.hir_id));
+               expr.hir_id, self.ir.tcx.hir().hir_to_pretty_string(body.hir_id));
 
-
-        self.break_ln.insert(expr.id, succ);
+        let node_id = self.ir.tcx.hir().hir_to_node_id(expr.hir_id);
+        self.break_ln.insert(node_id, succ);
 
         let cond_ln = match kind {
             LoopLoop => ln,
             WhileLoop(ref cond) => self.propagate_through_expr(&cond, ln),
         };
 
-        self.cont_ln.insert(expr.id, cond_ln);
+        self.cont_ln.insert(node_id, cond_ln);
 
         let body_ln = self.propagate_through_block(body, cond_ln);
 
index f65c09e31343cf12c67c5635763cf90472481f5c..822a42b374f38fc5a13e9b7d65e34776eff2be3d 100644 (file)
@@ -632,7 +632,7 @@ fn cat_expr_adjusted_with<F>(&self, expr: &hir::Expr,
     }
 
     pub fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> {
-        debug!("cat_expr: id={} expr={:?}", expr.id, expr);
+        debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr);
 
         let expr_ty = self.expr_ty(expr)?;
         match expr.node {
@@ -648,10 +648,10 @@ pub fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> {
             hir::ExprKind::Field(ref base, f_ident) => {
                 let base_cmt = Rc::new(self.cat_expr(&base)?);
                 debug!("cat_expr(cat_field): id={} expr={:?} base={:?}",
-                       expr.id,
+                       expr.hir_id,
                        expr,
                        base_cmt);
-                let f_index = self.tcx.field_index(expr.id, self.tables);
+                let f_index = self.tcx.field_index(expr.hir_id, self.tables);
                 Ok(self.cat_field(expr, base_cmt, f_index, f_ident, expr_ty))
             }
 
@@ -1321,7 +1321,7 @@ fn cat_pattern_<F>(&self, mut cmt: cmt<'tcx>, pat: &hir::Pat, op: &mut F) -> McR
 
                 for fp in field_pats {
                     let field_ty = self.pat_ty_adjusted(&fp.node.pat)?; // see (*2)
-                    let f_index = self.tcx.field_index(fp.node.id, self.tables);
+                    let f_index = self.tcx.field_index(fp.node.hir_id, self.tables);
                     let cmt_field = Rc::new(self.cat_field(pat, cmt.clone(), f_index,
                                                            fp.node.ident, field_ty));
                     self.cat_pattern_(cmt_field, &fp.node.pat, op)?;
index 3a81660ad6912f806d02348bacd05eb765e25b56..55572c637f80ad729d6b243314415c57e12745b9 100644 (file)
@@ -14,7 +14,7 @@
 use syntax::symbol::Symbol;
 use syntax_pos::{Span, MultiSpan};
 use syntax::ast;
-use syntax::ast::{NodeId, Attribute};
+use syntax::ast::Attribute;
 use syntax::errors::Applicability;
 use syntax::feature_gate::{GateIssue, emit_feature_err};
 use syntax::attr::{self, Stability, Deprecation};
@@ -557,9 +557,9 @@ fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool {
     /// If `id` is `Some(_)`, this function will also check if the item at `def_id` has been
     /// deprecated. If the item is indeed deprecated, we will emit a deprecation lint attached to
     /// `id`.
-    pub fn eval_stability(self, def_id: DefId, id: Option<NodeId>, span: Span) -> EvalResult {
+    pub fn eval_stability(self, def_id: DefId, id: Option<HirId>, span: Span) -> EvalResult {
         let lint_deprecated = |def_id: DefId,
-                               id: NodeId,
+                               id: HirId,
                                note: Option<Symbol>,
                                suggestion: Option<Symbol>,
                                message: &str,
@@ -570,9 +570,9 @@ pub fn eval_stability(self, def_id: DefId, id: Option<NodeId>, span: Span) -> Ev
                 format!("{}", message)
             };
 
-            let mut diag = self.struct_span_lint_node(lint, id, span, &msg);
+            let mut diag = self.struct_span_lint_hir(lint, id, span, &msg);
             if let Some(suggestion) = suggestion {
-                if let hir::Node::Expr(_) = self.hir().get(id) {
+                if let hir::Node::Expr(_) = self.hir().get_by_hir_id(id) {
                     diag.span_suggestion(
                         span,
                         &msg,
@@ -582,15 +582,16 @@ pub fn eval_stability(self, def_id: DefId, id: Option<NodeId>, span: Span) -> Ev
                 }
             }
             diag.emit();
-            if id == ast::DUMMY_NODE_ID {
-                span_bug!(span, "emitted a {} lint with dummy node id: {:?}", lint.name, def_id);
+            if id == hir::DUMMY_HIR_ID {
+                span_bug!(span, "emitted a {} lint with dummy HIR id: {:?}", lint.name, def_id);
             }
         };
 
         // Deprecated attributes apply in-crate and cross-crate.
         if let Some(id) = id {
             if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) {
-                let parent_def_id = self.hir().local_def_id(self.hir().get_parent(id));
+                let parent_def_id = self.hir().local_def_id_from_hir_id(
+                    self.hir().get_parent_item(id));
                 let skip = self.lookup_deprecation_entry(parent_def_id)
                                .map_or(false, |parent_depr| parent_depr.same_origin(&depr_entry));
 
@@ -703,7 +704,7 @@ pub fn eval_stability(self, def_id: DefId, id: Option<NodeId>, span: Span) -> Ev
     ///
     /// Additionally, this function will also check if the item is deprecated. If so, and `id` is
     /// not `None`, a deprecated lint attached to `id` will be emitted.
-    pub fn check_stability(self, def_id: DefId, id: Option<NodeId>, span: Span) {
+    pub fn check_stability(self, def_id: DefId, id: Option<HirId>, span: Span) {
         match self.eval_stability(def_id, id, span) {
             EvalResult::Allow => {}
             EvalResult::Deny { feature, reason, issue } => {
@@ -763,7 +764,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
                     None => return,
                 };
                 let def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
-                self.tcx.check_stability(def_id, Some(item.id), item.span);
+                self.tcx.check_stability(def_id, Some(item.hir_id), item.span);
             }
 
             // For implementations of traits, check the stability of each item
@@ -811,7 +812,6 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
     }
 
     fn visit_path(&mut self, path: &'tcx hir::Path, id: hir::HirId) {
-        let id = self.tcx.hir().hir_to_node_id(id);
         if let Some(def_id) = path.def.opt_def_id() {
             self.tcx.check_stability(def_id, Some(id), path.span)
         }
index 99d1e32d52398cdb15b7b048601c4f9e665cb820..be6a95948edb9d5201e8cfac86225b0f3c947f01 100644 (file)
@@ -257,10 +257,10 @@ pub enum ObligationCauseCode<'tcx> {
     ReturnNoExpression,
 
     /// `return` with an expression
-    ReturnType(ast::NodeId),
+    ReturnType(hir::HirId),
 
     /// Block implicit return
-    BlockTailExpression(ast::NodeId),
+    BlockTailExpression(hir::HirId),
 
     /// #[feature(trivial_bounds)] is not enabled
     TrivialBound,
index 02e4fb12af5c9b21ab202e36c0bd9767a285198d..a3cf7bf488ee71ad0398cc66095f8b5f7428179e 100644 (file)
@@ -2775,8 +2775,7 @@ fn associated_item_from_impl_item_ref(self,
         }
     }
 
-    pub fn field_index(self, node_id: NodeId, tables: &TypeckTables<'_>) -> usize {
-        let hir_id = self.hir().node_to_hir_id(node_id);
+    pub fn field_index(self, hir_id: hir::HirId, tables: &TypeckTables<'_>) -> usize {
         tables.field_indices().get(hir_id).cloned().expect("no index for a field")
     }
 
index b528967dd65ff6f884b39dbfbbcaa1c2889cd13a..c74d7f00cf5169626e5f634b1ed84878aa97988b 100644 (file)
@@ -89,15 +89,14 @@ struct CheckLoanCtxt<'a, 'tcx: 'a> {
 
 impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
     fn consume(&mut self,
-               consume_id: ast::NodeId,
+               consume_id: hir::HirId,
                consume_span: Span,
                cmt: &mc::cmt_<'tcx>,
                mode: euv::ConsumeMode) {
         debug!("consume(consume_id={}, cmt={:?}, mode={:?})",
                consume_id, cmt, mode);
 
-        let hir_id = self.tcx().hir().node_to_hir_id(consume_id);
-        self.consume_common(hir_id.local_id, consume_span, cmt, mode);
+        self.consume_common(consume_id.local_id, consume_span, cmt, mode);
     }
 
     fn matched_pat(&mut self,
@@ -118,7 +117,7 @@ fn consume_pat(&mut self,
     }
 
     fn borrow(&mut self,
-              borrow_id: ast::NodeId,
+              borrow_id: hir::HirId,
               borrow_span: Span,
               cmt: &mc::cmt_<'tcx>,
               loan_region: ty::Region<'tcx>,
@@ -130,22 +129,21 @@ fn borrow(&mut self,
                borrow_id, cmt, loan_region,
                bk, loan_cause);
 
-        let hir_id = self.tcx().hir().node_to_hir_id(borrow_id);
         if let Some(lp) = opt_loan_path(cmt) {
             let moved_value_use_kind = match loan_cause {
                 euv::ClosureCapture(_) => MovedInCapture,
                 _ => MovedInUse,
             };
-            self.check_if_path_is_moved(hir_id.local_id, borrow_span, moved_value_use_kind, &lp);
+            self.check_if_path_is_moved(borrow_id.local_id, borrow_span, moved_value_use_kind, &lp);
         }
 
-        self.check_for_conflicting_loans(hir_id.local_id);
+        self.check_for_conflicting_loans(borrow_id.local_id);
 
         self.check_for_loans_across_yields(cmt, loan_region, borrow_span);
     }
 
     fn mutate(&mut self,
-              assignment_id: ast::NodeId,
+              assignment_id: hir::HirId,
               assignment_span: Span,
               assignee_cmt: &mc::cmt_<'tcx>,
               mode: euv::MutateMode)
@@ -176,8 +174,7 @@ fn mutate(&mut self,
                 }
             }
         }
-        self.check_assignment(self.tcx().hir().node_to_hir_id(assignment_id).local_id,
-                              assignment_span, assignee_cmt);
+        self.check_assignment(assignment_id.local_id, assignment_span, assignee_cmt);
     }
 
     fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) { }
@@ -188,7 +185,7 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
                                      move_data: &move_data::FlowedMoveData<'c, 'tcx>,
                                      all_loans: &[Loan<'tcx>],
                                      body: &hir::Body) {
-    debug!("check_loans(body id={})", body.value.id);
+    debug!("check_loans(body id={})", body.value.hir_id);
 
     let def_id = bccx.tcx.hir().body_owner_def_id(body.id());
 
index cf6053b71b6a8a953cfd30666839d4b038492290..03af27997d3cbee7bdf7b4accd3f561ee603d89f 100644 (file)
@@ -68,7 +68,7 @@ struct GatherLoanCtxt<'a, 'tcx: 'a> {
 
 impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
     fn consume(&mut self,
-               consume_id: ast::NodeId,
+               consume_id: hir::HirId,
                _consume_span: Span,
                cmt: &mc::cmt_<'tcx>,
                mode: euv::ConsumeMode) {
@@ -79,7 +79,7 @@ fn consume(&mut self,
             euv::Move(move_reason) => {
                 gather_moves::gather_move_from_expr(
                     self.bccx, &self.move_data, &mut self.move_error_collector,
-                    self.bccx.tcx.hir().node_to_hir_id(consume_id).local_id, cmt, move_reason);
+                    consume_id.local_id, cmt, move_reason);
             }
             euv::Copy => { }
         }
@@ -115,7 +115,7 @@ fn consume_pat(&mut self,
     }
 
     fn borrow(&mut self,
-              borrow_id: ast::NodeId,
+              borrow_id: hir::HirId,
               borrow_span: Span,
               cmt: &mc::cmt_<'tcx>,
               loan_region: ty::Region<'tcx>,
@@ -126,8 +126,8 @@ fn borrow(&mut self,
                bk={:?}, loan_cause={:?})",
                borrow_id, cmt, loan_region,
                bk, loan_cause);
-        let hir_id = self.bccx.tcx.hir().node_to_hir_id(borrow_id);
-        self.guarantee_valid(hir_id.local_id,
+
+        self.guarantee_valid(borrow_id.local_id,
                              borrow_span,
                              cmt,
                              bk,
@@ -136,12 +136,13 @@ fn borrow(&mut self,
     }
 
     fn mutate(&mut self,
-              assignment_id: ast::NodeId,
+              assignment_id: hir::HirId,
               assignment_span: Span,
               assignee_cmt: &mc::cmt_<'tcx>,
               _: euv::MutateMode)
     {
-        self.guarantee_assignment_valid(assignment_id,
+        let node_id = self.bccx.tcx.hir().hir_to_node_id(assignment_id);
+        self.guarantee_assignment_valid(node_id,
                                         assignment_span,
                                         assignee_cmt);
     }
index b0b5594b93eac1bc1bbdd427534f4d178d1cdf60..0698c15346ebc4e9792cacf3270a3e048c9e3c19 100644 (file)
@@ -425,8 +425,8 @@ fn post(&self, s: &mut pprust_hir::State, node: pprust_hir::AnnNode) -> io::Resu
             }
             pprust_hir::AnnNode::Expr(expr) => {
                 s.s.space()?;
-                s.synth_comment(format!("node_id: {} hir local_id: {}",
-                                        expr.id, expr.hir_id.local_id.as_u32()))?;
+                s.synth_comment(format!("expr hir_id: {} hir local_id: {}",
+                                        expr.hir_id, expr.hir_id.local_id.as_u32()))?;
                 s.pclose()
             }
             pprust_hir::AnnNode::Pat(pat) => {
@@ -834,15 +834,15 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
     let body_id = match code {
         blocks::Code::Expr(expr) => {
             // Find the function this expression is from.
-            let mut node_id = expr.id;
+            let mut hir_id = expr.hir_id;
             loop {
-                let node = tcx.hir().get(node_id);
+                let node = tcx.hir().get_by_hir_id(hir_id);
                 if let Some(n) = hir::map::blocks::FnLikeNode::from_node(node) {
                     break n.body();
                 }
-                let parent = tcx.hir().get_parent_node(node_id);
-                assert_ne!(node_id, parent);
-                node_id = parent;
+                let parent = tcx.hir().get_parent_node_by_hir_id(hir_id);
+                assert_ne!(hir_id, parent);
+                hir_id = parent;
             }
         }
         blocks::Code::FnLike(fn_like) => fn_like.body(),
index 40c9ef3f63cf5abcd5ccc8e49b7dc3068dcaca1c..ac10b6403bd132e6a7d30c08350cb3b2fc8cb454 100644 (file)
@@ -200,7 +200,7 @@ fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat) {
                 }
                 if let PatKind::Binding(_, _, _, ident, None) = fieldpat.node.pat.node {
                     if cx.tcx.find_field_index(ident, &variant) ==
-                       Some(cx.tcx.field_index(fieldpat.node.id, cx.tables)) {
+                       Some(cx.tcx.field_index(fieldpat.node.hir_id, cx.tables)) {
                         let mut err = cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS,
                                      fieldpat.span,
                                      &format!("the `{}:` in this pattern is redundant", ident));
index 34f8fc40597f17a9d8906a511c1ace6b0aa9d452..ba598ccf7ab5d35c81f7e7cd6a578160ee917bfd 100644 (file)
 #[derive(Copy, Clone)]
 pub struct TypeLimits {
     /// Id of the last visited negated expression
-    negated_expr_id: ast::NodeId,
+    negated_expr_id: hir::HirId,
 }
 
 impl TypeLimits {
     pub fn new() -> TypeLimits {
-        TypeLimits { negated_expr_id: ast::DUMMY_NODE_ID }
+        TypeLimits { negated_expr_id: hir::DUMMY_HIR_ID }
     }
 }
 
@@ -73,8 +73,8 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
         match e.node {
             hir::ExprKind::Unary(hir::UnNeg, ref expr) => {
                 // propagate negation, if the negation itself isn't negated
-                if self.negated_expr_id != e.id {
-                    self.negated_expr_id = expr.id;
+                if self.negated_expr_id != e.hir_id {
+                    self.negated_expr_id = expr.hir_id;
                 }
             }
             hir::ExprKind::Binary(binop, ref l, ref r) => {
@@ -97,7 +97,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
                                 };
                                 let (_, max) = int_ty_range(int_type);
                                 let max = max as u128;
-                                let negative = self.negated_expr_id == e.id;
+                                let negative = self.negated_expr_id == e.hir_id;
 
                                 // Detect literal value out of range [min, max] inclusive
                                 // avoiding use of -min to prevent overflow/panic
@@ -138,8 +138,8 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
                             _ => bug!(),
                         };
                         if lit_val < min || lit_val > max {
-                            let parent_id = cx.tcx.hir().get_parent_node(e.id);
-                            if let Node::Expr(parent_expr) = cx.tcx.hir().get(parent_id) {
+                            let parent_id = cx.tcx.hir().get_parent_node_by_hir_id(e.hir_id);
+                            if let Node::Expr(parent_expr) = cx.tcx.hir().get_by_hir_id(parent_id) {
                                 if let hir::ExprKind::Cast(..) = parent_expr.node {
                                     if let ty::Char = cx.tables.expr_ty(parent_expr).sty {
                                         let mut err = cx.struct_span_lint(
index 407e6842935151b355441a8dc335da4a467c7d54..86b8b276eafe5930d35cb7c427705892690c0c6d 100644 (file)
@@ -58,7 +58,9 @@ fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
 
         let t = cx.tables.expr_ty(&expr);
         let type_permits_lack_of_use = if t.is_unit()
-            || cx.tcx.is_ty_uninhabited_from(cx.tcx.hir().get_module_parent(expr.id), t) {
+            || cx.tcx.is_ty_uninhabited_from(
+                cx.tcx.hir().get_module_parent_by_hir_id(expr.hir_id), t)
+        {
             true
         } else {
             match t.sty {
index 79457cc028a7d51dc63df84e570312d52a0a2d50..5fdc5899a721ec3862365706ee6639c5fb3d7119 100644 (file)
@@ -1729,7 +1729,7 @@ fn encode_info_for_ty(&mut self, ty: &hir::Ty) {
     fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
         match expr.node {
             hir::ExprKind::Closure(..) => {
-                let def_id = self.tcx.hir().local_def_id(expr.id);
+                let def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
                 self.record(def_id, IsolatedEncoder::encode_info_for_closure, def_id);
             }
             _ => {}
index b63bf4bc2468480b952afc5dfa9af502f7430fb9..f58e61915e8c99d120db8bc72a714f97e62da050 100644 (file)
@@ -103,7 +103,7 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                         },
                         pattern,
                         initializer: local.init.to_ref(),
-                        lint_level: cx.lint_level_of(local.id),
+                        lint_level: cx.lint_level_of(local.hir_id),
                     },
                     opt_destruction_scope: opt_dxn_ext,
                     span: stmt_span,
index 10d04a80d734152a2fdef5c98ce97cf8b4d1b6b5..a11afc3a27f213c4ee4bf23295b0b443172fb41c 100644 (file)
@@ -24,7 +24,7 @@ fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Expr<'tcx> {
             data: region::ScopeData::Node
         };
 
-        debug!("Expr::make_mirror(): id={}, span={:?}", self.id, self.span);
+        debug!("Expr::make_mirror(): id={}, span={:?}", self.hir_id, self.span);
 
         let mut expr = make_mirror_unadjusted(cx, self);
 
@@ -44,7 +44,7 @@ fn make_mirror<'a, 'gcx>(self, cx: &mut Cx<'a, 'gcx, 'tcx>) -> Expr<'tcx> {
             kind: ExprKind::Scope {
                 region_scope: expr_scope,
                 value: expr.to_ref(),
-                lint_level: cx.lint_level_of(self.id),
+                lint_level: cx.lint_level_of(self.hir_id),
             },
         };
 
@@ -529,7 +529,8 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                     span_bug!(expr.span, "closure expr w/o closure type: {:?}", closure_ty);
                 }
             };
-            let upvars = cx.tcx.with_freevars(expr.id, |freevars| {
+            let expr_node_id = cx.tcx.hir().hir_to_node_id(expr.hir_id);
+            let upvars = cx.tcx.with_freevars(expr_node_id, |freevars| {
                 freevars.iter()
                     .zip(substs.upvar_tys(def_id, cx.tcx))
                     .map(|(fv, ty)| capture_freevar(cx, expr, fv, ty))
@@ -637,7 +638,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         hir::ExprKind::Field(ref source, ..) => {
             ExprKind::Field {
                 lhs: source.to_ref(),
-                name: Field::new(cx.tcx.field_index(expr.id, cx.tables)),
+                name: Field::new(cx.tcx.field_index(expr.hir_id, cx.tables)),
             }
         }
         hir::ExprKind::Cast(ref source, ref cast_ty) => {
@@ -1184,7 +1185,7 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
     let var_hir_id = cx.tcx.hir().node_to_hir_id(freevar.var_id());
     let upvar_id = ty::UpvarId {
         var_path: ty::UpvarPath { hir_id: var_hir_id },
-        closure_expr_id: cx.tcx.hir().local_def_id(closure_expr.id).to_local(),
+        closure_expr_id: cx.tcx.hir().local_def_id_from_hir_id(closure_expr.hir_id).to_local(),
     };
     let upvar_capture = cx.tables().upvar_capture(upvar_id);
     let temp_lifetime = cx.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id);
@@ -1223,7 +1224,7 @@ fn field_refs<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
     fields.iter()
         .map(|field| {
             FieldExprRef {
-                name: Field::new(cx.tcx.field_index(field.id, cx.tables)),
+                name: Field::new(cx.tcx.field_index(field.hir_id, cx.tables)),
                 expr: field.expr.to_ref(),
             }
         })
index d24a70528ec4d3ea7c8f0c7e1dafd8a16f298f14..9e19badf49db0591040ae5732149c3fb576525dc 100644 (file)
@@ -197,8 +197,7 @@ pub fn needs_drop(&mut self, ty: Ty<'tcx>) -> bool {
         ty.needs_drop(self.tcx.global_tcx(), param_env)
     }
 
-    fn lint_level_of(&self, node_id: ast::NodeId) -> LintLevel {
-        let hir_id = self.tcx.hir().definitions().node_to_hir_id(node_id);
+    fn lint_level_of(&self, hir_id: hir::HirId) -> LintLevel {
         let has_lint_level = self.tcx.dep_graph.with_ignore(|| {
             self.tcx.lint_levels(LOCAL_CRATE).lint_level_set(hir_id).is_some()
         });
index 7c44d1bf2c9369d2dd5cca0df6d4bd19de32bead..fff810b0e6f2cce312a087baafb2dfd1f5ba5c3a 100644 (file)
@@ -171,7 +171,7 @@ fn check_match(
             }
         }
 
-        let module = self.tcx.hir().get_module_parent(scrut.id);
+        let module = self.tcx.hir().get_module_parent_by_hir_id(scrut.hir_id);
         MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
             let mut have_errors = false;
 
@@ -203,7 +203,7 @@ fn check_match(
             // Then, if the match has no arms, check whether the scrutinee
             // is uninhabited.
             let pat_ty = self.tables.node_type(scrut.hir_id);
-            let module = self.tcx.hir().get_module_parent(scrut.id);
+            let module = self.tcx.hir().get_module_parent_by_hir_id(scrut.hir_id);
             if inlined_arms.is_empty() {
                 let scrutinee_is_uninhabited = if self.tcx.features().exhaustive_patterns {
                     self.tcx.is_ty_uninhabited_from(module, pat_ty)
@@ -561,10 +561,10 @@ struct MutationChecker<'a, 'tcx: 'a> {
 
 impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
     fn matched_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: euv::MatchMode) {}
-    fn consume(&mut self, _: ast::NodeId, _: Span, _: &cmt_<'_>, _: ConsumeMode) {}
+    fn consume(&mut self, _: hir::HirId, _: Span, _: &cmt_<'_>, _: ConsumeMode) {}
     fn consume_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: ConsumeMode) {}
     fn borrow(&mut self,
-              _: ast::NodeId,
+              _: hir::HirId,
               span: Span,
               _: &cmt_<'_>,
               _: ty::Region<'tcx>,
@@ -587,7 +587,7 @@ fn borrow(&mut self,
         }
     }
     fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {}
-    fn mutate(&mut self, _: ast::NodeId, span: Span, _: &cmt_<'_>, mode: MutateMode) {
+    fn mutate(&mut self, _: hir::HirId, span: Span, _: &cmt_<'_>, mode: MutateMode) {
         match mode {
             MutateMode::JustWrite | MutateMode::WriteAndRead => {
                 struct_span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard")
index 4d571f4f78296124d665a00d3818c5244e38d0c2..9e5fdaa8afdf75b87d1359c1a500709b70254f62 100644 (file)
@@ -631,7 +631,7 @@ fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> {
                     fields.iter()
                           .map(|field| {
                               FieldPattern {
-                                  field: Field::new(self.tcx.field_index(field.node.id,
+                                  field: Field::new(self.tcx.field_index(field.node.hir_id,
                                                                          self.tables)),
                                   pattern: self.lower_pattern(&field.node.pat),
                               }
index 20f31b3ebc1736e4c4a4244639dac1fbf62713da..c25884df87ba13e49f8e4d8d13fbe34753bf1e87 100644 (file)
@@ -23,7 +23,7 @@
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::ty::query::Providers;
 use rustc::ty::subst::Substs;
-use rustc::util::nodemap::{ItemLocalSet, NodeSet};
+use rustc::util::nodemap::{ItemLocalSet, HirIdSet};
 use rustc::hir;
 use rustc_data_structures::sync::Lrc;
 use syntax::ast;
@@ -92,7 +92,7 @@ struct CheckCrateVisitor<'a, 'tcx: 'a> {
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     in_fn: bool,
     in_static: bool,
-    mut_rvalue_borrows: NodeSet,
+    mut_rvalue_borrows: HirIdSet,
     param_env: ty::ParamEnv<'tcx>,
     identity_substs: &'tcx Substs<'tcx>,
     tables: &'a ty::TypeckTables<'tcx>,
@@ -169,7 +169,7 @@ fn handle_const_fn_call(
     fn remove_mut_rvalue_borrow(&mut self, pat: &hir::Pat) -> bool {
         let mut any_removed = false;
         pat.walk(|p| {
-            any_removed |= self.mut_rvalue_borrows.remove(&p.id);
+            any_removed |= self.mut_rvalue_borrows.remove(&p.hir_id);
             true
         });
         any_removed
@@ -223,7 +223,7 @@ fn check_stmt(&mut self, stmt: &'tcx hir::Stmt) -> Promotability {
             hir::StmtKind::Local(ref local) => {
                 if self.remove_mut_rvalue_borrow(&local.pat) {
                     if let Some(init) = &local.init {
-                        self.mut_rvalue_borrows.insert(init.id);
+                        self.mut_rvalue_borrows.insert(init.hir_id);
                     }
                 }
 
@@ -248,7 +248,7 @@ fn check_expr(&mut self, ex: &'tcx hir::Expr) -> Promotability {
         outer &= check_adjustments(self, ex);
 
         // Handle borrows on (or inside the autorefs of) this expression.
-        if self.mut_rvalue_borrows.remove(&ex.id) {
+        if self.mut_rvalue_borrows.remove(&ex.hir_id) {
             outer = NotPromotable
         }
 
@@ -318,7 +318,7 @@ fn check_expr_kind<'a, 'tcx>(
         }
         hir::ExprKind::Cast(ref from, _) => {
             let expr_promotability = v.check_expr(from);
-            debug!("Checking const cast(id={})", from.id);
+            debug!("Checking const cast(id={})", from.hir_id);
             match v.tables.cast_kinds().get(from.hir_id) {
                 None => {
                     v.tcx.sess.delay_span_bug(e.span, "no kind for cast");
@@ -456,9 +456,10 @@ fn check_expr_kind<'a, 'tcx>(
         hir::ExprKind::Closure(_capture_clause, ref _box_fn_decl,
                                body_id, _span, _option_generator_movability) => {
             let nested_body_promotable = v.check_nested_body(body_id);
+            let node_id = v.tcx.hir().hir_to_node_id(e.hir_id);
             // Paths in constant contexts cannot refer to local variables,
             // as there are none, and thus closures can't have upvars there.
-            if v.tcx.with_freevars(e.id, |fv| !fv.is_empty()) {
+            if v.tcx.with_freevars(node_id, |fv| !fv.is_empty()) {
                 NotPromotable
             } else {
                 nested_body_promotable
@@ -518,7 +519,7 @@ fn check_expr_kind<'a, 'tcx>(
                 mut_borrow = v.remove_mut_rvalue_borrow(pat);
             }
             if mut_borrow {
-                v.mut_rvalue_borrows.insert(expr.id);
+                v.mut_rvalue_borrows.insert(expr.hir_id);
             }
 
             let _ = v.check_expr(expr);
@@ -619,13 +620,13 @@ fn check_adjustments<'a, 'tcx>(
 
 impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
     fn consume(&mut self,
-               _consume_id: ast::NodeId,
+               _consume_id: hir::HirId,
                _consume_span: Span,
                _cmt: &mc::cmt_<'_>,
                _mode: euv::ConsumeMode) {}
 
     fn borrow(&mut self,
-              borrow_id: ast::NodeId,
+              borrow_id: hir::HirId,
               _borrow_span: Span,
               cmt: &mc::cmt_<'tcx>,
               _loan_region: ty::Region<'tcx>,
@@ -678,7 +679,7 @@ fn borrow(&mut self,
 
     fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) {}
     fn mutate(&mut self,
-              _assignment_id: ast::NodeId,
+              _assignment_id: hir::HirId,
               _assignment_span: Span,
               _assignee_cmt: &mc::cmt_<'_>,
               _mode: euv::MutateMode) {
index 830ede751fbc6ccecf82f4a25bad8da3f53256ef..568e622bd34c2e70f494729bc4fccd094ee1e9b0 100644 (file)
@@ -271,7 +271,8 @@ fn def_id_visibility<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
                     return (ctor_vis, span, descr);
                 }
                 Node::Expr(expr) => {
-                    return (ty::Visibility::Restricted(tcx.hir().get_module_parent(expr.id)),
+                    return (ty::Visibility::Restricted(
+                        tcx.hir().get_module_parent_by_hir_id(expr.hir_id)),
                             expr.span, "private")
                 }
                 node => bug!("unexpected node kind: {:?}", node)
@@ -872,7 +873,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
                     // unmentioned fields, just check them all.
                     for (vf_index, variant_field) in variant.fields.iter().enumerate() {
                         let field = fields.iter().find(|f| {
-                            self.tcx.field_index(f.id, self.tables) == vf_index
+                            self.tcx.field_index(f.hir_id, self.tables) == vf_index
                         });
                         let (use_ctxt, span) = match field {
                             Some(field) => (field.ident.span, field.span),
@@ -883,7 +884,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
                 } else {
                     for field in fields {
                         let use_ctxt = field.ident.span;
-                        let index = self.tcx.field_index(field.id, self.tables);
+                        let index = self.tcx.field_index(field.hir_id, self.tables);
                         self.check_field(use_ctxt, field.span, adt, &variant.fields[index]);
                     }
                 }
@@ -902,7 +903,7 @@ fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
                 let variant = adt.variant_of_def(def);
                 for field in fields {
                     let use_ctxt = field.node.ident.span;
-                    let index = self.tcx.field_index(field.node.id, self.tables);
+                    let index = self.tcx.field_index(field.node.hir_id, self.tables);
                     self.check_field(use_ctxt, field.span, adt, &variant.fields[index]);
                 }
             }
index 187ebf0bc4304207bb32bfe4dde2c66c603e9f82..b82aee7c96ad296caa5b8ec2df951ac9405939f1 100644 (file)
@@ -1517,7 +1517,8 @@ fn visit_expr(&mut self, ex: &'l ast::Expr) {
                         return;
                     }
                 };
-                let def = self.save_ctxt.get_path_def(hir_expr.id);
+                let node_id = self.save_ctxt.tcx.hir().hir_to_node_id(hir_expr.hir_id);
+                let def = self.save_ctxt.get_path_def(node_id);
                 self.process_struct_lit(ex, path, fields, adt.variant_of_def(def), base)
             }
             ast::ExprKind::MethodCall(ref seg, ref args) => self.process_method_call(ex, seg, args),
index 9dfd19199bac7b0a6b8989c020e03bf31fafe44e..e5ab7ba1de946b07f1d365e9a1a5ec83d28e8cac 100644 (file)
@@ -885,7 +885,7 @@ fn ast_type_binding_to_poly_projection_predicate(
             let msg = format!("associated type `{}` is private", binding.item_name);
             tcx.sess.span_err(binding.span, &msg);
         }
-        tcx.check_stability(assoc_ty.def_id, Some(ref_id), binding.span);
+        tcx.check_stability(assoc_ty.def_id, Some(hir_ref_id), binding.span);
 
         if !speculative {
             dup_bindings.entry(assoc_ty.def_id)
@@ -1276,7 +1276,6 @@ pub fn associated_path_to_ty(
     ) -> (Ty<'tcx>, Def) {
         let tcx = self.tcx();
         let assoc_ident = assoc_segment.ident;
-        let ref_id = tcx.hir().hir_to_node_id(hir_ref_id);
 
         debug!("associated_path_to_ty: {:?}::{}", qself_ty, assoc_ident);
 
@@ -1293,7 +1292,7 @@ pub fn associated_path_to_ty(
                     let def = Def::Variant(variant_def.did);
                     if permit_variants {
                         check_type_alias_enum_variants_enabled(tcx, span);
-                        tcx.check_stability(variant_def.did, Some(ref_id), span);
+                        tcx.check_stability(variant_def.did, Some(hir_ref_id), span);
                         return (qself_ty, def);
                     } else {
                         variant_resolution = Some(def);
@@ -1385,7 +1384,7 @@ pub fn associated_path_to_ty(
             let msg = format!("{} `{}` is private", def.kind_name(), assoc_ident);
             tcx.sess.span_err(span, &msg);
         }
-        tcx.check_stability(item.def_id, Some(ref_id), span);
+        tcx.check_stability(item.def_id, Some(hir_ref_id), span);
 
         if let Some(variant_def) = variant_resolution {
             let mut err = tcx.struct_span_lint_hir(
index 0e6ab5b1eb3b20621973fc0e8e1f4f2474b46b0a..7c53cb05391cce3ce099b4ce6e070c5304695fb3 100644 (file)
@@ -64,7 +64,7 @@ pub fn check_pat_walk(
                 }
             }
             PatKind::Path(ref qpath) => {
-                let (def, _, _) = self.resolve_ty_and_def_ufcs(qpath, pat.id, pat.span);
+                let (def, _, _) = self.resolve_ty_and_def_ufcs(qpath, pat.hir_id, pat.span);
                 match def {
                     Def::Const(..) | Def::AssociatedConst(..) => false,
                     _ => true,
@@ -630,7 +630,7 @@ pub fn check_match(
 
         if self.diverges.get().always() {
             for arm in arms {
-                self.warn_if_unreachable(arm.body.id, arm.body.span, "arm");
+                self.warn_if_unreachable(arm.body.hir_id, arm.body.span, "arm");
             }
         }
 
@@ -725,7 +725,7 @@ pub fn check_match(
                 let cause = if i == 0 {
                     // The reason for the first arm to fail is not that the match arms diverge,
                     // but rather that there's a prior obligation that doesn't hold.
-                    self.cause(arm_span, ObligationCauseCode::BlockTailExpression(arm.body.id))
+                    self.cause(arm_span, ObligationCauseCode::BlockTailExpression(arm.body.hir_id))
                 } else {
                     self.cause(expr.span, ObligationCauseCode::MatchExpressionArm {
                         arm_span,
@@ -761,7 +761,8 @@ fn check_pat_struct(
     ) -> Ty<'tcx>
     {
         // Resolve the path and check the definition for errors.
-        let (variant, pat_ty) = if let Some(variant_ty) = self.check_struct_path(qpath, pat.id) {
+        let (variant, pat_ty) = if let Some(variant_ty) = self.check_struct_path(qpath, pat.hir_id)
+        {
             variant_ty
         } else {
             for field in fields {
@@ -779,7 +780,8 @@ fn check_pat_struct(
         self.demand_eqtype_pat(pat.span, expected, pat_ty, match_discrim_span);
 
         // Type-check subpatterns.
-        if self.check_struct_pat_fields(pat_ty, pat.id, pat.span, variant, fields, etc, def_bm) {
+        if self.check_struct_pat_fields(pat_ty, pat.hir_id, pat.span, variant, fields, etc, def_bm)
+        {
             pat_ty
         } else {
             self.tcx.types.err
@@ -795,7 +797,7 @@ fn check_pat_path(
         let tcx = self.tcx;
 
         // Resolve the path and check the definition for errors.
-        let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.id, pat.span);
+        let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.hir_id, pat.span);
         match def {
             Def::Err => {
                 self.set_tainted_by_errors();
@@ -818,7 +820,7 @@ fn check_pat_path(
         }
 
         // Type-check the path.
-        let pat_ty = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.id).0;
+        let pat_ty = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.hir_id).0;
         self.demand_suptype(pat.span, expected, pat_ty);
         pat_ty
     }
@@ -849,7 +851,7 @@ fn check_pat_tuple_struct(
         };
 
         // Resolve the path and check the definition for errors.
-        let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.id, pat.span);
+        let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.hir_id, pat.span);
         if def == Def::Err {
             self.set_tainted_by_errors();
             on_error();
@@ -857,7 +859,8 @@ fn check_pat_tuple_struct(
         }
 
         // Type-check the path.
-        let (pat_ty, def) = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.id);
+        let (pat_ty, def) = self.instantiate_value_path(segments, opt_ty, def, pat.span,
+            pat.hir_id);
         if !pat_ty.is_fn() {
             report_unexpected_def(def);
             return self.tcx.types.err;
@@ -897,7 +900,7 @@ fn check_pat_tuple_struct(
                 let field_ty = self.field_ty(subpat.span, &variant.fields[i], substs);
                 self.check_pat_walk(&subpat, field_ty, def_bm, match_arm_pat_span);
 
-                self.tcx.check_stability(variant.fields[i].did, Some(pat.id), subpat.span);
+                self.tcx.check_stability(variant.fields[i].did, Some(pat.hir_id), subpat.span);
             }
         } else {
             let subpats_ending = if subpats.len() == 1 { "" } else { "s" };
@@ -917,7 +920,7 @@ fn check_pat_tuple_struct(
 
     fn check_struct_pat_fields(&self,
                                adt_ty: Ty<'tcx>,
-                               pat_id: ast::NodeId,
+                               pat_id: hir::HirId,
                                span: Span,
                                variant: &'tcx ty::VariantDef,
                                fields: &'gcx [Spanned<hir::FieldPat>],
@@ -963,7 +966,7 @@ fn check_struct_pat_fields(&self,
                     vacant.insert(span);
                     field_map.get(&ident)
                         .map(|(i, f)| {
-                            self.write_field_index(field.id, *i);
+                            self.write_field_index(field.hir_id, *i);
                             self.tcx.check_stability(f.did, Some(pat_id), span);
                             self.field_ty(span, f, substs)
                         })
index 1bbb93b4e461da7a43cf1d29112315485c473bf4..79dcb9a9305cd8374c1928a8acb62e6a41924753 100644 (file)
@@ -250,7 +250,7 @@ fn confirm_builtin_call(
                 if let &ty::Adt(adt_def, ..) = t {
                     if adt_def.is_enum() {
                         if let hir::ExprKind::Call(ref expr, _) = call_expr.node {
-                            unit_variant = Some(self.tcx.hir().node_to_pretty_string(expr.id))
+                            unit_variant = Some(self.tcx.hir().hir_to_pretty_string(expr.hir_id))
                         }
                     }
                 }
index 317d6bbd78592baa6334345e8d83bedc0ac9f177..97ee973938ccbbe1e1d4b2d664ea069bbf55f600 100644 (file)
@@ -399,9 +399,9 @@ fn trivial_cast_lint(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) {
         } else {
             ("", lint::builtin::TRIVIAL_CASTS)
         };
-        let mut err = fcx.tcx.struct_span_lint_node(
+        let mut err = fcx.tcx.struct_span_lint_hir(
             lint,
-            self.expr.id,
+            self.expr.hir_id,
             self.span,
             &format!("trivial {}cast: `{}` as `{}`",
                      adjective,
@@ -417,7 +417,7 @@ pub fn check(mut self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) {
         self.cast_ty = fcx.structurally_resolved_type(self.span, self.cast_ty);
 
         debug!("check_cast({}, {:?} as {:?})",
-               self.expr.id,
+               self.expr.hir_id,
                self.expr_ty,
                self.cast_ty);
 
index f602ed24acd4e14ff98d0d9b6cd20cb9e03d00d1..5cf767abfc512a71d6ecc89b25dadd347decc625 100644 (file)
@@ -72,7 +72,7 @@ fn check_closure(
             opt_kind, expected_sig
         );
 
-        let expr_def_id = self.tcx.hir().local_def_id(expr.id);
+        let expr_def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
 
         let ClosureSignatures {
             bound_sig,
@@ -131,8 +131,8 @@ fn check_closure(
         let closure_type = self.tcx.mk_closure(expr_def_id, substs);
 
         debug!(
-            "check_closure: expr.id={:?} closure_type={:?}",
-            expr.id, closure_type
+            "check_closure: expr.hir_id={:?} closure_type={:?}",
+            expr.hir_id, closure_type
         );
 
         // Tuple up the arguments and insert the resulting function type into
index 90071e3f3634ad084b37e481f7b9a9725fcf9426..62c6ab8da24a053e13a8f7d68da9ab8b7fbe1531 100644 (file)
@@ -1177,7 +1177,8 @@ fn coerce_inner<'a>(&mut self,
                         Expressions::UpFront(coercion_sites) => {
                             // if the user gave us an array to validate, check that we got
                             // the next expression in the list, as expected
-                            assert_eq!(coercion_sites[self.pushed].as_coercion_site().id, e.id);
+                            assert_eq!(coercion_sites[self.pushed].as_coercion_site().hir_id,
+                                       e.hir_id);
                         }
                     }
                     self.pushed += 1;
@@ -1208,7 +1209,7 @@ fn coerce_inner<'a>(&mut self,
                         db.span_label(cause.span, "return type is not `()`");
                     }
                     ObligationCauseCode::BlockTailExpression(blk_id) => {
-                        let parent_id = fcx.tcx.hir().get_parent_node(blk_id);
+                        let parent_id = fcx.tcx.hir().get_parent_node_by_hir_id(blk_id);
                         db = self.report_return_mismatched_types(
                             cause,
                             expected,
@@ -1246,8 +1247,8 @@ fn report_return_mismatched_types<'a>(
         found: Ty<'tcx>,
         err: TypeError<'tcx>,
         fcx: &FnCtxt<'a, 'gcx, 'tcx>,
-        id: syntax::ast::NodeId,
-        expression: Option<(&'gcx hir::Expr, syntax::ast::NodeId)>,
+        id: hir::HirId,
+        expression: Option<(&'gcx hir::Expr, hir::HirId)>,
     ) -> DiagnosticBuilder<'a> {
         let mut db = fcx.report_mismatched_types(cause, expected, found, err);
 
@@ -1257,7 +1258,7 @@ fn report_return_mismatched_types<'a>(
         // Verify that this is a tail expression of a function, otherwise the
         // label pointing out the cause for the type coercion will be wrong
         // as prior return coercions would not be relevant (#57664).
-        let parent_id = fcx.tcx.hir().get_parent_node(id);
+        let parent_id = fcx.tcx.hir().get_parent_node_by_hir_id(id);
         let fn_decl = if let Some((expr, blk_id)) = expression {
             pointing_at_return_type = fcx.suggest_mismatched_types_on_tail(
                 &mut db,
@@ -1267,7 +1268,7 @@ fn report_return_mismatched_types<'a>(
                 cause.span,
                 blk_id,
             );
-            let parent = fcx.tcx.hir().get(parent_id);
+            let parent = fcx.tcx.hir().get_by_hir_id(parent_id);
             fcx.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
         } else {
             fcx.get_fn_decl(parent_id)
index 8b80fba4d19d01e096b72c3d5a033a5f9c442f09..ac794c3d6f34deeea9f3cf83632861c51667573e 100644 (file)
@@ -2,7 +2,6 @@
 use rustc::infer::InferOk;
 use rustc::traits::{ObligationCause, ObligationCauseCode};
 
-use syntax::ast;
 use syntax::util::parser::PREC_POSTFIX;
 use syntax_pos::Span;
 use rustc::hir;
@@ -164,7 +163,7 @@ pub fn get_conversion_methods(&self, span: Span, expected: Ty<'tcx>, checked_ty:
                                                      probe::Mode::MethodCall,
                                                      expected,
                                                      checked_ty,
-                                                     ast::DUMMY_NODE_ID);
+                                                     hir::DUMMY_HIR_ID);
         methods.retain(|m| {
             self.has_no_input_arg(m) &&
                 self.tcx.get_attrs(m.def_id).iter()
@@ -218,15 +217,15 @@ fn can_use_as_ref(
             if let hir::def::Def::Local(id) = path.def {
                 let parent = self.tcx.hir().get_parent_node(id);
                 if let Some(Node::Expr(hir::Expr {
-                    id,
+                    hir_id,
                     node: hir::ExprKind::Closure(_, decl, ..),
                     ..
                 })) = self.tcx.hir().find(parent) {
-                    let parent = self.tcx.hir().get_parent_node(*id);
+                    let parent = self.tcx.hir().get_parent_node_by_hir_id(*hir_id);
                     if let (Some(Node::Expr(hir::Expr {
                         node: hir::ExprKind::MethodCall(path, span, expr),
                         ..
-                    })), 1) = (self.tcx.hir().find(parent), decl.inputs.len()) {
+                    })), 1) = (self.tcx.hir().find_by_hir_id(parent), decl.inputs.len()) {
                         let self_ty = self.tables.borrow().node_type(expr[0].hir_id);
                         let self_ty = format!("{:?}", self_ty);
                         let name = path.ident.as_str();
@@ -470,8 +469,8 @@ pub fn check_for_cast(
         checked_ty: Ty<'tcx>,
         expected_ty: Ty<'tcx>,
     ) -> bool {
-        let parent_id = self.tcx.hir().get_parent_node(expr.id);
-        if let Some(parent) = self.tcx.hir().find(parent_id) {
+        let parent_id = self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
+        if let Some(parent) = self.tcx.hir().find_by_hir_id(parent_id) {
             // Shouldn't suggest `.into()` on `const`s.
             if let Node::Item(Item { node: ItemKind::Const(_, _), .. }) = parent {
                 // FIXME(estebank): modify once we decide to suggest `as` casts
@@ -501,10 +500,10 @@ pub fn check_for_cast(
         if let Some(hir::Node::Expr(hir::Expr {
             node: hir::ExprKind::Struct(_, fields, _),
             ..
-        })) = self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.id)) {
+        })) = self.tcx.hir().find_by_hir_id(self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id)) {
             // `expr` is a literal field for a struct, only suggest if appropriate
             for field in fields {
-                if field.expr.id == expr.id && field.is_shorthand {
+                if field.expr.hir_id == expr.hir_id && field.is_shorthand {
                     // This is a field literal
                     prefix = format!("{}: ", field.ident);
                     break;
index 259a28645815f7f1f0f95c5f2981b51e6d892fa5..b14c56ddad008fa03c9ed1c0bb347f1490b918f3 100644 (file)
@@ -105,7 +105,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
     pub fn method_exists(&self,
                          method_name: ast::Ident,
                          self_ty: Ty<'tcx>,
-                         call_expr_id: ast::NodeId,
+                         call_expr_id: hir::HirId,
                          allow_private: bool)
                          -> bool {
         let mode = probe::Mode::MethodCall;
@@ -131,7 +131,7 @@ pub fn method_exists(&self,
         msg: &str,
         method_name: ast::Ident,
         self_ty: Ty<'tcx>,
-        call_expr_id: ast::NodeId,
+        call_expr_id: hir::HirId,
     ) {
         let has_params = self
             .probe_for_name(
@@ -202,7 +202,7 @@ pub fn lookup_method(&self,
                 .unwrap().insert(import_def_id);
         }
 
-        self.tcx.check_stability(pick.item.def_id, Some(call_expr.id), span);
+        self.tcx.check_stability(pick.item.def_id, Some(call_expr.hir_id), span);
 
         let result = self.confirm_method(
             span,
@@ -255,7 +255,7 @@ fn lookup_probe(&self,
         let mode = probe::Mode::MethodCall;
         let self_ty = self.resolve_type_vars_if_possible(&self_ty);
         self.probe_for_name(span, mode, method_name, IsSuggestion(false),
-                            self_ty, call_expr.id, scope)
+                            self_ty, call_expr.hir_id, scope)
     }
 
     /// `lookup_method_in_trait` is used for overloaded operators.
@@ -399,7 +399,7 @@ pub fn resolve_ufcs(
         span: Span,
         method_name: ast::Ident,
         self_ty: Ty<'tcx>,
-        expr_id: ast::NodeId
+        expr_id: hir::HirId
     ) -> Result<Def, MethodError<'tcx>> {
         debug!(
             "resolve_ufcs: method_name={:?} self_ty={:?} expr_id={:?}",
index 709177212ada7409e2824b367f9684cf9790d400..c6116d58c1e7f00ec9ff2358966853699c67d00b 100644 (file)
@@ -209,7 +209,7 @@ pub fn probe_for_return_type(&self,
                                  mode: Mode,
                                  return_type: Ty<'tcx>,
                                  self_ty: Ty<'tcx>,
-                                 scope_expr_id: ast::NodeId)
+                                 scope_expr_id: hir::HirId)
                                  -> Vec<ty::AssociatedItem> {
         debug!("probe(self_ty={:?}, return_type={}, scope_expr_id={})",
                self_ty,
@@ -238,7 +238,7 @@ pub fn probe_for_name(&self,
                           item_name: ast::Ident,
                           is_suggestion: IsSuggestion,
                           self_ty: Ty<'tcx>,
-                          scope_expr_id: ast::NodeId,
+                          scope_expr_id: hir::HirId,
                           scope: ProbeScope)
                           -> PickResult<'tcx> {
         debug!("probe(self_ty={:?}, item_name={}, scope_expr_id={})",
@@ -263,7 +263,7 @@ fn probe_op<OP,R>(&'a self,
                       return_type: Option<Ty<'tcx>>,
                       is_suggestion: IsSuggestion,
                       self_ty: Ty<'tcx>,
-                      scope_expr_id: ast::NodeId,
+                      scope_expr_id: hir::HirId,
                       scope: ProbeScope,
                       op: OP)
                       -> Result<R, MethodError<'tcx>>
@@ -340,7 +340,7 @@ fn probe_op<OP,R>(&'a self,
                               "the type of this value must be known \
                                to call a method on a raw pointer on it");
                 } else {
-                   self.tcx.lint_node(
+                   self.tcx.lint_hir(
                         lint::builtin::TYVAR_BEHIND_RAW_POINTER,
                         scope_expr_id,
                         span,
@@ -825,13 +825,12 @@ fn elaborate_bounds<F>(&mut self,
     }
 
     fn assemble_extension_candidates_for_traits_in_scope(&mut self,
-                                                         expr_id: ast::NodeId)
+                                                         expr_hir_id: hir::HirId)
                                                          -> Result<(), MethodError<'tcx>> {
-        if expr_id == ast::DUMMY_NODE_ID {
+        if expr_hir_id == hir::DUMMY_HIR_ID {
             return Ok(())
         }
         let mut duplicates = FxHashSet::default();
-        let expr_hir_id = self.tcx.hir().node_to_hir_id(expr_id);
         let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id);
         if let Some(applicable_traits) = opt_applicable_traits {
             for trait_candidate in applicable_traits.iter() {
@@ -1415,7 +1414,7 @@ fn probe_for_lev_candidate(&mut self) -> Result<Option<ty::AssociatedItem>, Meth
                                             steps, IsSuggestion(true));
             pcx.allow_similar_names = true;
             pcx.assemble_inherent_candidates();
-            pcx.assemble_extension_candidates_for_traits_in_scope(ast::DUMMY_NODE_ID)?;
+            pcx.assemble_extension_candidates_for_traits_in_scope(hir::DUMMY_HIR_ID)?;
 
             let method_names = pcx.candidate_method_names();
             pcx.allow_similar_names = false;
@@ -1425,7 +1424,7 @@ fn probe_for_lev_candidate(&mut self) -> Result<Option<ty::AssociatedItem>, Meth
                     pcx.reset();
                     pcx.method_name = Some(method_name);
                     pcx.assemble_inherent_candidates();
-                    pcx.assemble_extension_candidates_for_traits_in_scope(ast::DUMMY_NODE_ID)
+                    pcx.assemble_extension_candidates_for_traits_in_scope(hir::DUMMY_HIR_ID)
                         .ok().map_or(None, |_| {
                             pcx.pick_core()
                                 .and_then(|pick| pick.ok())
index 61fc58ec86182f25f713315e457b9195edfe46d9..0ff3b613fe7a99403e70800e7f7da10c342ddb72 100644 (file)
 use crate::lint;
 use crate::util::captures::Captures;
 use crate::util::common::{ErrorReported, indenter};
-use crate::util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, NodeMap};
+use crate::util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, HirIdMap, NodeMap};
 
 pub use self::Expectation::*;
 use self::autoderef::Autoderef;
@@ -497,11 +497,11 @@ pub struct BreakableCtxt<'gcx: 'tcx, 'tcx> {
 
 pub struct EnclosingBreakables<'gcx: 'tcx, 'tcx> {
     stack: Vec<BreakableCtxt<'gcx, 'tcx>>,
-    by_id: NodeMap<usize>,
+    by_id: HirIdMap<usize>,
 }
 
 impl<'gcx, 'tcx> EnclosingBreakables<'gcx, 'tcx> {
-    fn find_breakable(&mut self, target_id: ast::NodeId) -> &mut BreakableCtxt<'gcx, 'tcx> {
+    fn find_breakable(&mut self, target_id: hir::HirId) -> &mut BreakableCtxt<'gcx, 'tcx> {
         let ix = *self.by_id.get(&target_id).unwrap_or_else(|| {
             bug!("could not find enclosing breakable with id {}", target_id);
         });
@@ -2049,13 +2049,13 @@ pub fn err_count_since_creation(&self) -> usize {
 
     /// Produces warning on the given node, if the current point in the
     /// function is unreachable, and there hasn't been another warning.
-    fn warn_if_unreachable(&self, id: ast::NodeId, span: Span, kind: &str) {
+    fn warn_if_unreachable(&self, id: hir::HirId, span: Span, kind: &str) {
         if self.diverges.get() == Diverges::Always {
             self.diverges.set(Diverges::WarnedAlways);
 
             debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind);
 
-            self.tcx().lint_node(
+            self.tcx().lint_hir(
                 lint::builtin::UNREACHABLE_CODE,
                 id, span,
                 &format!("unreachable {}", kind));
@@ -2143,8 +2143,7 @@ pub fn write_ty(&self, id: hir::HirId, ty: Ty<'tcx>) {
         }
     }
 
-    pub fn write_field_index(&self, node_id: ast::NodeId, index: usize) {
-        let hir_id = self.tcx.hir().node_to_hir_id(node_id);
+    pub fn write_field_index(&self, hir_id: hir::HirId, index: usize) {
         self.tables.borrow_mut().field_indices_mut().insert(hir_id, index);
     }
 
@@ -3007,7 +3006,7 @@ fn check_argument_types(&self,
                 // Closure arguments themselves can't be diverging, but
                 // a previous argument can, e.g., `foo(panic!(), || {})`.
                 if !check_closures {
-                    self.warn_if_unreachable(arg.id, arg.span, "expression");
+                    self.warn_if_unreachable(arg.hir_id, arg.span, "expression");
                 }
 
                 let is_closure = match arg.node {
@@ -3338,7 +3337,7 @@ fn check_return_expr(&self, return_expr: &'gcx hir::Expr) {
         ret_coercion.borrow_mut()
                     .coerce(self,
                             &self.cause(return_expr.span,
-                                        ObligationCauseCode::ReturnType(return_expr.id)),
+                                        ObligationCauseCode::ReturnType(return_expr.hir_id)),
                             return_expr,
                             return_expr_ty);
     }
@@ -3509,13 +3508,13 @@ fn check_field(&self,
                         let field_ty = self.field_ty(expr.span, field, substs);
                         // Save the index of all fields regardless of their visibility in case
                         // of error recovery.
-                        self.write_field_index(expr.id, index);
+                        self.write_field_index(expr.hir_id, index);
                         if field.vis.is_accessible_from(def_scope, self.tcx) {
                             let adjustments = autoderef.adjust_steps(self, needs);
                             self.apply_adjustments(base, adjustments);
                             autoderef.finalize(self);
 
-                            self.tcx.check_stability(field.did, Some(expr.id), expr.span);
+                            self.tcx.check_stability(field.did, Some(expr.hir_id), expr.span);
                             return field_ty;
                         }
                         private_candidate = Some((base_def.did, field_ty));
@@ -3530,7 +3529,7 @@ fn check_field(&self,
                                 self.apply_adjustments(base, adjustments);
                                 autoderef.finalize(self);
 
-                                self.write_field_index(expr.id, index);
+                                self.write_field_index(expr.hir_id, index);
                                 return field_ty;
                             }
                         }
@@ -3547,31 +3546,33 @@ fn check_field(&self,
                                            "field `{}` of struct `{}` is private",
                                            field, struct_path);
             // Also check if an accessible method exists, which is often what is meant.
-            if self.method_exists(field, expr_t, expr.id, false) && !self.expr_in_place(expr.id) {
+            if self.method_exists(field, expr_t, expr.hir_id, false)
+                && !self.expr_in_place(expr.hir_id)
+            {
                 self.suggest_method_call(
                     &mut err,
                     &format!("a method `{}` also exists, call it with parentheses", field),
                     field,
                     expr_t,
-                    expr.id,
+                    expr.hir_id,
                 );
             }
             err.emit();
             field_ty
         } else if field.name == keywords::Invalid.name() {
             self.tcx().types.err
-        } else if self.method_exists(field, expr_t, expr.id, true) {
+        } else if self.method_exists(field, expr_t, expr.hir_id, true) {
             let mut err = type_error_struct!(self.tcx().sess, field.span, expr_t, E0615,
                                "attempted to take value of method `{}` on type `{}`",
                                field, expr_t);
 
-            if !self.expr_in_place(expr.id) {
+            if !self.expr_in_place(expr.hir_id) {
                 self.suggest_method_call(
                     &mut err,
                     "use parentheses to call the method",
                     field,
                     expr_t,
-                    expr.id
+                    expr.hir_id
                 );
             } else {
                 err.help("methods are immutable and cannot be assigned to");
@@ -3611,7 +3612,8 @@ fn check_field(&self,
                         ) {
                             let base = self.tcx.sess.source_map()
                                 .span_to_snippet(base.span)
-                                .unwrap_or_else(|_| self.tcx.hir().node_to_pretty_string(base.id));
+                                .unwrap_or_else(|_|
+                                    self.tcx.hir().hir_to_pretty_string(base.hir_id));
                             let help = "instead of using tuple indexing, use array indexing";
                             let suggestion = format!("{}[{}]", base, field);
                             let applicability = if len < user_index {
@@ -3627,7 +3629,7 @@ fn check_field(&self,
                     ty::RawPtr(..) => {
                         let base = self.tcx.sess.source_map()
                             .span_to_snippet(base.span)
-                            .unwrap_or_else(|_| self.tcx.hir().node_to_pretty_string(base.id));
+                            .unwrap_or_else(|_| self.tcx.hir().hir_to_pretty_string(base.hir_id));
                         let msg = format!("`{}` is a raw pointer; try dereferencing it", base);
                         let suggestion = format!("(*{}).{}", base, field);
                         err.span_suggestion(
@@ -3752,7 +3754,7 @@ fn report_unknown_field(&self,
     fn check_expr_struct_fields(&self,
                                 adt_ty: Ty<'tcx>,
                                 expected: Expectation<'tcx>,
-                                expr_id: ast::NodeId,
+                                expr_id: hir::HirId,
                                 span: Span,
                                 variant: &'tcx ty::VariantDef,
                                 ast_fields: &'gcx [hir::Field],
@@ -3785,7 +3787,7 @@ fn check_expr_struct_fields(&self,
             let ident = tcx.adjust_ident(field.ident, variant.did, self.body_id).0;
             let field_type = if let Some((i, v_field)) = remaining_fields.remove(&ident) {
                 seen_fields.insert(ident, field.span);
-                self.write_field_index(field.id, i);
+                self.write_field_index(field.hir_id, i);
 
                 // We don't look at stability attributes on
                 // struct-like enums (yet...), but it's definitely not
@@ -3873,13 +3875,13 @@ fn check_struct_fields_on_error(&self,
 
     pub fn check_struct_path(&self,
                              qpath: &QPath,
-                             node_id: ast::NodeId)
+                             hir_id: hir::HirId)
                              -> Option<(&'tcx ty::VariantDef,  Ty<'tcx>)> {
         let path_span = match *qpath {
             QPath::Resolved(_, ref path) => path.span,
             QPath::TypeRelative(ref qself, _) => qself.span
         };
-        let (def, ty) = self.finish_resolving_struct_path(qpath, path_span, node_id);
+        let (def, ty) = self.finish_resolving_struct_path(qpath, path_span, hir_id);
         let variant = match def {
             Def::Err => {
                 self.set_tainted_by_errors();
@@ -3907,7 +3909,6 @@ pub fn check_struct_path(&self,
 
         if let Some((variant, did, substs)) = variant {
             debug!("check_struct_path: did={:?} substs={:?}", did, substs);
-            let hir_id = self.tcx.hir().node_to_hir_id(node_id);
             self.write_user_type_annotation_from_substs(hir_id, did, substs, None);
 
             // Check bounds on type arguments used in the path.
@@ -3936,7 +3937,7 @@ fn check_expr_struct(&self,
     {
         // Find the relevant variant
         let (variant, adt_ty) =
-            if let Some(variant_ty) = self.check_struct_path(qpath, expr.id) {
+            if let Some(variant_ty) = self.check_struct_path(qpath, expr.hir_id) {
                 variant_ty
             } else {
                 self.check_struct_fields_on_error(fields, base_expr);
@@ -3956,7 +3957,7 @@ fn check_expr_struct(&self,
                       adt.variant_descr());
         }
 
-        let error_happened = self.check_expr_struct_fields(adt_ty, expected, expr.id, path_span,
+        let error_happened = self.check_expr_struct_fields(adt_ty, expected, expr.hir_id, path_span,
                                                            variant, fields, base_expr.is_none());
         if let &Some(ref base_expr) = base_expr {
             // If check_expr_struct_fields hit an error, do not attempt to populate
@@ -4005,7 +4006,7 @@ fn check_expr_with_expectation_and_needs(&self,
                expr, expected);
 
         // Warn for expressions after diverging siblings.
-        self.warn_if_unreachable(expr.id, expr.span, "expression");
+        self.warn_if_unreachable(expr.hir_id, expr.span, "expression");
 
         // Hide the outer diverging and has_errors flags.
         let old_diverges = self.diverges.get();
@@ -4021,7 +4022,7 @@ fn check_expr_with_expectation_and_needs(&self,
             ExprKind::Loop(..) | ExprKind::While(..) |
             ExprKind::If(..) | ExprKind::Match(..) => {}
 
-            _ => self.warn_if_unreachable(expr.id, expr.span, "expression")
+            _ => self.warn_if_unreachable(expr.hir_id, expr.span, "expression")
         }
 
         // Any expression that produces a value of type `!` must have diverged
@@ -4038,7 +4039,7 @@ fn check_expr_with_expectation_and_needs(&self,
         self.diverges.set(self.diverges.get() | old_diverges);
         self.has_errors.set(self.has_errors.get() | old_has_errors);
 
-        debug!("type of {} is...", self.tcx.hir().node_to_string(expr.id));
+        debug!("type of {} is...", self.tcx.hir().hir_to_string(expr.hir_id));
         debug!("... {:?}, expected is {:?}", ty, expected);
 
         ty
@@ -4058,7 +4059,7 @@ fn check_expr_kind(
         );
 
         let tcx = self.tcx;
-        let id = expr.id;
+        let id = expr.hir_id;
         match expr.node {
             ExprKind::Box(ref subexpr) => {
                 let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| {
@@ -4190,7 +4191,8 @@ fn check_expr_kind(
                 }
             }
             ExprKind::Path(ref qpath) => {
-                let (def, opt_ty, segs) = self.resolve_ty_and_def_ufcs(qpath, expr.id, expr.span);
+                let (def, opt_ty, segs) = self.resolve_ty_and_def_ufcs(qpath, expr.hir_id,
+                    expr.span);
                 let ty = match def {
                     Def::Err => {
                         self.set_tainted_by_errors();
@@ -4255,6 +4257,7 @@ fn check_expr_kind(
             }
             ExprKind::Break(destination, ref expr_opt) => {
                 if let Ok(target_id) = destination.target_id {
+                    let target_id = tcx.hir().node_to_hir_id(target_id);
                     let (e_ty, cause);
                     if let Some(ref e) = *expr_opt {
                         // If this is a break with a value, we need to type-check
@@ -4360,7 +4363,7 @@ fn check_expr_kind(
                         *self.ret_coercion_span.borrow_mut() = Some(expr.span);
                     }
                     let cause = self.cause(expr.span, ObligationCauseCode::ReturnNoExpression);
-                    if let Some((fn_decl, _)) = self.get_fn_decl(expr.id) {
+                    if let Some((fn_decl, _)) = self.get_fn_decl(expr.hir_id) {
                         coercion.coerce_forced_unit(
                             self,
                             &cause,
@@ -4422,7 +4425,7 @@ fn check_expr_kind(
                     may_break: false,  // Will get updated if/when we find a `break`.
                 };
 
-                let (ctxt, ()) = self.with_breakable_ctxt(expr.id, ctxt, || {
+                let (ctxt, ()) = self.with_breakable_ctxt(expr.hir_id, ctxt, || {
                     self.check_expr_has_type_or_error(&cond, tcx.types.bool);
                     let cond_diverging = self.diverges.get();
                     self.check_block_no_value(&body);
@@ -4458,7 +4461,7 @@ fn check_expr_kind(
                     may_break: false, // Will get updated if/when we find a `break`.
                 };
 
-                let (ctxt, ()) = self.with_breakable_ctxt(expr.id, ctxt, || {
+                let (ctxt, ()) = self.with_breakable_ctxt(expr.hir_id, ctxt, || {
                     self.check_block_no_value(&body);
                 });
 
@@ -4715,7 +4718,7 @@ fn check_expr_kind(
     fn finish_resolving_struct_path(&self,
                                     qpath: &QPath,
                                     path_span: Span,
-                                    node_id: ast::NodeId)
+                                    hir_id: hir::HirId)
                                     -> (Def, Ty<'tcx>)
     {
         match *qpath {
@@ -4732,12 +4735,10 @@ fn finish_resolving_struct_path(&self,
                 } else {
                     Def::Err
                 };
-                let hir_id = self.tcx.hir().node_to_hir_id(node_id);
                 let (ty, def) = AstConv::associated_path_to_ty(self, hir_id, path_span,
                                                                ty, def, segment, true);
 
                 // Write back the new resolution.
-                let hir_id = self.tcx.hir().node_to_hir_id(node_id);
                 self.tables.borrow_mut().type_dependent_defs_mut().insert(hir_id, def);
 
                 (def, ty)
@@ -4749,11 +4750,11 @@ fn finish_resolving_struct_path(&self,
     /// definition. The newly resolved definition is written into `type_dependent_defs`.
     pub fn resolve_ty_and_def_ufcs<'b>(&self,
                                        qpath: &'b QPath,
-                                       node_id: ast::NodeId,
+                                       hir_id: hir::HirId,
                                        span: Span)
                                        -> (Def, Option<Ty<'tcx>>, &'b [hir::PathSegment])
     {
-        debug!("resolve_ty_and_def_ufcs: qpath={:?} node_id={:?} span={:?}", qpath, node_id, span);
+        debug!("resolve_ty_and_def_ufcs: qpath={:?} hir_id={:?} span={:?}", qpath, hir_id, span);
         let (ty, qself, item_segment) = match *qpath {
             QPath::Resolved(ref opt_qself, ref path) => {
                 return (path.def,
@@ -4764,14 +4765,13 @@ pub fn resolve_ty_and_def_ufcs<'b>(&self,
                 (self.to_ty(qself), qself, segment)
             }
         };
-        let hir_id = self.tcx.hir().node_to_hir_id(node_id);
         if let Some(cached_def) = self.tables.borrow().type_dependent_defs().get(hir_id) {
             // Return directly on cache hit. This is useful to avoid doubly reporting
             // errors with default match binding modes. See #44614.
             return (*cached_def, Some(ty), slice::from_ref(&**item_segment))
         }
         let item_name = item_segment.ident;
-        let def = match self.resolve_ufcs(span, item_name, ty, node_id) {
+        let def = match self.resolve_ufcs(span, item_name, ty, hir_id) {
             Ok(def) => def,
             Err(error) => {
                 let def = match error {
@@ -4853,7 +4853,7 @@ pub fn check_stmt(&self, stmt: &'gcx hir::Stmt) {
             hir::StmtKind::Local(..) | hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {}
         }
 
-        self.warn_if_unreachable(stmt.id, stmt.span, "statement");
+        self.warn_if_unreachable(stmt.hir_id, stmt.span, "statement");
 
         // Hide the outer diverging and `has_errors` flags.
         let old_diverges = self.diverges.get();
@@ -4935,8 +4935,7 @@ fn check_block_with_expected(&self,
             may_break: false,
         };
 
-        let blk_node_id = self.tcx.hir().hir_to_node_id(blk.hir_id);
-        let (ctxt, ()) = self.with_breakable_ctxt(blk_node_id, ctxt, || {
+        let (ctxt, ()) = self.with_breakable_ctxt(blk.hir_id, ctxt, || {
             for s in &blk.stmts {
                 self.check_stmt(s);
             }
@@ -4946,12 +4945,12 @@ fn check_block_with_expected(&self,
             let tail_expr_ty = tail_expr.map(|t| self.check_expr_with_expectation(t, expected));
 
             let mut enclosing_breakables = self.enclosing_breakables.borrow_mut();
-            let ctxt = enclosing_breakables.find_breakable(blk_node_id);
+            let ctxt = enclosing_breakables.find_breakable(blk.hir_id);
             let coerce = ctxt.coerce.as_mut().unwrap();
             if let Some(tail_expr_ty) = tail_expr_ty {
                 let tail_expr = tail_expr.unwrap();
                 let cause = self.cause(tail_expr.span,
-                                       ObligationCauseCode::BlockTailExpression(blk_node_id));
+                                       ObligationCauseCode::BlockTailExpression(blk.hir_id));
                 coerce.coerce(self,
                               &cause,
                               tail_expr,
@@ -4975,6 +4974,7 @@ fn check_block_with_expected(&self,
                     // that highlight errors inline.
                     let mut sp = blk.span;
                     let mut fn_span = None;
+                    let blk_node_id = self.tcx.hir().hir_to_node_id(blk.hir_id);
                     if let Some((decl, ident)) = self.get_parent_fn_decl(blk_node_id) {
                         let ret_sp = decl.output.span();
                         if let Some(block_sp) = self.parent_item_span(blk_node_id) {
@@ -5067,13 +5067,13 @@ fn get_node_fn_decl(&self, node: Node) -> Option<(hir::FnDecl, ast::Ident, bool)
         }
     }
 
-    /// Given a `NodeId`, return the `FnDecl` of the method it is enclosed by and whether a
+    /// Given a `HirId`, return the `FnDecl` of the method it is enclosed by and whether a
     /// suggestion can be made, `None` otherwise.
-    pub fn get_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, bool)> {
+    pub fn get_fn_decl(&self, blk_id: hir::HirId) -> Option<(hir::FnDecl, bool)> {
         // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
         // `while` before reaching it, as block tail returns are not available in them.
         self.tcx.hir().get_return_block(blk_id).and_then(|blk_id| {
-            let parent = self.tcx.hir().get(blk_id);
+            let parent = self.tcx.hir().get_by_hir_id(blk_id);
             self.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
         })
     }
@@ -5090,7 +5090,7 @@ pub fn suggest_mismatched_types_on_tail(
         expected: Ty<'tcx>,
         found: Ty<'tcx>,
         cause_span: Span,
-        blk_id: ast::NodeId,
+        blk_id: hir::HirId,
     ) -> bool {
         self.suggest_missing_semicolon(err, expression, expected, cause_span);
         let mut pointing_at_return_type = false;
@@ -5303,14 +5303,14 @@ pub fn instantiate_value_path(&self,
                                   self_ty: Option<Ty<'tcx>>,
                                   def: Def,
                                   span: Span,
-                                  node_id: ast::NodeId)
+                                  hir_id: hir::HirId)
                                   -> (Ty<'tcx>, Def) {
         debug!(
-            "instantiate_value_path(segments={:?}, self_ty={:?}, def={:?}, node_id={})",
+            "instantiate_value_path(segments={:?}, self_ty={:?}, def={:?}, hir_id={})",
             segments,
             self_ty,
             def,
-            node_id,
+            hir_id,
         );
 
         let tcx = self.tcx;
@@ -5380,7 +5380,7 @@ pub fn instantiate_value_path(&self,
             Def::Local(nid) | Def::Upvar(nid, ..) => {
                 let ty = self.local_ty(span, nid).decl_ty;
                 let ty = self.normalize_associated_types_in(span, &ty);
-                self.write_ty(tcx.hir().node_to_hir_id(node_id), ty);
+                self.write_ty(hir_id, ty);
                 return (ty, def);
             }
             _ => {}
@@ -5532,7 +5532,6 @@ pub fn instantiate_value_path(&self,
         assert!(!ty.has_escaping_bound_vars());
 
         // First, store the "user substs" for later.
-        let hir_id = tcx.hir().node_to_hir_id(node_id);
         self.write_user_type_annotation_from_substs(hir_id, def_id, substs, user_self_ty);
 
         // Add all the obligations that are required, substituting and
@@ -5566,10 +5565,10 @@ pub fn instantiate_value_path(&self,
             }
         }
 
-        self.check_rustc_args_require_const(def_id, node_id, span);
+        self.check_rustc_args_require_const(def_id, hir_id, span);
 
         debug!("instantiate_value_path: type of {:?} is {:?}",
-               node_id,
+               hir_id,
                ty_substituted);
         self.write_substs(hir_id, substs);
 
@@ -5578,7 +5577,7 @@ pub fn instantiate_value_path(&self,
 
     fn check_rustc_args_require_const(&self,
                                       def_id: DefId,
-                                      node_id: ast::NodeId,
+                                      hir_id: hir::HirId,
                                       span: Span) {
         // We're only interested in functions tagged with
         // #[rustc_args_required_const], so ignore anything that's not.
@@ -5588,9 +5587,11 @@ fn check_rustc_args_require_const(&self,
 
         // If our calling expression is indeed the function itself, we're good!
         // If not, generate an error that this can only be called directly.
-        if let Node::Expr(expr) = self.tcx.hir().get(self.tcx.hir().get_parent_node(node_id)) {
+        if let Node::Expr(expr) = self.tcx.hir().get_by_hir_id(
+            self.tcx.hir().get_parent_node_by_hir_id(hir_id))
+        {
             if let ExprKind::Call(ref callee, ..) = expr.node {
-                if callee.id == node_id {
+                if callee.hir_id == hir_id {
                     return
                 }
             }
@@ -5618,7 +5619,7 @@ pub fn structurally_resolved_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
         }
     }
 
-    fn with_breakable_ctxt<F: FnOnce() -> R, R>(&self, id: ast::NodeId,
+    fn with_breakable_ctxt<F: FnOnce() -> R, R>(&self, id: hir::HirId,
                                                 ctxt: BreakableCtxt<'gcx, 'tcx>, f: F)
                                                 -> (BreakableCtxt<'gcx, 'tcx>, R) {
         let index;
@@ -5655,22 +5656,22 @@ fn probe_instantiate_query_response(
     }
 
     /// Returns `true` if an expression is contained inside the LHS of an assignment expression.
-    fn expr_in_place(&self, mut expr_id: ast::NodeId) -> bool {
+    fn expr_in_place(&self, mut expr_id: hir::HirId) -> bool {
         let mut contained_in_place = false;
 
         while let hir::Node::Expr(parent_expr) =
-            self.tcx.hir().get(self.tcx.hir().get_parent_node(expr_id))
+            self.tcx.hir().get_by_hir_id(self.tcx.hir().get_parent_node_by_hir_id(expr_id))
         {
             match &parent_expr.node {
                 hir::ExprKind::Assign(lhs, ..) | hir::ExprKind::AssignOp(_, lhs, ..) => {
-                    if lhs.id == expr_id {
+                    if lhs.hir_id == expr_id {
                         contained_in_place = true;
                         break;
                     }
                 }
                 _ => (),
             }
-            expr_id = parent_expr.id;
+            expr_id = parent_expr.hir_id;
         }
 
         contained_in_place
index 9b1a656b1bc98e48b1cfe495aa802099c3220d3d..284c8d1b7c42756a4c0183293f29997ec59d3c7e 100644 (file)
@@ -51,8 +51,8 @@ pub fn check_binop(&self,
     {
         let tcx = self.tcx;
 
-        debug!("check_binop(expr.id={}, expr={:?}, op={:?}, lhs_expr={:?}, rhs_expr={:?})",
-               expr.id,
+        debug!("check_binop(expr.hir_id={}, expr={:?}, op={:?}, lhs_expr={:?}, rhs_expr={:?})",
+               expr.hir_id,
                expr,
                op,
                lhs_expr,
@@ -150,8 +150,8 @@ fn check_overloaded_binop(&self,
                               is_assign: IsAssign)
                               -> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>)
     {
-        debug!("check_overloaded_binop(expr.id={}, op={:?}, is_assign={:?})",
-               expr.id,
+        debug!("check_overloaded_binop(expr.hir_id={}, op={:?}, is_assign={:?})",
+               expr.hir_id,
                op,
                is_assign);
 
index 5279fbd9cf6ebf32c466e09535bbaf5fb6a0d05d..bf4df19556d0277736601ee70b26bf739cb01db7 100644 (file)
@@ -694,8 +694,8 @@ fn visit_expr(&mut self, expr: &'gcx hir::Expr) {
             hir::ExprKind::Ret(Some(ref ret_expr)) => {
                 let call_site_scope = self.call_site_scope;
                 debug!(
-                    "visit_expr ExprKind::Ret ret_expr.id {} call_site_scope: {:?}",
-                    ret_expr.id, call_site_scope
+                    "visit_expr ExprKind::Ret ret_expr.hir_id {} call_site_scope: {:?}",
+                    ret_expr.hir_id, call_site_scope
                 );
                 let call_site_region = self.tcx.mk_region(ty::ReScope(call_site_scope.unwrap()));
                 self.type_of_node_must_outlive(
index 1816b7454dd2d12174d71dbe4427ccee560b1901..ffeef84c4176149c5569fa6b219c882a969ca9a0 100644 (file)
@@ -67,7 +67,7 @@ fn visit_expr(&mut self, expr: &'gcx hir::Expr) {
             let body = self.fcx.tcx.hir().body(body_id);
             self.visit_body(body);
             self.fcx
-                .analyze_closure(expr.id, expr.hir_id, expr.span, body, cc);
+                .analyze_closure(expr.hir_id, expr.span, body, cc);
         }
 
         intravisit::walk_expr(self, expr);
@@ -77,7 +77,6 @@ fn visit_expr(&mut self, expr: &'gcx hir::Expr) {
 impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
     fn analyze_closure(
         &self,
-        closure_node_id: ast::NodeId,
         closure_hir_id: hir::HirId,
         span: Span,
         body: &hir::Body,
@@ -89,7 +88,7 @@ fn analyze_closure(
 
         debug!(
             "analyze_closure(id={:?}, body.id={:?})",
-            closure_node_id,
+            closure_hir_id,
             body.id()
         );
 
@@ -105,7 +104,7 @@ fn analyze_closure(
                 span_bug!(
                     span,
                     "type of closure expr {:?} is not a closure {:?}",
-                    closure_node_id,
+                    closure_hir_id,
                     t
                 );
             }
@@ -121,6 +120,8 @@ fn analyze_closure(
             None
         };
 
+        let closure_node_id = self.tcx.hir().hir_to_node_id(closure_hir_id);
+
         self.tcx.with_freevars(closure_node_id, |freevars| {
             let mut freevar_list: Vec<ty::UpvarId> = Vec::with_capacity(freevars.len());
             for freevar in freevars {
@@ -582,7 +583,7 @@ fn adjust_closure_kind(
 impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
     fn consume(
         &mut self,
-        _consume_id: ast::NodeId,
+        _consume_id: hir::HirId,
         _consume_span: Span,
         cmt: &mc::cmt_<'tcx>,
         mode: euv::ConsumeMode,
@@ -611,7 +612,7 @@ fn consume_pat(
 
     fn borrow(
         &mut self,
-        borrow_id: ast::NodeId,
+        borrow_id: hir::HirId,
         _borrow_span: Span,
         cmt: &mc::cmt_<'tcx>,
         _loan_region: ty::Region<'tcx>,
@@ -638,7 +639,7 @@ fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) {}
 
     fn mutate(
         &mut self,
-        _assignment_id: ast::NodeId,
+        _assignment_id: hir::HirId,
         _assignment_span: Span,
         assignee_cmt: &mc::cmt_<'tcx>,
         _mode: euv::MutateMode,
index e4c0e3bd54d5dd861db6f2bca04f71d2b32bc0ec..82a12b95d99172d6c6b553c0a1271020ea102570 100644 (file)
@@ -243,11 +243,11 @@ fn visit_expr(&mut self, e: &'gcx hir::Expr) {
             }
             hir::ExprKind::Struct(_, ref fields, _) => {
                 for field in fields {
-                    self.visit_field_id(field.id);
+                    self.visit_field_id(field.hir_id);
                 }
             }
             hir::ExprKind::Field(..) => {
-                self.visit_field_id(e.id);
+                self.visit_field_id(e.hir_id);
             }
             _ => {}
         }
@@ -273,7 +273,7 @@ fn visit_pat(&mut self, p: &'gcx hir::Pat) {
             }
             hir::PatKind::Struct(_, ref fields, _) => {
                 for field in fields {
-                    self.visit_field_id(field.node.id);
+                    self.visit_field_id(field.node.hir_id);
                 }
             }
             _ => {}
@@ -590,8 +590,7 @@ fn visit_opaque_types(&mut self, span: Span) {
         }
     }
 
-    fn visit_field_id(&mut self, node_id: ast::NodeId) {
-        let hir_id = self.tcx().hir().node_to_hir_id(node_id);
+    fn visit_field_id(&mut self, hir_id: hir::HirId) {
         if let Some(index) = self.fcx
             .tables
             .borrow_mut()
index 2ef6aaf4f0499c964532ef28d30b41251dcf0fa0..7587380acf8cb3f4a89edb33496f879dc77b6992 100644 (file)
@@ -144,7 +144,7 @@ fn visit_generics(&mut self, generics: &'tcx hir::Generics) {
 
     fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
         if let hir::ExprKind::Closure(..) = expr.node {
-            let def_id = self.tcx.hir().local_def_id(expr.id);
+            let def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
             self.tcx.generics_of(def_id);
             self.tcx.type_of(def_id);
         }