about summary refs log tree commit diff
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2019-02-15 15:21:56 +0100
committerljedrz <ljedrz@gmail.com>2019-02-20 11:00:43 +0100
commit47dc349491e18a824a922c7bea4db3c26880c07f (patch)
treeffee7ead643ad24f09f911c258a14754f3012c8a
parentf5bba2c6d7b7fe28a33d709e5f776fd70b6f4edc (diff)
downloadrust-47dc349491e18a824a922c7bea4db3c26880c07f.tar.gz
rust-47dc349491e18a824a922c7bea4db3c26880c07f.zip
adjust intravisit HirIdification
-rw-r--r--src/librustc/hir/map/collector.rs21
-rw-r--r--src/librustc/hir/map/hir_id_validator.rs7
2 files changed, 12 insertions, 16 deletions
diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs
index 5b3e9873353..04eec88004a 100644
--- a/src/librustc/hir/map/collector.rs
+++ b/src/librustc/hir/map/collector.rs
@@ -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 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
             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 @@ impl<'a, 'hir> NodeCollector<'a, '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 @@ impl<'a, 'hir> NodeCollector<'a, '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 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
     }
 
     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 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
 
     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);
     }
 
diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs
index dc146a8bc09..fafe671b9eb 100644
--- a/src/librustc/hir/map/hir_id_validator.rs
+++ b/src/librustc/hir/map/hir_id_validator.rs
@@ -98,11 +98,8 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
         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());