]> git.lizzy.rs Git - rust.git/commitdiff
Give HirId to hir::Ty
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Wed, 13 Sep 2017 15:29:59 +0000 (18:29 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Fri, 22 Sep 2017 21:48:02 +0000 (00:48 +0300)
src/librustc/hir/lowering.rs
src/librustc/hir/mod.rs
src/librustc/ich/impls_hir.rs

index 465520ea03434c9af39ae87535cb0d56d6bd2170..f0cb59c08d28cbfdc5d55278d1332a08faf53f6e 100644 (file)
@@ -685,7 +685,7 @@ fn lower_ty(&mut self, t: &Ty) -> P<hir::Ty> {
                 return self.lower_ty(ty);
             }
             TyKind::Path(ref qself, ref path) => {
-                let id = self.lower_node_id(t.id).node_id;
+                let id = self.lower_node_id(t.id);
                 let qpath = self.lower_qpath(t.id, qself, path, ParamMode::Explicit);
                 return self.ty_path(id, t.span, qpath);
             }
@@ -734,10 +734,12 @@ fn lower_ty(&mut self, t: &Ty) -> P<hir::Ty> {
             TyKind::Mac(_) => panic!("TyMac should have been expanded by now."),
         };
 
+        let LoweredNodeId { node_id, hir_id } = self.lower_node_id(t.id);
         P(hir::Ty {
-            id: self.lower_node_id(t.id).node_id,
+            id: node_id,
             node: kind,
             span: t.span,
+            hir_id,
         })
     }
 
@@ -863,7 +865,7 @@ fn lower_qpath(&mut self,
             // Otherwise, the base path is an implicit `Self` type path,
             // e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
             // `<I as Iterator>::Item::default`.
-            let new_id = self.next_id().node_id;
+            let new_id = self.next_id();
             self.ty_path(new_id, p.span, hir::QPath::Resolved(qself, path))
         };
 
@@ -888,7 +890,7 @@ fn lower_qpath(&mut self,
             }
 
             // Wrap the associated extension in another type node.
-            let new_id = self.next_id().node_id;
+            let new_id = self.next_id();
             ty = self.ty_path(new_id, p.span, qpath);
         }
 
@@ -996,7 +998,8 @@ fn lower_parenthesized_parameter_data(&mut self,
         let &ParenthesizedParameterData { ref inputs, ref output, span } = data;
         let inputs = inputs.iter().map(|ty| self.lower_ty(ty)).collect();
         let mk_tup = |this: &mut Self, tys, span| {
-            P(hir::Ty { node: hir::TyTup(tys), id: this.next_id().node_id, span })
+            let LoweredNodeId { node_id, hir_id } = this.next_id();
+            P(hir::Ty { node: hir::TyTup(tys), id: node_id, hir_id, span })
         };
 
         hir::PathParameters {
@@ -2976,7 +2979,7 @@ fn signal_block_expr(&mut self,
         self.expr_block(block, attrs)
     }
 
-    fn ty_path(&mut self, id: NodeId, span: Span, qpath: hir::QPath) -> P<hir::Ty> {
+    fn ty_path(&mut self, id: LoweredNodeId, span: Span, qpath: hir::QPath) -> P<hir::Ty> {
         let mut id = id;
         let node = match qpath {
             hir::QPath::Resolved(None, path) => {
@@ -2986,14 +2989,14 @@ fn ty_path(&mut self, id: NodeId, span: Span, qpath: hir::QPath) -> P<hir::Ty> {
                         bound_lifetimes: hir_vec![],
                         trait_ref: hir::TraitRef {
                             path: path.and_then(|path| path),
-                            ref_id: id,
+                            ref_id: id.node_id,
                         },
                         span,
                     };
 
                     // The original ID is taken by the `PolyTraitRef`,
                     // so the `Ty` itself needs a different one.
-                    id = self.next_id().node_id;
+                    id = self.next_id();
 
                     hir::TyTraitObject(hir_vec![principal], self.elided_lifetime(span))
                 } else {
@@ -3002,7 +3005,7 @@ fn ty_path(&mut self, id: NodeId, span: Span, qpath: hir::QPath) -> P<hir::Ty> {
             }
             _ => hir::TyPath(qpath)
         };
-        P(hir::Ty { id, node, span })
+        P(hir::Ty { id: id.node_id, hir_id: id.hir_id, node, span })
     }
 
     fn elided_lifetime(&mut self, span: Span) -> hir::Lifetime {
index 1bef17b28acb572f52b67c0e82c9e1410d9d7ea0..e96edaa86d2a2a5709b7ab3cf82c6837218fa997 100644 (file)
@@ -1354,6 +1354,7 @@ pub struct Ty {
     pub id: NodeId,
     pub node: Ty_,
     pub span: Span,
+    pub hir_id: HirId,
 }
 
 impl fmt::Debug for Ty {
index b62b9e5ab46868fad66adf3c3904a65f83c4e438..bc0c52575ae1506fd65f5021f3cadb6185b9fc61 100644 (file)
@@ -245,6 +245,7 @@ fn hash_stable<W: StableHasherResult>(&self,
         hcx.while_hashing_hir_bodies(true, |hcx| {
             let hir::Ty {
                 id: _,
+                hir_id: _,
                 ref node,
                 ref span,
             } = *self;