Skip to content

Commit e1a9626

Browse files
committed
Update item functions
1 parent 518c78f commit e1a9626

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/librustc/hir/map/mod.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -404,27 +404,24 @@ impl<'hir> Map<'hir> {
404404
}
405405

406406
pub fn item(&self, id: HirId) -> &'hir Item<'hir> {
407-
self.read(id);
408-
409-
// N.B., intentionally bypass `self.krate()` so that we
410-
// do not trigger a read of the whole krate here
411-
self.krate.item(id)
407+
match self.find(id).unwrap() {
408+
Node::Item(item) => item,
409+
_ => bug!(),
410+
}
412411
}
413412

414413
pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
415-
self.read(id.hir_id);
416-
417-
// N.B., intentionally bypass `self.krate()` so that we
418-
// do not trigger a read of the whole krate here
419-
self.krate.trait_item(id)
414+
match self.find(id.hir_id).unwrap() {
415+
Node::TraitItem(item) => item,
416+
_ => bug!(),
417+
}
420418
}
421419

422420
pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> {
423-
self.read(id.hir_id);
424-
425-
// N.B., intentionally bypass `self.krate()` so that we
426-
// do not trigger a read of the whole krate here
427-
self.krate.impl_item(id)
421+
match self.find(id.hir_id).unwrap() {
422+
Node::ImplItem(item) => item,
423+
_ => bug!(),
424+
}
428425
}
429426

430427
pub fn body(&self, id: BodyId) -> &'hir Body<'hir> {

0 commit comments

Comments
 (0)