diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index e1245dbb665..9d6acbda62e 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -226,7 +226,7 @@ pub trait Visitor<'v>: Sized { /// but cannot supply a `Map`; see `nested_visit_map` for advice. #[allow(unused_variables)] fn visit_nested_item(&mut self, id: ItemId) { - let opt_item = self.nested_visit_map().inter().map(|map| map.expect_item(id.id)); + let opt_item = self.nested_visit_map().inter().map(|map| map.item(id.id)); if let Some(item) = opt_item { self.visit_item(item); } diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 05b0c8e36fd..69978efd81d 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -405,6 +405,14 @@ impl<'hir> Map<'hir> { self.forest.krate() } + pub fn item(&self, id: HirId) -> &'hir Item<'hir> { + self.read(id); + + // N.B., intentionally bypass `self.forest.krate()` so that we + // do not trigger a read of the whole krate here + self.forest.krate.item(id) + } + pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> { self.read(id.hir_id);