intravisit: .expect_item -> .item

This commit is contained in:
Mazdak Farrokhzad 2020-01-07 15:51:38 +01:00
parent 4b08c7e974
commit 62e9ccbe28
2 changed files with 9 additions and 1 deletions

View File

@ -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);
}

View File

@ -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);