Auto merge of #151168 - petrochenkov:rprivtit, r=eholk
privacy: Fix privacy lints in RPITITs Visit RPITITs and report `private_interfaces`, `private_bounds` and `exported_private_dependencies` in them (these are regular, non-deprecation lints). New hard errors are not reported, https://github.com/rust-lang/rust/pull/146470 is for hard errors. So this PR doesn't contain any breakage or language changes.
This commit is contained in:
commit
ef2657cbaf
19 changed files with 574 additions and 163 deletions
|
|
@ -1,5 +1,6 @@
|
|||
// tidy-alphabetical-start
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(default_field_values)]
|
||||
#![feature(try_blocks)]
|
||||
// tidy-alphabetical-end
|
||||
|
||||
|
|
@ -29,8 +30,8 @@ use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility,
|
|||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::print::PrintTraitRefExt as _;
|
||||
use rustc_middle::ty::{
|
||||
self, Const, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
|
||||
TypeVisitor,
|
||||
self, AssocContainer, Const, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeSuperVisitable,
|
||||
TypeVisitable, TypeVisitor,
|
||||
};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_session::lint;
|
||||
|
|
@ -311,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 }
|
||||
}
|
||||
|
|
@ -639,6 +652,19 @@ impl<'tcx> EmbargoVisitor<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> EmbargoVisitor<'tcx> {
|
||||
fn check_assoc_item(&mut self, item: &ty::AssocItem, item_ev: EffectiveVisibility) {
|
||||
let def_id = item.def_id.expect_local();
|
||||
let tcx = self.tcx;
|
||||
let mut reach = self.reach(def_id, item_ev);
|
||||
reach.generics().predicates();
|
||||
if assoc_has_type_of(tcx, item) {
|
||||
reach.ty();
|
||||
}
|
||||
if item.is_type() && item.container == AssocContainer::Trait {
|
||||
reach.bounds();
|
||||
}
|
||||
}
|
||||
|
||||
fn check_def_id(&mut self, owner_id: OwnerId) {
|
||||
// Update levels of nested things and mark all items
|
||||
// in interfaces of reachable items as reachable.
|
||||
|
|
@ -669,22 +695,10 @@ impl<'tcx> EmbargoVisitor<'tcx> {
|
|||
self.reach(owner_id.def_id, item_ev).generics().predicates();
|
||||
|
||||
for assoc_item in self.tcx.associated_items(owner_id).in_definition_order() {
|
||||
if assoc_item.is_impl_trait_in_trait() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let def_id = assoc_item.def_id.expect_local();
|
||||
self.update(def_id, item_ev, Level::Reachable);
|
||||
|
||||
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 {
|
||||
reach.ty();
|
||||
}
|
||||
self.check_assoc_item(assoc_item, item_ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -722,17 +736,13 @@ impl<'tcx> EmbargoVisitor<'tcx> {
|
|||
}
|
||||
|
||||
for assoc_item in self.tcx.associated_items(owner_id).in_definition_order() {
|
||||
if assoc_item.is_impl_trait_in_trait() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let def_id = assoc_item.def_id.expect_local();
|
||||
let max_vis =
|
||||
if of_trait { None } else { Some(self.tcx.local_visibility(def_id)) };
|
||||
self.update_eff_vis(def_id, item_ev, max_vis, Level::Direct);
|
||||
|
||||
if let Some(impl_item_ev) = self.get(def_id) {
|
||||
self.reach(def_id, impl_item_ev).generics().predicates().ty();
|
||||
self.check_assoc_item(assoc_item, impl_item_ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -824,7 +834,12 @@ impl ReachEverythingInTheInterfaceVisitor<'_, '_> {
|
|||
}
|
||||
|
||||
fn predicates(&mut self) -> &mut Self {
|
||||
self.visit_predicates(self.ev.tcx.predicates_of(self.item_def_id));
|
||||
self.visit_predicates(self.ev.tcx.explicit_predicates_of(self.item_def_id));
|
||||
self
|
||||
}
|
||||
|
||||
fn bounds(&mut self) -> &mut Self {
|
||||
self.visit_clauses(self.ev.tcx.explicit_item_bounds(self.item_def_id).skip_binder());
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -1353,26 +1368,20 @@ struct SearchInterfaceForPrivateItemsVisitor<'tcx> {
|
|||
/// The visitor checks that each component type is at least this visible.
|
||||
required_visibility: ty::Visibility,
|
||||
required_effective_vis: Option<EffectiveVisibility>,
|
||||
in_assoc_ty: bool,
|
||||
in_primary_interface: bool,
|
||||
skip_assoc_tys: bool,
|
||||
hard_error: bool = false,
|
||||
in_primary_interface: bool = true,
|
||||
skip_assoc_tys: bool = false,
|
||||
}
|
||||
|
||||
impl SearchInterfaceForPrivateItemsVisitor<'_> {
|
||||
fn generics(&mut self) -> &mut Self {
|
||||
self.in_primary_interface = true;
|
||||
for param in &self.tcx.generics_of(self.item_def_id).own_params {
|
||||
match param.kind {
|
||||
GenericParamDefKind::Lifetime => {}
|
||||
GenericParamDefKind::Type { has_default, .. } => {
|
||||
if has_default {
|
||||
let _ = self.visit(self.tcx.type_of(param.def_id).instantiate_identity());
|
||||
}
|
||||
}
|
||||
// FIXME(generic_const_exprs): May want to look inside const here
|
||||
GenericParamDefKind::Const { .. } => {
|
||||
let _ = self.visit(self.tcx.type_of(param.def_id).instantiate_identity());
|
||||
}
|
||||
if let GenericParamDefKind::Const { .. } = param.kind {
|
||||
let _ = self.visit(self.tcx.type_of(param.def_id).instantiate_identity());
|
||||
}
|
||||
if let Some(default) = param.default_value(self.tcx) {
|
||||
let _ = self.visit(default.instantiate_identity());
|
||||
}
|
||||
}
|
||||
self
|
||||
|
|
@ -1427,7 +1436,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
|
|||
};
|
||||
|
||||
let vis = self.tcx.local_visibility(local_def_id);
|
||||
if self.in_assoc_ty && !vis.is_at_least(self.required_visibility, self.tcx) {
|
||||
if self.hard_error && !vis.is_at_least(self.required_visibility, self.tcx) {
|
||||
let vis_descr = match vis {
|
||||
ty::Visibility::Public => "public",
|
||||
ty::Visibility::Restricted(vis_def_id) => {
|
||||
|
|
@ -1544,9 +1553,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
|
|||
item_def_id: def_id,
|
||||
required_visibility,
|
||||
required_effective_vis,
|
||||
in_assoc_ty: false,
|
||||
in_primary_interface: true,
|
||||
skip_assoc_tys: false,
|
||||
..
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1584,16 +1591,17 @@ 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),
|
||||
};
|
||||
|
||||
check.in_assoc_ty = is_assoc_ty;
|
||||
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 {
|
||||
check.hard_error = false;
|
||||
check.bounds();
|
||||
}
|
||||
}
|
||||
|
||||
fn get(&self, def_id: LocalDefId) -> Option<EffectiveVisibility> {
|
||||
|
|
@ -1625,20 +1633,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
|
|||
self.check(def_id, item_visibility, effective_vis).generics().predicates();
|
||||
|
||||
for assoc_item in tcx.associated_items(id.owner_id).in_definition_order() {
|
||||
if assoc_item.is_impl_trait_in_trait() {
|
||||
continue;
|
||||
}
|
||||
|
||||
self.check_assoc_item(assoc_item, item_visibility, effective_vis);
|
||||
|
||||
if assoc_item.is_type() {
|
||||
self.check(
|
||||
assoc_item.def_id.expect_local(),
|
||||
item_visibility,
|
||||
effective_vis,
|
||||
)
|
||||
.bounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
DefKind::TraitAlias => {
|
||||
|
|
@ -1712,10 +1707,6 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
|
|||
}
|
||||
|
||||
for assoc_item in tcx.associated_items(id.owner_id).in_definition_order() {
|
||||
if assoc_item.is_impl_trait_in_trait() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let impl_item_vis = if !of_trait {
|
||||
min(tcx.local_visibility(assoc_item.def_id.expect_local()), impl_vis, tcx)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -108,6 +108,18 @@ LL | fn foo() -> impl Iterator<Item = i32, Item = u32> {
|
|||
LL | [2u32].into_iter()
|
||||
| ------------------ return type was inferred to be `std::array::IntoIter<u32, 1>` here
|
||||
|
||||
error[E0271]: expected `impl Iterator<Item = u32>` to be an iterator that yields `i32`, but it yields `u32`
|
||||
--> $DIR/duplicate-bound-err.rs:111:17
|
||||
|
|
||||
LL | fn foo() -> impl Iterator<Item = i32, Item = u32> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
|
||||
|
|
||||
note: required by a bound in `Trait3::foo::{anon_assoc#0}`
|
||||
--> $DIR/duplicate-bound-err.rs:107:31
|
||||
|
|
||||
LL | fn foo() -> impl Iterator<Item = i32, Item = u32>;
|
||||
| ^^^^^^^^^^ required by this bound in `Trait3::foo::{anon_assoc#0}`
|
||||
|
||||
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
|
||||
--> $DIR/duplicate-bound-err.rs:87:42
|
||||
|
|
||||
|
|
@ -158,18 +170,6 @@ LL | type MustFail4 = dyn Trait2<ASSOC = 3u32, ASSOC = 3u32>;
|
|||
| |
|
||||
| `ASSOC` bound here first
|
||||
|
||||
error[E0271]: expected `impl Iterator<Item = u32>` to be an iterator that yields `i32`, but it yields `u32`
|
||||
--> $DIR/duplicate-bound-err.rs:111:17
|
||||
|
|
||||
LL | fn foo() -> impl Iterator<Item = i32, Item = u32> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
|
||||
|
|
||||
note: required by a bound in `Trait3::foo::{anon_assoc#0}`
|
||||
--> $DIR/duplicate-bound-err.rs:107:31
|
||||
|
|
||||
LL | fn foo() -> impl Iterator<Item = i32, Item = u32>;
|
||||
| ^^^^^^^^^^ required by this bound in `Trait3::foo::{anon_assoc#0}`
|
||||
|
||||
error[E0271]: expected `Empty<u32>` to be an iterator that yields `i32`, but it yields `u32`
|
||||
--> $DIR/duplicate-bound-err.rs:119:16
|
||||
|
|
||||
|
|
|
|||
|
|
@ -29,11 +29,7 @@ note: ...which requires comparing an impl and trait method signature, inferring
|
|||
LL | reuse ToReuse::opaque_ret;
|
||||
| ^^^^^^^^^^
|
||||
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`, completing the cycle
|
||||
note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret` is compatible with trait definition
|
||||
--> $DIR/unsupported.rs:33:24
|
||||
|
|
||||
LL | reuse ToReuse::opaque_ret;
|
||||
| ^^^^^^^^^^
|
||||
= note: cycle used when checking effective visibilities
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
error[E0283]: type annotations needed
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ note: ...which requires comparing an impl and trait method signature, inferring
|
|||
LL | reuse ToReuse::opaque_ret;
|
||||
| ^^^^^^^^^^
|
||||
= note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`, completing the cycle
|
||||
= note: cycle used when computing implied outlives bounds for `<u16 as opaque::ToReuse>::opaque_ret::{anon_assoc#0}` (hack disabled = false)
|
||||
= note: cycle used when checking effective visibilities
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
error[E0283]: type annotations needed
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
warning: use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:97:48
|
||||
warning: use of deprecated function `lint_stability::deprecated`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:24:9
|
||||
|
|
||||
LL | struct S2<T: TraitWithAssociatedTypes>(T::TypeDeprecated);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
LL | deprecated();
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-stability-deprecated.rs:6:9
|
||||
|
|
@ -10,12 +10,6 @@ note: the lint level is defined here
|
|||
LL | #![warn(deprecated)]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
warning: use of deprecated function `lint_stability::deprecated`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:24:9
|
||||
|
|
||||
LL | deprecated();
|
||||
| ^^^^^^^^^^
|
||||
|
||||
warning: use of deprecated method `lint_stability::Trait::trait_deprecated`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:29:16
|
||||
|
|
||||
|
|
@ -322,6 +316,12 @@ warning: use of deprecated function `this_crate::MethodTester::test_method_body:
|
|||
LL | fn_in_body();
|
||||
| ^^^^^^^^^^
|
||||
|
||||
warning: use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:97:48
|
||||
|
|
||||
LL | struct S2<T: TraitWithAssociatedTypes>(T::TypeDeprecated);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text
|
||||
--> $DIR/lint-stability-deprecated.rs:101:13
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,12 +1,3 @@
|
|||
error[E0658]: use of unstable library feature `unstable_test_feature`
|
||||
--> $DIR/lint-stability.rs:88:48
|
||||
|
|
||||
LL | struct S1<T: TraitWithAssociatedTypes>(T::TypeUnstable);
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: use of unstable library feature `unstable_test_feature`
|
||||
--> $DIR/lint-stability.rs:17:5
|
||||
|
|
||||
|
|
@ -376,6 +367,15 @@ LL | let _ = Unstable::StableVariant;
|
|||
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: use of unstable library feature `unstable_test_feature`
|
||||
--> $DIR/lint-stability.rs:88:48
|
||||
|
|
||||
LL | struct S1<T: TraitWithAssociatedTypes>(T::TypeUnstable);
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: use of unstable library feature `unstable_test_feature`
|
||||
--> $DIR/lint-stability.rs:92:13
|
||||
|
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
// Doesn't involve `impl Trait` unlike missing-mir-priv-bounds-extern.rs
|
||||
|
||||
pub trait ToPriv {
|
||||
type AssocPriv;
|
||||
}
|
||||
|
||||
pub trait PubTr {
|
||||
#[expect(private_bounds)]
|
||||
type Assoc: ToPriv<AssocPriv = Priv>;
|
||||
}
|
||||
|
||||
// Dummy and DummyToPriv are only used in call_handler
|
||||
struct Dummy;
|
||||
struct DummyToPriv;
|
||||
impl PubTr for Dummy {
|
||||
type Assoc = DummyToPriv;
|
||||
}
|
||||
impl ToPriv for DummyToPriv {
|
||||
type AssocPriv = Priv;
|
||||
}
|
||||
|
||||
pub trait PubTrHandler {
|
||||
fn handle<T: PubTr>();
|
||||
}
|
||||
pub fn call_handler<T: PubTrHandler>() {
|
||||
T::handle::<Dummy>();
|
||||
}
|
||||
|
||||
struct Priv;
|
||||
|
||||
pub trait GetUnreachable {
|
||||
type Assoc;
|
||||
}
|
||||
|
||||
mod m {
|
||||
pub struct Unreachable;
|
||||
|
||||
impl Unreachable {
|
||||
#[expect(dead_code)]
|
||||
pub fn generic<T>() {}
|
||||
}
|
||||
|
||||
impl crate::GetUnreachable for crate::Priv {
|
||||
type Assoc = Unreachable;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
struct Priv;
|
||||
|
||||
pub trait Super {
|
||||
type AssocSuper: GetUnreachable;
|
||||
}
|
||||
#[expect(private_bounds)]
|
||||
pub trait Sub: Super<AssocSuper = Priv> {}
|
||||
|
||||
// This Dummy type is only used in call_handler
|
||||
struct Dummy;
|
||||
impl Super for Dummy {
|
||||
type AssocSuper = Priv;
|
||||
}
|
||||
impl Sub for Dummy {}
|
||||
|
||||
pub trait SubHandler {
|
||||
fn handle<T: Sub>();
|
||||
}
|
||||
pub fn call_handler<T: SubHandler>() {
|
||||
<T as SubHandler>::handle::<Dummy>();
|
||||
}
|
||||
|
||||
pub trait GetUnreachable {
|
||||
type Assoc;
|
||||
}
|
||||
mod m {
|
||||
pub struct Unreachable;
|
||||
impl Unreachable {
|
||||
#[expect(dead_code)]
|
||||
pub fn generic<T>() {}
|
||||
}
|
||||
impl crate::GetUnreachable for crate::Priv {
|
||||
type Assoc = Unreachable;
|
||||
}
|
||||
}
|
||||
40
tests/ui/privacy/auxiliary/missing-mir-priv-bounds-extern.rs
Normal file
40
tests/ui/privacy/auxiliary/missing-mir-priv-bounds-extern.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
pub trait ToPriv {
|
||||
type AssocPriv;
|
||||
}
|
||||
|
||||
pub trait PubTr {
|
||||
#[expect(private_bounds)]
|
||||
type Assoc: ToPriv<AssocPriv = Priv>;
|
||||
}
|
||||
|
||||
struct Dummy;
|
||||
struct DummyToPriv;
|
||||
impl PubTr for Dummy {
|
||||
type Assoc = DummyToPriv;
|
||||
}
|
||||
impl ToPriv for DummyToPriv {
|
||||
type AssocPriv = Priv;
|
||||
}
|
||||
|
||||
pub fn get_dummy() -> impl PubTr {
|
||||
Dummy
|
||||
}
|
||||
|
||||
struct Priv;
|
||||
|
||||
pub trait GetUnreachable {
|
||||
type Assoc;
|
||||
}
|
||||
|
||||
mod m {
|
||||
pub struct Unreachable;
|
||||
|
||||
impl Unreachable {
|
||||
#[expect(dead_code)]
|
||||
pub fn generic<T>() {}
|
||||
}
|
||||
|
||||
impl crate::GetUnreachable for crate::Priv {
|
||||
type Assoc = Unreachable;
|
||||
}
|
||||
}
|
||||
29
tests/ui/privacy/missing-mir-priv-bounds-2.rs
Normal file
29
tests/ui/privacy/missing-mir-priv-bounds-2.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// Test case from issue #151284.
|
||||
// A private associated type bound allows to leak another private type and result in missing MIR.
|
||||
|
||||
//@ build-fail
|
||||
//@ aux-crate:dep=missing-mir-priv-bounds-extern-2.rs
|
||||
|
||||
extern crate dep;
|
||||
use dep::{GetUnreachable, PubTr, PubTrHandler, ToPriv, call_handler};
|
||||
|
||||
fn main() {
|
||||
call_handler::<Handler>();
|
||||
}
|
||||
|
||||
struct Handler;
|
||||
impl PubTrHandler for Handler {
|
||||
fn handle<T: PubTr>() {
|
||||
<T as Access>::AccessAssoc::generic::<i32>();
|
||||
}
|
||||
}
|
||||
|
||||
trait Access: PubTr {
|
||||
type AccessAssoc;
|
||||
}
|
||||
|
||||
impl<T: PubTr> Access for T {
|
||||
type AccessAssoc = <<T::Assoc as ToPriv>::AssocPriv as GetUnreachable>::Assoc;
|
||||
}
|
||||
|
||||
//~? ERROR missing optimized MIR
|
||||
10
tests/ui/privacy/missing-mir-priv-bounds-2.stderr
Normal file
10
tests/ui/privacy/missing-mir-priv-bounds-2.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: missing optimized MIR for `dep::m::Unreachable::generic::<i32>` in the crate `missing_mir_priv_bounds_extern_2`
|
||||
|
|
||||
note: missing optimized MIR for this item (was the crate `missing_mir_priv_bounds_extern_2` compiled with `--emit=metadata`?)
|
||||
--> $DIR/auxiliary/missing-mir-priv-bounds-extern-2.rs:40:9
|
||||
|
|
||||
LL | pub fn generic<T>() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
30
tests/ui/privacy/missing-mir-priv-bounds-3.rs
Normal file
30
tests/ui/privacy/missing-mir-priv-bounds-3.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// Test case from issue #151479.
|
||||
// A private associated type bound allows to leak another private type and result in missing MIR.
|
||||
|
||||
//@ build-fail
|
||||
//@ aux-crate:dep=missing-mir-priv-bounds-extern-3.rs
|
||||
|
||||
extern crate dep;
|
||||
use dep::{GetUnreachable, Sub, SubHandler, Super, call_handler};
|
||||
|
||||
fn main() {
|
||||
call_handler::<Handler>();
|
||||
}
|
||||
|
||||
struct Handler;
|
||||
impl SubHandler for Handler {
|
||||
fn handle<T: Sub>() {
|
||||
<T as Access>::AccessAssoc::generic::<i32>();
|
||||
}
|
||||
}
|
||||
|
||||
// Without this indirection, Handler::handle notices that
|
||||
// it's mentioning dep::Priv.
|
||||
trait Access: Super {
|
||||
type AccessAssoc;
|
||||
}
|
||||
impl<T: Super> Access for T {
|
||||
type AccessAssoc = <<T as Super>::AssocSuper as GetUnreachable>::Assoc;
|
||||
}
|
||||
|
||||
//~? ERROR missing optimized MIR
|
||||
10
tests/ui/privacy/missing-mir-priv-bounds-3.stderr
Normal file
10
tests/ui/privacy/missing-mir-priv-bounds-3.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: missing optimized MIR for `dep::m::Unreachable::generic::<i32>` in the crate `missing_mir_priv_bounds_extern_3`
|
||||
|
|
||||
note: missing optimized MIR for this item (was the crate `missing_mir_priv_bounds_extern_3` compiled with `--emit=metadata`?)
|
||||
--> $DIR/auxiliary/missing-mir-priv-bounds-extern-3.rs:30:9
|
||||
|
|
||||
LL | pub fn generic<T>() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
26
tests/ui/privacy/missing-mir-priv-bounds.rs
Normal file
26
tests/ui/privacy/missing-mir-priv-bounds.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// Test case from issue #151284.
|
||||
// A private associated type bound allows to leak another private type and result in missing MIR.
|
||||
|
||||
//@ build-fail
|
||||
//@ aux-crate:dep=missing-mir-priv-bounds-extern.rs
|
||||
|
||||
extern crate dep;
|
||||
use dep::{GetUnreachable, PubTr, ToPriv, get_dummy};
|
||||
|
||||
fn main() {
|
||||
wut(get_dummy());
|
||||
}
|
||||
|
||||
fn wut<T: PubTr>(_: T) {
|
||||
<T as Access>::AccessAssoc::generic::<i32>();
|
||||
}
|
||||
|
||||
trait Access: PubTr {
|
||||
type AccessAssoc;
|
||||
}
|
||||
|
||||
impl<T: PubTr> Access for T {
|
||||
type AccessAssoc = <<T::Assoc as ToPriv>::AssocPriv as GetUnreachable>::Assoc;
|
||||
}
|
||||
|
||||
//~? ERROR missing optimized MIR
|
||||
10
tests/ui/privacy/missing-mir-priv-bounds.stderr
Normal file
10
tests/ui/privacy/missing-mir-priv-bounds.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: missing optimized MIR for `dep::m::Unreachable::generic::<i32>` in the crate `missing_mir_priv_bounds_extern`
|
||||
|
|
||||
note: missing optimized MIR for this item (was the crate `missing_mir_priv_bounds_extern` compiled with `--emit=metadata`?)
|
||||
--> $DIR/auxiliary/missing-mir-priv-bounds-extern.rs:34:9
|
||||
|
|
||||
LL | pub fn generic<T>() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
@ -49,7 +49,11 @@ mod traits {
|
|||
fn f<T: PrivTr>(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 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}`
|
||||
}
|
||||
impl<T: PrivTr> Pub<T> {} //~ ERROR trait `traits::PrivTr` is more private than the item `traits::Pub<T>`
|
||||
impl<T: PrivTr> PubTr for Pub<T> {} // OK, trait impl predicates
|
||||
|
|
@ -89,7 +93,15 @@ mod generics {
|
|||
|
||||
pub trait Tr5 {
|
||||
fn required() -> impl PrivTr<Priv<()>>;
|
||||
//~^ ERROR trait `generics::PrivTr<generics::Priv<()>>` 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<generics::Priv<()>>` 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<Priv<()>> {}
|
||||
//~^ ERROR trait `generics::PrivTr<generics::Priv<()>>` 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 trait `generics::PrivTr<generics::Priv<()>>` 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}`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -194,8 +194,56 @@ 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::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: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 {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}`
|
||||
--> $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 {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: trait `traits::PrivTr` is more private than the item `traits::Pub<T>`
|
||||
--> $DIR/private-in-public-warn.rs:54:5
|
||||
--> $DIR/private-in-public-warn.rs:58:5
|
||||
|
|
||||
LL | impl<T: PrivTr> Pub<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ implementation `traits::Pub<T>` is reachable at visibility `pub(crate)`
|
||||
|
|
@ -207,103 +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:63:5
|
||||
--> $DIR/private-in-public-warn.rs:67:5
|
||||
|
|
||||
LL | pub type Alias<T> 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:59: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:66:5
|
||||
--> $DIR/private-in-public-warn.rs:70:5
|
||||
|
|
||||
LL | pub trait Tr2<T> 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:59: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:69:9
|
||||
--> $DIR/private-in-public-warn.rs:73:9
|
||||
|
|
||||
LL | fn f<T>(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:59: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<T>`
|
||||
--> $DIR/private-in-public-warn.rs:72:5
|
||||
--> $DIR/private-in-public-warn.rs:76:5
|
||||
|
|
||||
LL | impl<T> Pub<T> where T: PrivTr {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation `traits_where::Pub<T>` 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:59:5
|
||||
--> $DIR/private-in-public-warn.rs:63:5
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: trait `generics::PrivTr<generics::Pub>` is more private than the item `generics::Tr1`
|
||||
--> $DIR/private-in-public-warn.rs:84:5
|
||||
--> $DIR/private-in-public-warn.rs:88:5
|
||||
|
|
||||
LL | pub trait Tr1: PrivTr<Pub> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `generics::Tr1` is reachable at visibility `pub(crate)`
|
||||
|
|
||||
note: but trait `generics::PrivTr<generics::Pub>` is only usable at visibility `pub(self)`
|
||||
--> $DIR/private-in-public-warn.rs:80:5
|
||||
--> $DIR/private-in-public-warn.rs:84:5
|
||||
|
|
||||
LL | trait PrivTr<T> {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: type `generics::Priv` is more private than the item `generics::Tr2`
|
||||
--> $DIR/private-in-public-warn.rs:86:5
|
||||
--> $DIR/private-in-public-warn.rs:90:5
|
||||
|
|
||||
LL | pub trait Tr2: PubTr<Priv> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:78:5
|
||||
--> $DIR/private-in-public-warn.rs:82:5
|
||||
|
|
||||
LL | struct Priv<T = u8>(T);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: type `generics::Priv` is more private than the item `generics::Tr3`
|
||||
--> $DIR/private-in-public-warn.rs:87: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:78:5
|
||||
--> $DIR/private-in-public-warn.rs:82:5
|
||||
|
|
||||
LL | struct Priv<T = u8>(T);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: type `generics::Priv` is more private than the item `Tr4`
|
||||
--> $DIR/private-in-public-warn.rs:88:5
|
||||
--> $DIR/private-in-public-warn.rs:92:5
|
||||
|
|
||||
LL | pub trait Tr4: PubTr<Pub<Priv>> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:78:5
|
||||
--> $DIR/private-in-public-warn.rs:82:5
|
||||
|
|
||||
LL | struct Priv<T = u8>(T);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait `generics::PrivTr<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<Priv<()>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::required::{anon_assoc#0}` is reachable at visibility `pub(crate)`
|
||||
|
|
||||
note: but trait `generics::PrivTr<generics::Priv<()>>` is only usable at visibility `pub(self)`
|
||||
--> $DIR/private-in-public-warn.rs:84:5
|
||||
|
|
||||
LL | trait PrivTr<T> {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
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<Priv<()>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ 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 = u8>(T);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait `generics::PrivTr<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<Priv<()>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::required::{anon_assoc#0}` is reachable at visibility `pub(crate)`
|
||||
|
|
||||
note: but trait `generics::PrivTr<generics::Priv<()>>` is only usable at visibility `pub(self)`
|
||||
--> $DIR/private-in-public-warn.rs:84:5
|
||||
|
|
||||
LL | trait PrivTr<T> {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
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<Priv<()>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ 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 = u8>(T);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait `generics::PrivTr<generics::Priv<()>>` is more private than the item `Tr5::provided::{anon_assoc#0}`
|
||||
--> $DIR/private-in-public-warn.rs:100:26
|
||||
|
|
||||
LL | fn provided() -> impl PrivTr<Priv<()>> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::provided::{anon_assoc#0}` is reachable at visibility `pub(crate)`
|
||||
|
|
||||
note: but trait `generics::PrivTr<generics::Priv<()>>` is only usable at visibility `pub(self)`
|
||||
--> $DIR/private-in-public-warn.rs:84:5
|
||||
|
|
||||
LL | trait PrivTr<T> {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}`
|
||||
--> $DIR/private-in-public-warn.rs:100:26
|
||||
|
|
||||
LL | fn provided() -> impl PrivTr<Priv<()>> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ 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 = u8>(T);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait `generics::PrivTr<generics::Priv<()>>` is more private than the item `Tr5::provided::{anon_assoc#0}`
|
||||
--> $DIR/private-in-public-warn.rs:100:26
|
||||
|
|
||||
LL | fn provided() -> impl PrivTr<Priv<()>> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ opaque type `Tr5::provided::{anon_assoc#0}` is reachable at visibility `pub(crate)`
|
||||
|
|
||||
note: but trait `generics::PrivTr<generics::Priv<()>>` is only usable at visibility `pub(self)`
|
||||
--> $DIR/private-in-public-warn.rs:84:5
|
||||
|
|
||||
LL | trait PrivTr<T> {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}`
|
||||
--> $DIR/private-in-public-warn.rs:100:26
|
||||
|
|
||||
LL | fn provided() -> impl PrivTr<Priv<()>> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ 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 = u8>(T);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0446]: private type `impls::Priv` in public interface
|
||||
--> $DIR/private-in-public-warn.rs:119:9
|
||||
--> $DIR/private-in-public-warn.rs:131:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| ----------- `impls::Priv` declared as private
|
||||
|
|
@ -312,19 +456,19 @@ LL | type Alias = Priv;
|
|||
| ^^^^^^^^^^ can't leak private type
|
||||
|
||||
error: type `aliases_pub::Priv` is more private than the item `aliases_pub::<impl Pub2>::f`
|
||||
--> $DIR/private-in-public-warn.rs:190:9
|
||||
--> $DIR/private-in-public-warn.rs:202:9
|
||||
|
|
||||
LL | pub fn f(arg: Priv) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^ associated function `aliases_pub::<impl Pub2>::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:163: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:193:9
|
||||
--> $DIR/private-in-public-warn.rs:205:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| ----------- `aliases_pub::Priv` declared as private
|
||||
|
|
@ -333,7 +477,7 @@ 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:196:9
|
||||
--> $DIR/private-in-public-warn.rs:208:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| ----------- `aliases_pub::Priv` declared as private
|
||||
|
|
@ -342,7 +486,7 @@ 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:199:9
|
||||
--> $DIR/private-in-public-warn.rs:211:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| ----------- `aliases_pub::Priv` declared as private
|
||||
|
|
@ -351,7 +495,7 @@ 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:202:9
|
||||
--> $DIR/private-in-public-warn.rs:214:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| ----------- `aliases_pub::Priv` declared as private
|
||||
|
|
@ -360,37 +504,37 @@ 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:232: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:218:5
|
||||
--> $DIR/private-in-public-warn.rs:230:5
|
||||
|
|
||||
LL | trait PrivTr1<T = u8> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait `PrivTr1<Priv2>` is more private than the item `aliases_priv::Tr2`
|
||||
--> $DIR/private-in-public-warn.rs:234:5
|
||||
--> $DIR/private-in-public-warn.rs:246:5
|
||||
|
|
||||
LL | pub trait Tr2: PrivUseAliasTr<PrivAlias> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `aliases_priv::Tr2` is reachable at visibility `pub(crate)`
|
||||
|
|
||||
note: but trait `PrivTr1<Priv2>` is only usable at visibility `pub(self)`
|
||||
--> $DIR/private-in-public-warn.rs:218:5
|
||||
--> $DIR/private-in-public-warn.rs:230:5
|
||||
|
|
||||
LL | trait PrivTr1<T = u8> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: type `Priv2` is more private than the item `aliases_priv::Tr2`
|
||||
--> $DIR/private-in-public-warn.rs:234:5
|
||||
--> $DIR/private-in-public-warn.rs:246:5
|
||||
|
|
||||
LL | pub trait Tr2: PrivUseAliasTr<PrivAlias> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:216:5
|
||||
--> $DIR/private-in-public-warn.rs:228:5
|
||||
|
|
||||
LL | struct Priv2;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -410,7 +554,7 @@ LL | pub type Alias<T: PrivTr> = T;
|
|||
= note: `#[warn(type_alias_bounds)]` on by default
|
||||
|
||||
warning: where clauses on type aliases are not enforced
|
||||
--> $DIR/private-in-public-warn.rs:63:29
|
||||
--> $DIR/private-in-public-warn.rs:67:29
|
||||
|
|
||||
LL | pub type Alias<T> where T: PrivTr = T;
|
||||
| ------^^^^^^^^^
|
||||
|
|
@ -422,6 +566,6 @@ LL | pub type Alias<T> where T: PrivTr = T;
|
|||
see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
|
||||
= help: add `#![feature(lazy_type_alias)]` to the crate attributes to enable the desired semantics
|
||||
|
||||
error: aborting due to 34 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`.
|
||||
|
|
|
|||
|
|
@ -74,8 +74,12 @@ pub trait MyPubTrait {
|
|||
//~^ ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
||||
|
||||
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
|
||||
//~| ERROR trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
||||
|
||||
fn required_concrete() -> OtherType;
|
||||
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface
|
||||
|
|
|
|||
|
|
@ -11,55 +11,55 @@ LL | #![deny(exported_private_dependencies)]
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: macro `m` from private dependency 'priv_dep' is re-exported
|
||||
--> $DIR/pub-priv1.rs:156: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:158: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:160: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:162: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:165: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:168: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:170: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:172: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:174:9
|
||||
--> $DIR/pub-priv1.rs:178:9
|
||||
|
|
||||
LL | pub use priv_dep::OtherType as Renamed;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -124,92 +124,120 @@ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
|||
LL | type Foo: OtherTrait;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
||||
--> $DIR/pub-priv1.rs:76:33
|
||||
|
|
||||
LL | fn required_impl_trait() -> impl OtherTrait;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
||||
--> $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:80:33
|
||||
|
|
||||
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:80: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:83: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:87: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:96: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:100:1
|
||||
--> $DIR/pub-priv1.rs:104:1
|
||||
|
|
||||
LL | pub fn in_bounds<T: OtherTrait>(x: T) { unimplemented!() }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
|
||||
--> $DIR/pub-priv1.rs:103: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:106: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:109:1
|
||||
--> $DIR/pub-priv1.rs:113:1
|
||||
|
|
||||
LL | pub fn private_in_generic() -> std::num::Saturating<OtherType> { unimplemented!() }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: type `OtherType` from private dependency 'priv_dep' in public interface
|
||||
--> $DIR/pub-priv1.rs:112: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:115: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:118: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:121: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:126: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:131: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:131:1
|
||||
--> $DIR/pub-priv1.rs:135:1
|
||||
|
|
||||
LL | impl PubTraitOnPrivate for OtherType {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -217,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:137:1
|
||||
--> $DIR/pub-priv1.rs:141:1
|
||||
|
|
||||
LL | impl From<OtherType> for PublicWithStdImpl {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: type `OtherType` from private dependency 'priv_dep' in public interface
|
||||
--> $DIR/pub-priv1.rs:139: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:143:1
|
||||
--> $DIR/pub-priv1.rs:147:1
|
||||
|
|
||||
LL | impl From<PublicWithStdImpl> for OtherType {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: type `OtherType` from private dependency 'priv_dep' in public interface
|
||||
--> $DIR/pub-priv1.rs:143:1
|
||||
--> $DIR/pub-priv1.rs:147:1
|
||||
|
|
||||
LL | impl From<PublicWithStdImpl> for OtherType {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -243,18 +271,18 @@ LL | impl From<PublicWithStdImpl> 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:146: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:146: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 41 previous errors
|
||||
error: aborting due to 45 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue