]> git.lizzy.rs Git - rust.git/commitdiff
Update `find`
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Fri, 7 Feb 2020 18:01:27 +0000 (19:01 +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 23a80eb6b7de393c9582e2796201e7e1b2075edc..c98a919d0f5f33dfe4478df52cc52379fbc2cef5 100644 (file)
@@ -607,13 +607,8 @@ pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics<'hir>> {
 
     /// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
     pub fn find(&self, hir_id: HirId) -> Option<Node<'hir>> {
-        let result = self.find_entry(hir_id).and_then(|entry| {
-            if let Node::Crate(..) = entry.node { None } else { Some(entry.node) }
-        });
-        if result.is_some() {
-            self.read(hir_id);
-        }
-        result
+        let node = self.get_entry(hir_id).node;
+        if let Node::Crate(..) = node { None } else { Some(node) }
     }
 
     /// Similar to `get_parent`; returns the parent HIR Id, or just `hir_id` if there