Use LocalDefId in rustc_passes::hir_id_validator.

This commit is contained in:
Camille GILLOT 2021-12-05 13:08:52 +01:00
parent a5b7e235d3
commit 79afe99973

View File

@ -57,22 +57,22 @@ impl<'a, 'hir> OuterVisitor<'a, 'hir> {
impl<'a, 'hir> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> {
fn visit_item(&mut self, i: &'hir hir::Item<'hir>) {
let mut inner_visitor = self.new_inner_visitor(self.hir_map);
inner_visitor.check(i.hir_id(), |this| intravisit::walk_item(this, i));
inner_visitor.check(i.def_id, |this| intravisit::walk_item(this, i));
}
fn visit_trait_item(&mut self, i: &'hir hir::TraitItem<'hir>) {
let mut inner_visitor = self.new_inner_visitor(self.hir_map);
inner_visitor.check(i.hir_id(), |this| intravisit::walk_trait_item(this, i));
inner_visitor.check(i.def_id, |this| intravisit::walk_trait_item(this, i));
}
fn visit_impl_item(&mut self, i: &'hir hir::ImplItem<'hir>) {
let mut inner_visitor = self.new_inner_visitor(self.hir_map);
inner_visitor.check(i.hir_id(), |this| intravisit::walk_impl_item(this, i));
inner_visitor.check(i.def_id, |this| intravisit::walk_impl_item(this, i));
}
fn visit_foreign_item(&mut self, i: &'hir hir::ForeignItem<'hir>) {
let mut inner_visitor = self.new_inner_visitor(self.hir_map);
inner_visitor.check(i.hir_id(), |this| intravisit::walk_foreign_item(this, i));
inner_visitor.check(i.def_id, |this| intravisit::walk_foreign_item(this, i));
}
}
@ -83,9 +83,8 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
self.errors.lock().push(f());
}
fn check<F: FnOnce(&mut HirIdValidator<'a, 'hir>)>(&mut self, hir_id: HirId, walk: F) {
fn check<F: FnOnce(&mut HirIdValidator<'a, 'hir>)>(&mut self, owner: LocalDefId, walk: F) {
assert!(self.owner.is_none());
let owner = self.hir_map.local_def_id(hir_id);
self.owner = Some(owner);
walk(self);