From 1ce89c04490746ba07f55413d7f511675e638bab Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 16 Jan 2026 20:51:41 +0300 Subject: [PATCH] privacy: Close one more hole in associated type visiting --- compiler/rustc_privacy/src/lib.rs | 26 ++-- tests/ui/privacy/private-in-public-warn.rs | 3 + .../ui/privacy/private-in-public-warn.stderr | 138 +++++++++++------- tests/ui/privacy/pub-priv-dep/pub-priv1.rs | 1 + .../ui/privacy/pub-priv-dep/pub-priv1.stderr | 74 +++++----- 5 files changed, 148 insertions(+), 94 deletions(-) diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index d4d0727dc479..a8046e705732 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -312,6 +312,18 @@ where } } +fn assoc_has_type_of(tcx: TyCtxt<'_>, item: &ty::AssocItem) -> bool { + if let ty::AssocKind::Type { data: ty::AssocTypeData::Normal(..) } = item.kind + && let hir::Node::TraitItem(item) = + tcx.hir_node(tcx.local_def_id_to_hir_id(item.def_id.expect_local())) + && let hir::TraitItemKind::Type(_, None) = item.kind + { + false + } else { + true + } +} + fn min(vis1: ty::Visibility, vis2: ty::Visibility, tcx: TyCtxt<'_>) -> ty::Visibility { if vis1.is_at_least(vis2, tcx) { vis2 } else { vis1 } } @@ -680,10 +692,7 @@ impl<'tcx> EmbargoVisitor<'tcx> { let tcx = self.tcx; let mut reach = self.reach(def_id, item_ev); reach.generics().predicates(); - - if assoc_item.is_type() && !assoc_item.defaultness(tcx).has_value() { - // No type to visit. - } else { + if assoc_has_type_of(tcx, assoc_item) { reach.ty(); } } @@ -1583,14 +1592,11 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> { ) { let mut check = self.check(item.def_id.expect_local(), vis, effective_vis); - let (check_ty, is_assoc_ty) = match item.kind { - ty::AssocKind::Const { .. } | ty::AssocKind::Fn { .. } => (true, false), - ty::AssocKind::Type { .. } => (item.defaultness(self.tcx).has_value(), true), - }; - + let is_assoc_ty = item.is_type(); check.hard_error = is_assoc_ty && !item.is_impl_trait_in_trait(); check.generics().predicates(); - if check_ty { + 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 { diff --git a/tests/ui/privacy/private-in-public-warn.rs b/tests/ui/privacy/private-in-public-warn.rs index 9f2958e88298..6a0ac2b9ade7 100644 --- a/tests/ui/privacy/private-in-public-warn.rs +++ b/tests/ui/privacy/private-in-public-warn.rs @@ -50,6 +50,7 @@ mod traits { //~^ 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 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 trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}` @@ -94,6 +95,8 @@ mod generics { 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 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}` diff --git a/tests/ui/privacy/private-in-public-warn.stderr b/tests/ui/privacy/private-in-public-warn.stderr index 7ec023b9f89f..1fa415e27c16 100644 --- a/tests/ui/privacy/private-in-public-warn.stderr +++ b/tests/ui/privacy/private-in-public-warn.stderr @@ -206,8 +206,20 @@ 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}` + --> $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 {} + | ^^^^^^^^^^^^ + error: trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:53:19 + --> $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)` @@ -219,7 +231,7 @@ LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:53:19 + --> $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)` @@ -231,7 +243,7 @@ LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `traits::PrivTr` is more private than the item `traits::Pub` - --> $DIR/private-in-public-warn.rs:57:5 + --> $DIR/private-in-public-warn.rs:58:5 | LL | impl Pub {} | ^^^^^^^^^^^^^^^^^^^^^^ implementation `traits::Pub` is reachable at visibility `pub(crate)` @@ -243,175 +255,199 @@ LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `traits_where::PrivTr` is more private than the item `traits_where::Alias` - --> $DIR/private-in-public-warn.rs:66:5 + --> $DIR/private-in-public-warn.rs:67:5 | LL | pub type Alias where T: PrivTr = T; | ^^^^^^^^^^^^^^^^^ type alias `traits_where::Alias` is reachable at visibility `pub(crate)` | note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:62:5 + --> $DIR/private-in-public-warn.rs:63:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `traits_where::PrivTr` is more private than the item `traits_where::Tr2` - --> $DIR/private-in-public-warn.rs:69:5 + --> $DIR/private-in-public-warn.rs:70:5 | LL | pub trait Tr2 where T: PrivTr {} | ^^^^^^^^^^^^^^^^ trait `traits_where::Tr2` is reachable at visibility `pub(crate)` | note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:62:5 + --> $DIR/private-in-public-warn.rs:63:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `traits_where::PrivTr` is more private than the item `traits_where::Tr3::f` - --> $DIR/private-in-public-warn.rs:72:9 + --> $DIR/private-in-public-warn.rs:73:9 | LL | fn f(arg: T) where T: PrivTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated function `traits_where::Tr3::f` is reachable at visibility `pub(crate)` | note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:62:5 + --> $DIR/private-in-public-warn.rs:63:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `traits_where::PrivTr` is more private than the item `traits_where::Pub` - --> $DIR/private-in-public-warn.rs:75:5 + --> $DIR/private-in-public-warn.rs:76:5 | LL | impl Pub where T: PrivTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation `traits_where::Pub` is reachable at visibility `pub(crate)` | note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:62:5 + --> $DIR/private-in-public-warn.rs:63:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^ error: trait `generics::PrivTr` is more private than the item `generics::Tr1` - --> $DIR/private-in-public-warn.rs:87:5 + --> $DIR/private-in-public-warn.rs:88:5 | LL | pub trait Tr1: PrivTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `generics::Tr1` is reachable at visibility `pub(crate)` | note: but trait `generics::PrivTr` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:83:5 + --> $DIR/private-in-public-warn.rs:84:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^^^^ error: type `generics::Priv` is more private than the item `generics::Tr2` - --> $DIR/private-in-public-warn.rs:89:5 + --> $DIR/private-in-public-warn.rs:90:5 | LL | pub trait Tr2: PubTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `generics::Tr2` is reachable at visibility `pub(crate)` | note: but type `generics::Priv` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:81:5 + --> $DIR/private-in-public-warn.rs:82:5 | LL | struct Priv(T); | ^^^^^^^^^^^^^^^^^^^ error: type `generics::Priv` is more private than the item `generics::Tr3` - --> $DIR/private-in-public-warn.rs:90:5 + --> $DIR/private-in-public-warn.rs:91:5 | LL | pub trait Tr3: PubTr<[Priv; 1]> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `generics::Tr3` is reachable at visibility `pub(crate)` | note: but type `generics::Priv` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:81:5 + --> $DIR/private-in-public-warn.rs:82:5 | LL | struct Priv(T); | ^^^^^^^^^^^^^^^^^^^ error: type `generics::Priv` is more private than the item `Tr4` - --> $DIR/private-in-public-warn.rs:91:5 + --> $DIR/private-in-public-warn.rs:92:5 | LL | pub trait Tr4: PubTr> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `Tr4` is reachable at visibility `pub(crate)` | note: but type `generics::Priv` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:81:5 + --> $DIR/private-in-public-warn.rs:82:5 | LL | struct Priv(T); | ^^^^^^^^^^^^^^^^^^^ error: trait `generics::PrivTr>` is more private than the item `Tr5::required::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:94:26 + --> $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:83:5 + --> $DIR/private-in-public-warn.rs:84:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^^^^ error: type `generics::Priv<()>` is more private than the item `Tr5::required::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:94:26 + --> $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:81:5 + --> $DIR/private-in-public-warn.rs:82:5 + | +LL | struct Priv(T); + | ^^^^^^^^^^^^^^^^^^^ + +error: trait `generics::PrivTr>` is more private than the item `Tr5::required::{anon_assoc#0}` + --> $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 {} + | ^^^^^^^^^^^^^^^ + +error: type `generics::Priv<()>` is more private than the item `Tr5::required::{anon_assoc#0}` + --> $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); | ^^^^^^^^^^^^^^^^^^^ error: trait `generics::PrivTr>` is more private than the item `Tr5::provided::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:97:26 + --> $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:83:5 + --> $DIR/private-in-public-warn.rs:84:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^^^^ error: type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:97:26 + --> $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:81:5 + --> $DIR/private-in-public-warn.rs:82:5 | LL | struct Priv(T); | ^^^^^^^^^^^^^^^^^^^ error: trait `generics::PrivTr>` is more private than the item `Tr5::provided::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:97:26 + --> $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:83:5 + --> $DIR/private-in-public-warn.rs:84:5 | LL | trait PrivTr {} | ^^^^^^^^^^^^^^^ error: type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}` - --> $DIR/private-in-public-warn.rs:97:26 + --> $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:81:5 + --> $DIR/private-in-public-warn.rs:82:5 | LL | struct Priv(T); | ^^^^^^^^^^^^^^^^^^^ error[E0446]: private type `impls::Priv` in public interface - --> $DIR/private-in-public-warn.rs:128:9 + --> $DIR/private-in-public-warn.rs:131:9 | LL | struct Priv; | ----------- `impls::Priv` declared as private @@ -420,26 +456,17 @@ LL | type Alias = Priv; | ^^^^^^^^^^ can't leak private type error: type `aliases_pub::Priv` is more private than the item `aliases_pub::::f` - --> $DIR/private-in-public-warn.rs:199:9 + --> $DIR/private-in-public-warn.rs:202:9 | LL | pub fn f(arg: Priv) {} | ^^^^^^^^^^^^^^^^^^^ associated function `aliases_pub::::f` is reachable at visibility `pub(crate)` | note: but type `aliases_pub::Priv` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:172:5 + --> $DIR/private-in-public-warn.rs:175:5 | LL | struct Priv; | ^^^^^^^^^^^ -error[E0446]: private type `aliases_pub::Priv` in public interface - --> $DIR/private-in-public-warn.rs:202:9 - | -LL | struct Priv; - | ----------- `aliases_pub::Priv` declared as private -... -LL | type Check = Priv; - | ^^^^^^^^^^ can't leak private type - error[E0446]: private type `aliases_pub::Priv` in public interface --> $DIR/private-in-public-warn.rs:205:9 | @@ -467,38 +494,47 @@ LL | struct Priv; LL | type Check = Priv; | ^^^^^^^^^^ can't leak private type +error[E0446]: private type `aliases_pub::Priv` in public interface + --> $DIR/private-in-public-warn.rs:214:9 + | +LL | struct Priv; + | ----------- `aliases_pub::Priv` declared as private +... +LL | type Check = Priv; + | ^^^^^^^^^^ can't leak private type + error: trait `PrivTr1` is more private than the item `aliases_priv::Tr1` - --> $DIR/private-in-public-warn.rs:241:5 + --> $DIR/private-in-public-warn.rs:244:5 | LL | pub trait Tr1: PrivUseAliasTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `aliases_priv::Tr1` is reachable at visibility `pub(crate)` | note: but trait `PrivTr1` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:227:5 + --> $DIR/private-in-public-warn.rs:230:5 | LL | trait PrivTr1 { | ^^^^^^^^^^^^^^^^^^^^^ error: trait `PrivTr1` is more private than the item `aliases_priv::Tr2` - --> $DIR/private-in-public-warn.rs:243:5 + --> $DIR/private-in-public-warn.rs:246:5 | LL | pub trait Tr2: PrivUseAliasTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `aliases_priv::Tr2` is reachable at visibility `pub(crate)` | note: but trait `PrivTr1` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:227:5 + --> $DIR/private-in-public-warn.rs:230:5 | LL | trait PrivTr1 { | ^^^^^^^^^^^^^^^^^^^^^ error: type `Priv2` is more private than the item `aliases_priv::Tr2` - --> $DIR/private-in-public-warn.rs:243:5 + --> $DIR/private-in-public-warn.rs:246:5 | LL | pub trait Tr2: PrivUseAliasTr {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `aliases_priv::Tr2` is reachable at visibility `pub(crate)` | note: but type `Priv2` is only usable at visibility `pub(self)` - --> $DIR/private-in-public-warn.rs:225:5 + --> $DIR/private-in-public-warn.rs:228:5 | LL | struct Priv2; | ^^^^^^^^^^^^ @@ -518,7 +554,7 @@ LL | pub type Alias = T; = note: `#[warn(type_alias_bounds)]` on by default warning: where clauses on type aliases are not enforced - --> $DIR/private-in-public-warn.rs:66:29 + --> $DIR/private-in-public-warn.rs:67:29 | LL | pub type Alias where T: PrivTr = T; | ------^^^^^^^^^ @@ -530,6 +566,6 @@ LL | pub type Alias where T: PrivTr = T; see issue #112792 for more information = help: add `#![feature(lazy_type_alias)]` to the crate attributes to enable the desired semantics -error: aborting due to 43 previous errors; 2 warnings emitted +error: aborting due to 46 previous errors; 2 warnings emitted For more information about this error, try `rustc --explain E0446`. diff --git a/tests/ui/privacy/pub-priv-dep/pub-priv1.rs b/tests/ui/privacy/pub-priv-dep/pub-priv1.rs index 9093b0808fdb..ae86be19cf96 100644 --- a/tests/ui/privacy/pub-priv-dep/pub-priv1.rs +++ b/tests/ui/privacy/pub-priv-dep/pub-priv1.rs @@ -75,6 +75,7 @@ pub trait MyPubTrait { fn required_impl_trait() -> impl OtherTrait; //~^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface + //~| ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface fn provided_impl_trait() -> impl OtherTrait { OtherType } //~^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface diff --git a/tests/ui/privacy/pub-priv-dep/pub-priv1.stderr b/tests/ui/privacy/pub-priv-dep/pub-priv1.stderr index 61c948c2817a..609dbd77f9c1 100644 --- a/tests/ui/privacy/pub-priv-dep/pub-priv1.stderr +++ b/tests/ui/privacy/pub-priv-dep/pub-priv1.stderr @@ -11,55 +11,55 @@ LL | #![deny(exported_private_dependencies)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: macro `m` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:159:9 + --> $DIR/pub-priv1.rs:160:9 | LL | pub use priv_dep::m; | ^^^^^^^^^^^ error: macro `fn_like` from private dependency 'pm' is re-exported - --> $DIR/pub-priv1.rs:161:9 + --> $DIR/pub-priv1.rs:162:9 | LL | pub use pm::fn_like; | ^^^^^^^^^^^ error: derive macro `PmDerive` from private dependency 'pm' is re-exported - --> $DIR/pub-priv1.rs:163:9 + --> $DIR/pub-priv1.rs:164:9 | LL | pub use pm::PmDerive; | ^^^^^^^^^^^^ error: attribute macro `pm_attr` from private dependency 'pm' is re-exported - --> $DIR/pub-priv1.rs:165:9 + --> $DIR/pub-priv1.rs:166:9 | LL | pub use pm::pm_attr; | ^^^^^^^^^^^ error: variant `V1` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:168:9 + --> $DIR/pub-priv1.rs:169:9 | LL | pub use priv_dep::E::V1; | ^^^^^^^^^^^^^^^ error: type alias `Unit` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:171:9 + --> $DIR/pub-priv1.rs:172:9 | LL | pub use priv_dep::Unit; | ^^^^^^^^^^^^^^ error: type alias `PubPub` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:173:9 + --> $DIR/pub-priv1.rs:174:9 | LL | pub use priv_dep::PubPub; | ^^^^^^^^^^^^^^^^ error: type alias `PubPriv` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:175:9 + --> $DIR/pub-priv1.rs:176:9 | LL | pub use priv_dep::PubPriv; | ^^^^^^^^^^^^^^^^^ error: struct `Renamed` from private dependency 'priv_dep' is re-exported - --> $DIR/pub-priv1.rs:177:9 + --> $DIR/pub-priv1.rs:178:9 | LL | pub use priv_dep::OtherType as Renamed; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -131,13 +131,21 @@ LL | fn required_impl_trait() -> impl OtherTrait; | ^^^^^^^^^^^^^^^ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:79:33 + --> $DIR/pub-priv1.rs:76:33 + | +LL | fn required_impl_trait() -> impl OtherTrait; + | ^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: trait `OtherTrait` from private dependency 'priv_dep' in public interface + --> $DIR/pub-priv1.rs:80:33 | LL | fn provided_impl_trait() -> impl OtherTrait { OtherType } | ^^^^^^^^^^^^^^^ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:79:33 + --> $DIR/pub-priv1.rs:80:33 | LL | fn provided_impl_trait() -> impl OtherTrait { OtherType } | ^^^^^^^^^^^^^^^ @@ -145,91 +153,91 @@ LL | fn provided_impl_trait() -> impl OtherTrait { OtherType } = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:83:5 + --> $DIR/pub-priv1.rs:84:5 | LL | fn required_concrete() -> OtherType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:86:5 + --> $DIR/pub-priv1.rs:87:5 | LL | fn provided_concrete() -> OtherType { OtherType } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:90:1 + --> $DIR/pub-priv1.rs:91:1 | LL | pub trait WithSuperTrait: OtherTrait {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:99:5 + --> $DIR/pub-priv1.rs:100:5 | LL | type X = OtherType; | ^^^^^^ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:103:1 + --> $DIR/pub-priv1.rs:104:1 | LL | pub fn in_bounds(x: T) { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:106:1 + --> $DIR/pub-priv1.rs:107:1 | LL | pub fn private_return_impl_trait() -> impl OtherTrait { OtherType } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:109:1 + --> $DIR/pub-priv1.rs:110:1 | LL | pub fn private_return() -> OtherType { OtherType } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:112:1 + --> $DIR/pub-priv1.rs:113:1 | LL | pub fn private_in_generic() -> std::num::Saturating { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:115:1 + --> $DIR/pub-priv1.rs:116:1 | LL | pub static STATIC: OtherType = OtherType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:118:1 + --> $DIR/pub-priv1.rs:119:1 | LL | pub const CONST: OtherType = OtherType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:121:1 + --> $DIR/pub-priv1.rs:122:1 | LL | pub type Alias = OtherType; | ^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:124:1 + --> $DIR/pub-priv1.rs:125:1 | LL | pub type AliasOfAlias = priv_dep::PubPub; | ^^^^^^^^^^^^^^^^^^^^^ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:129:1 + --> $DIR/pub-priv1.rs:130:1 | LL | impl OtherTrait for PublicWithPrivateImpl {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:134:1 + --> $DIR/pub-priv1.rs:135:1 | LL | impl PubTraitOnPrivate for OtherType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:134:1 + --> $DIR/pub-priv1.rs:135:1 | LL | impl PubTraitOnPrivate for OtherType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -237,25 +245,25 @@ LL | impl PubTraitOnPrivate for OtherType {} = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:140:1 + --> $DIR/pub-priv1.rs:141:1 | LL | impl From for PublicWithStdImpl { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:142:5 + --> $DIR/pub-priv1.rs:143:5 | LL | fn from(val: OtherType) -> Self { Self } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:146:1 + --> $DIR/pub-priv1.rs:147:1 | LL | impl From for OtherType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:146:1 + --> $DIR/pub-priv1.rs:147:1 | LL | impl From for OtherType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -263,18 +271,18 @@ LL | impl From for OtherType { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:149:5 + --> $DIR/pub-priv1.rs:150:5 | LL | fn from(val: PublicWithStdImpl) -> Self { Self } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:149:5 + --> $DIR/pub-priv1.rs:150:5 | LL | fn from(val: PublicWithStdImpl) -> Self { Self } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 44 previous errors +error: aborting due to 45 previous errors