diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 9a952bb721951..a34fcc4f68c9e 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -1590,13 +1590,14 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> { let mut check = self.check(item.def_id.expect_local(), vis, effective_vis); let is_assoc_ty = item.is_type(); - check.hard_error = is_assoc_ty && !item.is_impl_trait_in_trait(); + check.hard_error = is_assoc_ty; check.generics().predicates(); if assoc_has_type_of(self.tcx, item) { - check.hard_error = check.hard_error && item.defaultness(self.tcx).has_value(); check.ty(); } if is_assoc_ty && item.container == AssocContainer::Trait { + // FIXME: too much breakage from reporting hard errors here, better wait for a fix + // from proper associated type normalization. check.hard_error = false; check.bounds(); } diff --git a/tests/ui/privacy/private-in-public-warn.rs b/tests/ui/privacy/private-in-public-warn.rs index 6a0ac2b9ade79..299fe9a75d4cc 100644 --- a/tests/ui/privacy/private-in-public-warn.rs +++ b/tests/ui/privacy/private-in-public-warn.rs @@ -49,10 +49,10 @@ mod traits { fn f(arg: T) {} //~^ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::f` fn g() -> impl PrivTr; - //~^ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::g::{anon_assoc#0}` + //~^ ERROR private trait `traits::PrivTr` in public interface //~| ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::g::{anon_assoc#0}` fn h() -> impl PrivTr {} - //~^ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}` + //~^ ERROR private trait `traits::PrivTr` in public interface //~| ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}` } impl Pub {} //~ ERROR trait `traits::PrivTr` is more private than the item `traits::Pub` @@ -93,13 +93,13 @@ mod generics { pub trait Tr5 { fn required() -> impl PrivTr>; - //~^ ERROR trait `generics::PrivTr>` is more private than the item `Tr5::required::{anon_assoc#0}` - //~| ERROR type `generics::Priv<()>` is more private than the item `Tr5::required::{anon_assoc#0}` + //~^ ERROR private trait `generics::PrivTr>` in public interface + //~| ERROR private type `generics::Priv<()>` in public interface //~| ERROR trait `generics::PrivTr>` is more private than the item `Tr5::required::{anon_assoc#0}` //~| ERROR type `generics::Priv<()>` is more private than the item `Tr5::required::{anon_assoc#0}` fn provided() -> impl PrivTr> {} - //~^ ERROR trait `generics::PrivTr>` is more private than the item `Tr5::provided::{anon_assoc#0}` - //~| ERROR type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}` + //~^ ERROR private trait `generics::PrivTr>` in public interface + //~| ERROR private type `generics::Priv<()>` in public interface //~| ERROR trait `generics::PrivTr>` is more private than the item `Tr5::provided::{anon_assoc#0}` //~| ERROR type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}` } diff --git a/tests/ui/privacy/private-in-public-warn.stderr b/tests/ui/privacy/private-in-public-warn.stderr index 1fa415e27c16f..64be22b4cdf99 100644 --- a/tests/ui/privacy/private-in-public-warn.stderr +++ b/tests/ui/privacy/private-in-public-warn.stderr @@ -194,17 +194,14 @@ note: but trait `traits::PrivTr` is only usable at visibility `pub(self)` LL | trait PrivTr {} | ^^^^^^^^^^^^ -error: trait `traits::PrivTr` is more private than the item `traits::Tr3::g::{anon_assoc#0}` +error[E0446]: private trait `traits::PrivTr` in public interface --> $DIR/private-in-public-warn.rs:51:19 | -LL | fn g() -> impl PrivTr; - | ^^^^^^^^^^^ opaque type `traits::Tr3::g::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `traits::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:37:5 - | LL | trait PrivTr {} - | ^^^^^^^^^^^^ + | ------------ `traits::PrivTr` declared as private +... +LL | fn g() -> impl PrivTr; + | ^^^^^^^^^^^ can't leak private trait error: trait `traits::PrivTr` is more private than the item `traits::Tr3::g::{anon_assoc#0}` --> $DIR/private-in-public-warn.rs:51:19 @@ -218,17 +215,14 @@ note: but trait `traits::PrivTr` is only usable at visibility `pub(self)` LL | trait PrivTr {} | ^^^^^^^^^^^^ -error: trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}` +error[E0446]: private trait `traits::PrivTr` in public interface --> $DIR/private-in-public-warn.rs:54:19 | -LL | fn h() -> impl PrivTr {} - | ^^^^^^^^^^^ opaque type `traits::Tr3::h::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `traits::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:37:5 - | LL | trait PrivTr {} - | ^^^^^^^^^^^^ + | ------------ `traits::PrivTr` declared as private +... +LL | fn h() -> impl PrivTr {} + | ^^^^^^^^^^^ can't leak private trait error: trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}` --> $DIR/private-in-public-warn.rs:54:19 @@ -350,29 +344,23 @@ note: but type `generics::Priv` is only usable at visibility `pub(self)` LL | struct Priv(T); | ^^^^^^^^^^^^^^^^^^^ -error: trait `generics::PrivTr>` is more private than the item `Tr5::required::{anon_assoc#0}` +error[E0446]: private trait `generics::PrivTr>` in public interface --> $DIR/private-in-public-warn.rs:95:26 | -LL | fn required() -> impl PrivTr>; - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::required::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `generics::PrivTr>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:84:5 - | LL | trait PrivTr {} - | ^^^^^^^^^^^^^^^ + | --------------- `generics::PrivTr>` declared as private +... +LL | fn required() -> impl PrivTr>; + | ^^^^^^^^^^^^^^^^^^^^^ can't leak private trait -error: type `generics::Priv<()>` is more private than the item `Tr5::required::{anon_assoc#0}` +error[E0446]: private type `generics::Priv<()>` in public interface --> $DIR/private-in-public-warn.rs:95:26 | -LL | fn required() -> impl PrivTr>; - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::required::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but type `generics::Priv<()>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:82:5 - | LL | struct Priv(T); - | ^^^^^^^^^^^^^^^^^^^ + | ------------------- `generics::Priv<()>` declared as private +... +LL | fn required() -> impl PrivTr>; + | ^^^^^^^^^^^^^^^^^^^^^ can't leak private type error: trait `generics::PrivTr>` is more private than the item `Tr5::required::{anon_assoc#0}` --> $DIR/private-in-public-warn.rs:95:26 @@ -398,29 +386,23 @@ note: but type `generics::Priv<()>` is only usable at visibility `pub(self)` LL | struct Priv(T); | ^^^^^^^^^^^^^^^^^^^ -error: trait `generics::PrivTr>` is more private than the item `Tr5::provided::{anon_assoc#0}` +error[E0446]: private trait `generics::PrivTr>` in public interface --> $DIR/private-in-public-warn.rs:100:26 | -LL | fn provided() -> impl PrivTr> {} - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::provided::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but trait `generics::PrivTr>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:84:5 - | LL | trait PrivTr {} - | ^^^^^^^^^^^^^^^ + | --------------- `generics::PrivTr>` declared as private +... +LL | fn provided() -> impl PrivTr> {} + | ^^^^^^^^^^^^^^^^^^^^^ can't leak private trait -error: type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}` +error[E0446]: private type `generics::Priv<()>` in public interface --> $DIR/private-in-public-warn.rs:100:26 | -LL | fn provided() -> impl PrivTr> {} - | ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::provided::{anon_assoc#0}` is reachable at visibility `pub(crate)` - | -note: but type `generics::Priv<()>` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:82:5 - | LL | struct Priv(T); - | ^^^^^^^^^^^^^^^^^^^ + | ------------------- `generics::Priv<()>` declared as private +... +LL | fn provided() -> impl PrivTr> {} + | ^^^^^^^^^^^^^^^^^^^^^ can't leak private type error: trait `generics::PrivTr>` is more private than the item `Tr5::provided::{anon_assoc#0}` --> $DIR/private-in-public-warn.rs:100:26