]> git.lizzy.rs Git - rust.git/commitdiff
Don't generate a new NodeId for universal impl Trait
authorOliver Schneider <github35764891676564198441@oli-obk.de>
Wed, 20 Jun 2018 08:44:31 +0000 (10:44 +0200)
committerOliver Schneider <github35764891676564198441@oli-obk.de>
Wed, 27 Jun 2018 09:17:25 +0000 (11:17 +0200)
src/librustc/hir/lowering.rs
src/librustc/hir/map/collector.rs

index d8d222b9a39f7a55ef93f564689bd6082b6470ba..18f652854d87b9d54d18e66bef210b18f6d669fb 100644 (file)
@@ -1167,18 +1167,17 @@ fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> P<hir::Ty> {
                 }
                 hir::TyTraitObject(bounds, lifetime_bound)
             }
-            TyKind::ImplTrait(exist_ty_node_id, ref bounds) => {
+            TyKind::ImplTrait(def_node_id, ref bounds) => {
                 let span = t.span;
                 match itctx {
                     ImplTraitContext::Existential(fn_def_id) => {
                         self.lower_existential_impl_trait(
-                            span, fn_def_id, exist_ty_node_id,
+                            span, fn_def_id, def_node_id,
                             |this| this.lower_param_bounds(bounds, itctx),
                         )
                     }
                     ImplTraitContext::Universal(def_id) => {
-                        let def_node_id = self.next_id().node_id;
-
+                        self.lower_node_id(def_node_id);
                         // Add a definition for the in-band TyParam
                         let def_index = self.resolver.definitions().create_def_with_parent(
                             def_id.index,
index 14cecba490d0ab3c99258ab9f7ab2429ce46d8f2..f16bf1d774455f7e9c0ce697e2648e9e3dfd8d85 100644 (file)
@@ -221,9 +221,9 @@ fn insert(&mut self, id: NodeId, node: Node<'hir>) {
         // Make sure that the DepNode of some node coincides with the HirId
         // owner of that node.
         if cfg!(debug_assertions) {
-            let hir_id_owner = self.definitions.node_to_hir_id(id).owner;
+            let hir_id = self.definitions.node_to_hir_id(id);
 
-            if hir_id_owner != self.current_dep_node_owner {
+            if hir_id.owner != self.current_dep_node_owner {
                 let node_str = match self.definitions.opt_def_index(id) {
                     Some(def_index) => {
                         self.definitions.def_path(def_index).to_string_no_crate()
@@ -231,13 +231,17 @@ fn insert(&mut self, id: NodeId, node: Node<'hir>) {
                     None => format!("{:?}", node)
                 };
 
+                if hir_id == ::hir::DUMMY_HIR_ID {
+                    println!("Maybe you forgot to lower the node id {:?}?", id);
+                }
+
                 bug!("inconsistent DepNode for `{}`: \
                       current_dep_node_owner={}, hir_id.owner={}",
                     node_str,
                     self.definitions
                         .def_path(self.current_dep_node_owner)
                         .to_string_no_crate(),
-                    self.definitions.def_path(hir_id_owner).to_string_no_crate())
+                    self.definitions.def_path(hir_id.owner).to_string_no_crate())
             }
         }