Move some Map
methods onto TyCtxt
.
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
This commit is contained in:
parent
cd1d84cdf7
commit
f86f7ad5f2
197 changed files with 465 additions and 476 deletions
|
@ -1036,7 +1036,7 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
|
|||
return;
|
||||
}
|
||||
let old_maybe_typeck_results = self.maybe_typeck_results.replace(new_typeck_results);
|
||||
self.visit_body(self.tcx.hir().body(body_id));
|
||||
self.visit_body(self.tcx.hir_body(body_id));
|
||||
self.maybe_typeck_results = old_maybe_typeck_results;
|
||||
}
|
||||
|
||||
|
@ -1161,7 +1161,7 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
|
|||
fn visit_nested_body(&mut self, body_id: hir::BodyId) {
|
||||
let old_maybe_typeck_results =
|
||||
self.maybe_typeck_results.replace(self.tcx.typeck_body(body_id));
|
||||
self.visit_body(self.tcx.hir().body(body_id));
|
||||
self.visit_body(self.tcx.hir_body(body_id));
|
||||
self.maybe_typeck_results = old_maybe_typeck_results;
|
||||
}
|
||||
|
||||
|
@ -1599,7 +1599,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
|
|||
self.check(def_id, item_visibility, effective_vis).generics().bounds();
|
||||
}
|
||||
DefKind::Trait => {
|
||||
let item = tcx.hir().item(id);
|
||||
let item = tcx.hir_item(id);
|
||||
if let hir::ItemKind::Trait(.., trait_item_refs) = item.kind {
|
||||
self.check_unnameable(item.owner_id.def_id, effective_vis);
|
||||
|
||||
|
@ -1630,7 +1630,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
|
|||
self.check(def_id, item_visibility, effective_vis).generics().predicates();
|
||||
}
|
||||
DefKind::Enum => {
|
||||
let item = tcx.hir().item(id);
|
||||
let item = tcx.hir_item(id);
|
||||
if let hir::ItemKind::Enum(ref def, _) = item.kind {
|
||||
self.check_unnameable(item.owner_id.def_id, effective_vis);
|
||||
|
||||
|
@ -1647,10 +1647,10 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
|
|||
}
|
||||
// Subitems of foreign modules have their own publicity.
|
||||
DefKind::ForeignMod => {
|
||||
let item = tcx.hir().item(id);
|
||||
let item = tcx.hir_item(id);
|
||||
if let hir::ItemKind::ForeignMod { items, .. } = item.kind {
|
||||
for foreign_item in items {
|
||||
let foreign_item = tcx.hir().foreign_item(foreign_item.id);
|
||||
let foreign_item = tcx.hir_foreign_item(foreign_item.id);
|
||||
|
||||
let ev = self.get(foreign_item.owner_id.def_id);
|
||||
let vis = tcx.local_visibility(foreign_item.owner_id.def_id);
|
||||
|
@ -1668,7 +1668,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
|
|||
}
|
||||
// Subitems of structs and unions have their own publicity.
|
||||
DefKind::Struct | DefKind::Union => {
|
||||
let item = tcx.hir().item(id);
|
||||
let item = tcx.hir_item(id);
|
||||
if let hir::ItemKind::Struct(ref struct_def, _)
|
||||
| hir::ItemKind::Union(ref struct_def, _) = item.kind
|
||||
{
|
||||
|
@ -1695,7 +1695,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
|
|||
// A trait impl is public when both its type and its trait are public
|
||||
// Subitems of trait impls have inherited publicity.
|
||||
DefKind::Impl { .. } => {
|
||||
let item = tcx.hir().item(id);
|
||||
let item = tcx.hir_item(id);
|
||||
if let hir::ItemKind::Impl(impl_) = item.kind {
|
||||
let impl_vis = ty::Visibility::of_impl::<false>(
|
||||
item.owner_id.def_id,
|
||||
|
@ -1788,7 +1788,7 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
|
|||
}
|
||||
|
||||
for id in module.free_items() {
|
||||
if let ItemKind::Impl(i) = tcx.hir().item(id).kind {
|
||||
if let ItemKind::Impl(i) = tcx.hir_item(id).kind {
|
||||
if let Some(item) = i.of_trait {
|
||||
let trait_ref = tcx.impl_trait_ref(id.owner_id.def_id).unwrap();
|
||||
let trait_ref = trait_ref.instantiate_identity();
|
||||
|
@ -1885,7 +1885,7 @@ fn check_private_in_public(tcx: TyCtxt<'_>, (): ()) {
|
|||
// Check for private types in public interfaces.
|
||||
let mut checker = PrivateItemsInPublicInterfacesChecker { tcx, effective_visibilities };
|
||||
|
||||
for id in tcx.hir().items() {
|
||||
for id in tcx.hir_free_items() {
|
||||
checker.check_item(id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue