Skip to content

Commit 181861c

Browse files
authored
Rollup merge of #113196 - Bryanskiy:assoc_item, r=petrochenkov
Fix associated items effective visibility calculation for type privacy lints Fixes #113126 (comment).
2 parents 6a84278 + f9a4db7 commit 181861c

File tree

1 file changed

+7
-4
lines changed
  • compiler/rustc_privacy/src

1 file changed

+7
-4
lines changed

compiler/rustc_privacy/src/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -2135,16 +2135,18 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {
21352135
// lints shouldn't be emmited even if `from` effective visibility
21362136
// is larger than `Priv` nominal visibility and if `Priv` can leak
21372137
// in some scenarios due to type inference.
2138-
let impl_ev = Some(EffectiveVisibility::of_impl::<false>(
2138+
let impl_ev = EffectiveVisibility::of_impl::<false>(
21392139
item.owner_id.def_id,
21402140
tcx,
21412141
self.effective_visibilities,
2142-
));
2142+
);
21432143

21442144
// check that private components do not appear in the generics or predicates of inherent impls
21452145
// this check is intentionally NOT performed for impls of traits, per #90586
21462146
if impl_.of_trait.is_none() {
2147-
self.check(item.owner_id.def_id, impl_vis, impl_ev).generics().predicates();
2147+
self.check(item.owner_id.def_id, impl_vis, Some(impl_ev))
2148+
.generics()
2149+
.predicates();
21482150
}
21492151
for impl_item_ref in impl_.items {
21502152
let impl_item_vis = if impl_.of_trait.is_none() {
@@ -2159,8 +2161,9 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {
21592161

21602162
let impl_item_ev = if impl_.of_trait.is_none() {
21612163
self.get(impl_item_ref.id.owner_id.def_id)
2164+
.map(|ev| ev.min(impl_ev, self.tcx))
21622165
} else {
2163-
impl_ev
2166+
Some(impl_ev)
21642167
};
21652168

21662169
self.check_assoc_item(

0 commit comments

Comments
 (0)