]> git.lizzy.rs Git - rust.git/commitdiff
Update `get_parent_node`
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Fri, 7 Feb 2020 17:46:21 +0000 (18:46 +0100)
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Sat, 14 Mar 2020 21:52:29 +0000 (22:52 +0100)
src/librustc/hir/map/mod.rs

index f7990ca01494adec49cb5a5c50d192f67c5ab802..23a80eb6b7de393c9582e2796201e7e1b2075edc 100644 (file)
@@ -579,12 +579,11 @@ pub fn visit_item_likes_in_module<V>(&self, module: DefId, visitor: &mut V)
 
     /// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
     pub fn get(&self, id: HirId) -> Node<'hir> {
-        // read recorded by `find`
         self.find(id).unwrap_or_else(|| bug!("couldn't find hir id {} in the HIR map", id))
     }
 
     pub fn get_if_local(&self, id: DefId) -> Option<Node<'hir>> {
-        self.as_local_hir_id(id).map(|id| self.get(id)) // read recorded by `get`
+        self.as_local_hir_id(id).map(|id| self.get(id))
     }
 
     pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics<'hir>> {
@@ -628,13 +627,7 @@ pub fn find(&self, hir_id: HirId) -> Option<Node<'hir>> {
     /// from a node to the root of the HIR (unless you get back the same ID here,
     /// which can happen if the ID is not in the map itself or is just weird).
     pub fn get_parent_node(&self, hir_id: HirId) -> HirId {
-        if self.dep_graph.is_fully_enabled() {
-            let hir_id_owner = hir_id.owner;
-            let def_path_hash = self.definitions.def_path_hash(hir_id_owner);
-            self.dep_graph.read(DepNode::from_def_path_hash(def_path_hash, DepKind::HirBody));
-        }
-
-        self.find_entry(hir_id).and_then(|x| x.parent_node()).unwrap_or(hir_id)
+        self.get_entry(hir_id).parent_node().unwrap_or(hir_id)
     }
 
     /// Returns an iterator for the nodes in the ancestor tree of the `current_id`