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

index 6b22ac01a0670cf3acc8c590c67db767cc654156..c5499e7fe1793fd7027a772b6c090269f1e92717 100644 (file)
@@ -404,27 +404,24 @@ fn find_entry(&self, id: HirId) -> Option<Entry<'hir>> {
     }
 
     pub fn item(&self, id: HirId) -> &'hir Item<'hir> {
-        self.read(id);
-
-        // N.B., intentionally bypass `self.krate()` so that we
-        // do not trigger a read of the whole krate here
-        self.krate.item(id)
+        match self.find(id).unwrap() {
+            Node::Item(item) => item,
+            _ => bug!(),
+        }
     }
 
     pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
-        self.read(id.hir_id);
-
-        // N.B., intentionally bypass `self.krate()` so that we
-        // do not trigger a read of the whole krate here
-        self.krate.trait_item(id)
+        match self.find(id.hir_id).unwrap() {
+            Node::TraitItem(item) => item,
+            _ => bug!(),
+        }
     }
 
     pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> {
-        self.read(id.hir_id);
-
-        // N.B., intentionally bypass `self.krate()` so that we
-        // do not trigger a read of the whole krate here
-        self.krate.impl_item(id)
+        match self.find(id.hir_id).unwrap() {
+            Node::ImplItem(item) => item,
+            _ => bug!(),
+        }
     }
 
     pub fn body(&self, id: BodyId) -> &'hir Body<'hir> {