Skip to content

Commit e9e1226

Browse files
committed
Do not fetch HIR for reachable.
1 parent 2a51e73 commit e9e1226

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

compiler/rustc_passes/src/reachable.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -325,26 +325,23 @@ fn check_item<'tcx>(
325325
}
326326

327327
// We need only trait impls here, not inherent impls, and only non-exported ones
328-
let item = tcx.hir().item(id);
329-
if let hir::ItemKind::Impl(hir::Impl { of_trait: Some(ref trait_ref), ref items, .. }) =
330-
item.kind
331-
{
332-
if !effective_visibilities.is_reachable(item.owner_id.def_id) {
333-
worklist.extend(items.iter().map(|ii_ref| ii_ref.id.owner_id.def_id));
328+
if effective_visibilities.is_reachable(id.owner_id.def_id) {
329+
return;
330+
}
334331

335-
let Res::Def(DefKind::Trait, trait_def_id) = trait_ref.path.res else {
336-
unreachable!();
337-
};
332+
let items = tcx.associated_item_def_ids(id.owner_id);
333+
worklist.extend(items.iter().map(|ii_ref| ii_ref.expect_local()));
338334

339-
if !trait_def_id.is_local() {
340-
return;
341-
}
335+
let Some(trait_def_id) = tcx.trait_id_of_impl(id.owner_id.to_def_id()) else {
336+
unreachable!();
337+
};
342338

343-
worklist.extend(
344-
tcx.provided_trait_methods(trait_def_id).map(|assoc| assoc.def_id.expect_local()),
345-
);
346-
}
339+
if !trait_def_id.is_local() {
340+
return;
347341
}
342+
343+
worklist
344+
.extend(tcx.provided_trait_methods(trait_def_id).map(|assoc| assoc.def_id.expect_local()));
348345
}
349346

350347
fn has_custom_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {

0 commit comments

Comments
 (0)