]> git.lizzy.rs Git - rust.git/commitdiff
adjust intravisit HirIdification
authorljedrz <ljedrz@gmail.com>
Fri, 15 Feb 2019 14:21:56 +0000 (15:21 +0100)
committerljedrz <ljedrz@gmail.com>
Wed, 20 Feb 2019 10:00:43 +0000 (11:00 +0100)
src/librustc/hir/map/collector.rs
src/librustc/hir/map/hir_id_validator.rs

index 5b3e9873353d1934bc50ddc5244235779b2c634e..04eec88004aa6fade46a7b55ab874faae3853873 100644 (file)
@@ -27,7 +27,7 @@ pub(super) struct NodeCollector<'a, 'hir> {
     /// The node map
     map: Vec<Option<Entry<'hir>>>,
     /// The parent of this node
-    parent_hir: hir::HirId,
+    parent_node: hir::HirId,
 
     // These fields keep track of the currently relevant DepNodes during
     // the visitor's traversal.
@@ -147,7 +147,7 @@ pub(super) fn root(sess: &'a Session,
             krate,
             source_map: sess.source_map(),
             map: repeat(None).take(sess.current_node_id_count()).collect(),
-            parent_hir: hir::CRATE_HIR_ID,
+            parent_node: hir::CRATE_HIR_ID,
             current_signature_dep_index: root_mod_sig_dep_index,
             current_full_dep_index: root_mod_full_dep_index,
             current_dep_node_owner: CRATE_DEF_INDEX,
@@ -230,8 +230,8 @@ fn insert_entry(&mut self, id: NodeId, entry: Entry<'hir>) {
 
     fn insert(&mut self, span: Span, hir_id: HirId, node: Node<'hir>) {
         let entry = Entry {
-            parent: self.hir_to_node_id[&self.parent_hir],
-            parent_hir: self.parent_hir,
+            parent: self.hir_to_node_id[&self.parent_node],
+            parent_hir: self.parent_node,
             dep_node: if self.currently_in_body {
                 self.current_full_dep_index
             } else {
@@ -283,13 +283,13 @@ fn insert(&mut self, span: Span, hir_id: HirId, node: Node<'hir>) {
 
     fn with_parent<F: FnOnce(&mut Self)>(
         &mut self,
-        parent_hir_id: HirId,
+        parent_node_id: HirId,
         f: F,
     ) {
-        let parent_hir = self.parent_hir;
-        self.parent_hir = parent_hir_id;
+        let parent_node = self.parent_node;
+        self.parent_node = parent_node_id;
         f(self);
-        self.parent_hir = parent_hir;
+        self.parent_node = parent_node;
     }
 
     fn with_dep_node_owner<T: for<'b> HashStable<StableHashingContext<'b>>,
@@ -446,8 +446,7 @@ fn visit_stmt(&mut self, stmt: &'hir Stmt) {
     }
 
     fn visit_path_segment(&mut self, path_span: Span, path_segment: &'hir PathSegment) {
-        if path_segment.id.is_some() {
-            let hir_id = path_segment.hir_id.unwrap();
+        if let Some(hir_id) = path_segment.hir_id {
             self.insert(path_span, hir_id, Node::PathSegment(path_segment));
         }
         intravisit::walk_path_segment(self, path_span, path_segment);
@@ -471,7 +470,7 @@ fn visit_trait_ref(&mut self, tr: &'hir TraitRef) {
 
     fn visit_fn(&mut self, fk: intravisit::FnKind<'hir>, fd: &'hir FnDecl,
                 b: BodyId, s: Span, id: HirId) {
-        assert_eq!(self.parent_hir, id);
+        assert_eq!(self.parent_node, id);
         intravisit::walk_fn(self, fk, fd, b, s, id);
     }
 
index dc146a8bc09b8e4e906b098ee58fec8296c4caac..fafe671b9eb8b6970ebdb060dc27889efcaf925d 100644 (file)
@@ -98,11 +98,8 @@ fn check<F: FnOnce(&mut HirIdValidator<'a, 'hir>)>(&mut self,
         if max != self.hir_ids_seen.len() - 1 {
             // Collect the missing ItemLocalIds
             let missing: Vec<_> = (0 ..= max as u32)
-              .filter(|&i| !self.hir_ids_seen
-                                .iter()
-                                .find(|&local_id| local_id == &ItemLocalId::from_u32(i))
-                                .is_some()
-            ).collect();
+              .filter(|&i| !self.hir_ids_seen.contains(&ItemLocalId::from_u32(i)))
+              .collect();
 
             // Try to map those to something more useful
             let mut missing_items = Vec::with_capacity(missing.len());