summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_passes/src/reachable.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_passes/src/reachable.rs')
-rw-r--r--compiler/rustc_passes/src/reachable.rs31
1 files changed, 14 insertions, 17 deletions
diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs
index ad0952203..051100c56 100644
--- a/compiler/rustc_passes/src/reachable.rs
+++ b/compiler/rustc_passes/src/reachable.rs
@@ -320,31 +320,28 @@ fn check_item<'tcx>(
worklist.push(id.owner_id.def_id);
}
- if !matches!(tcx.def_kind(id.owner_id), DefKind::Impl) {
+ if !matches!(tcx.def_kind(id.owner_id), DefKind::Impl { of_trait: true }) {
return;
}
// 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 {
- unreachable!();
- };
+ let items = tcx.associated_item_def_ids(id.owner_id);
+ worklist.extend(items.iter().map(|ii_ref| ii_ref.expect_local()));
- if !trait_def_id.is_local() {
- return;
- }
+ let Some(trait_def_id) = tcx.trait_id_of_impl(id.owner_id.to_def_id()) else {
+ unreachable!();
+ };
- worklist.extend(
- tcx.provided_trait_methods(trait_def_id).map(|assoc| assoc.def_id.expect_local()),
- );
- }
+ if !trait_def_id.is_local() {
+ return;
}
+
+ 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 {