Skip to content

Commit

Permalink
Use LocalDefId in rustc_passes::hir_id_validator.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Jan 15, 2022
1 parent a5b7e23 commit 79afe99
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions compiler/rustc_passes/src/hir_id_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

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

Expand Down

0 comments on commit 79afe99

Please sign in to comment.