Do not fetch HIR for reachable.

This commit is contained in:
Camille GILLOT 2023-02-12 18:35:31 +00:00
parent 2a51e73ac9
commit e9e12266ce

View file

@ -325,14 +325,14 @@ fn check_item<'tcx>(
}
// We need only trait impls here, not inherent impls, and only non-exported ones
let item = tcx.hir().item(id);
if let hir::ItemKind::Impl(hir::Impl { of_trait: Some(ref trait_ref), ref items, .. }) =
item.kind
{
if !effective_visibilities.is_reachable(item.owner_id.def_id) {
worklist.extend(items.iter().map(|ii_ref| ii_ref.id.owner_id.def_id));
if effective_visibilities.is_reachable(id.owner_id.def_id) {
return;
}
let Res::Def(DefKind::Trait, trait_def_id) = trait_ref.path.res else {
let items = tcx.associated_item_def_ids(id.owner_id);
worklist.extend(items.iter().map(|ii_ref| ii_ref.expect_local()));
let Some(trait_def_id) = tcx.trait_id_of_impl(id.owner_id.to_def_id()) else {
unreachable!();
};
@ -340,11 +340,8 @@ fn check_item<'tcx>(
return;
}
worklist.extend(
tcx.provided_trait_methods(trait_def_id).map(|assoc| assoc.def_id.expect_local()),
);
}
}
worklist
.extend(tcx.provided_trait_methods(trait_def_id).map(|assoc| assoc.def_id.expect_local()));
}
fn has_custom_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {