summaryrefslogtreecommitdiffstats
path: root/tests/ui/privacy
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/ui/privacy/associated-item-privacy-inherent.rs2
-rw-r--r--tests/ui/privacy/associated-item-privacy-trait.rs2
-rw-r--r--tests/ui/privacy/associated-item-privacy-type-binding.rs2
-rw-r--r--tests/ui/privacy/effective_visibilities_full_priv.rs2
-rw-r--r--tests/ui/privacy/issue-30079.rs3
-rw-r--r--tests/ui/privacy/issue-30079.stderr17
-rw-r--r--tests/ui/privacy/private-bounds-locally-allowed.rs7
-rw-r--r--tests/ui/privacy/private-in-public-assoc-ty.rs9
-rw-r--r--tests/ui/privacy/private-in-public-assoc-ty.stderr50
-rw-r--r--tests/ui/privacy/private-in-public-lint.rs19
-rw-r--r--tests/ui/privacy/private-in-public-lint.stderr21
-rw-r--r--tests/ui/privacy/private-in-public-non-principal-2.rs2
-rw-r--r--tests/ui/privacy/private-in-public-non-principal.rs10
-rw-r--r--tests/ui/privacy/private-in-public-non-principal.stderr28
-rw-r--r--tests/ui/privacy/private-in-public-type-alias-impl-trait.rs2
-rw-r--r--tests/ui/privacy/private-in-public-warn.rs85
-rw-r--r--tests/ui/privacy/private-in-public-warn.stderr376
-rw-r--r--tests/ui/privacy/private-in-public.rs66
-rw-r--r--tests/ui/privacy/private-in-public.stderr468
-rw-r--r--tests/ui/privacy/private-inferred-type-2.rs1
-rw-r--r--tests/ui/privacy/private-inferred-type-2.stderr6
-rw-r--r--tests/ui/privacy/private-inferred-type.rs2
-rw-r--r--tests/ui/privacy/private-type-in-interface.rs1
-rw-r--r--tests/ui/privacy/private-type-in-interface.stderr18
-rw-r--r--tests/ui/privacy/restricted/private-in-public.rs5
-rw-r--r--tests/ui/privacy/restricted/private-in-public.stderr21
-rw-r--r--tests/ui/privacy/unnameable_types.rs9
-rw-r--r--tests/ui/privacy/unnameable_types.stderr8
-rw-r--r--tests/ui/privacy/where-priv-type.rs27
-rw-r--r--tests/ui/privacy/where-priv-type.stderr107
-rw-r--r--tests/ui/privacy/where-pub-type-impls-priv-trait.rs23
-rw-r--r--tests/ui/privacy/where-pub-type-impls-priv-trait.stderr84
32 files changed, 697 insertions, 786 deletions
diff --git a/tests/ui/privacy/associated-item-privacy-inherent.rs b/tests/ui/privacy/associated-item-privacy-inherent.rs
index 7b7c734a9..81703ae10 100644
--- a/tests/ui/privacy/associated-item-privacy-inherent.rs
+++ b/tests/ui/privacy/associated-item-privacy-inherent.rs
@@ -1,5 +1,5 @@
#![feature(decl_macro, associated_type_defaults)]
-#![allow(unused, private_in_public)]
+#![allow(private_interfaces)]
mod priv_nominal {
pub struct Pub;
diff --git a/tests/ui/privacy/associated-item-privacy-trait.rs b/tests/ui/privacy/associated-item-privacy-trait.rs
index c686a2177..db77a6a72 100644
--- a/tests/ui/privacy/associated-item-privacy-trait.rs
+++ b/tests/ui/privacy/associated-item-privacy-trait.rs
@@ -1,5 +1,5 @@
#![feature(decl_macro, associated_type_defaults)]
-#![allow(unused, private_in_public)]
+#![allow(private_interfaces, private_bounds)]
mod priv_trait {
trait PrivTr {
diff --git a/tests/ui/privacy/associated-item-privacy-type-binding.rs b/tests/ui/privacy/associated-item-privacy-type-binding.rs
index 9826b83a3..95a4fbf63 100644
--- a/tests/ui/privacy/associated-item-privacy-type-binding.rs
+++ b/tests/ui/privacy/associated-item-privacy-type-binding.rs
@@ -1,5 +1,5 @@
#![feature(decl_macro, associated_type_defaults)]
-#![allow(unused, private_in_public)]
+#![allow(private_interfaces, private_bounds)]
mod priv_trait {
trait PrivTr {
diff --git a/tests/ui/privacy/effective_visibilities_full_priv.rs b/tests/ui/privacy/effective_visibilities_full_priv.rs
index a26ae3bd1..b96eddcab 100644
--- a/tests/ui/privacy/effective_visibilities_full_priv.rs
+++ b/tests/ui/privacy/effective_visibilities_full_priv.rs
@@ -1,5 +1,5 @@
#![feature(rustc_attrs)]
-#![allow(private_in_public)]
+#![allow(private_interfaces)]
struct SemiPriv;
diff --git a/tests/ui/privacy/issue-30079.rs b/tests/ui/privacy/issue-30079.rs
index a02a932d0..ddba629f5 100644
--- a/tests/ui/privacy/issue-30079.rs
+++ b/tests/ui/privacy/issue-30079.rs
@@ -3,8 +3,7 @@ struct SemiPriv;
mod m1 {
struct Priv;
impl ::SemiPriv {
- pub fn f(_: Priv) {} //~ WARN private type `m1::Priv` in public interface
- //~^ WARNING hard error
+ pub fn f(_: Priv) {} //~ WARN type `m1::Priv` is more private than the item `m1::<impl SemiPriv>::f`
}
impl Priv {
diff --git a/tests/ui/privacy/issue-30079.stderr b/tests/ui/privacy/issue-30079.stderr
index 9179ff339..f1facba7c 100644
--- a/tests/ui/privacy/issue-30079.stderr
+++ b/tests/ui/privacy/issue-30079.stderr
@@ -1,15 +1,18 @@
-warning: private type `m1::Priv` in public interface (error E0446)
+warning: type `m1::Priv` is more private than the item `m1::<impl SemiPriv>::f`
--> $DIR/issue-30079.rs:6:9
|
LL | pub fn f(_: Priv) {}
- | ^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^ associated function `m1::<impl SemiPriv>::f` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
- = note: `#[warn(private_in_public)]` on by default
+note: but type `m1::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/issue-30079.rs:4:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
+ = note: `#[warn(private_interfaces)]` on by default
error[E0446]: private type `m2::Priv` in public interface
- --> $DIR/issue-30079.rs:18:9
+ --> $DIR/issue-30079.rs:17:9
|
LL | struct Priv;
| ----------- `m2::Priv` declared as private
@@ -18,7 +21,7 @@ LL | type Target = Priv;
| ^^^^^^^^^^^ can't leak private type
error[E0446]: private type `m3::Priv` in public interface
- --> $DIR/issue-30079.rs:35:9
+ --> $DIR/issue-30079.rs:34:9
|
LL | struct Priv;
| ----------- `m3::Priv` declared as private
diff --git a/tests/ui/privacy/private-bounds-locally-allowed.rs b/tests/ui/privacy/private-bounds-locally-allowed.rs
new file mode 100644
index 000000000..96a007a64
--- /dev/null
+++ b/tests/ui/privacy/private-bounds-locally-allowed.rs
@@ -0,0 +1,7 @@
+// check-pass
+// compile-flags: --crate-type=lib
+
+#[allow(private_bounds)]
+pub trait Foo: FooImpl {}
+
+trait FooImpl {}
diff --git a/tests/ui/privacy/private-in-public-assoc-ty.rs b/tests/ui/privacy/private-in-public-assoc-ty.rs
index d4d379bdb..5f7c4bcf2 100644
--- a/tests/ui/privacy/private-in-public-assoc-ty.rs
+++ b/tests/ui/privacy/private-in-public-assoc-ty.rs
@@ -22,14 +22,11 @@ mod m {
// applies only to the aliased types, not bounds.
pub trait PubTr {
type Alias1: PrivTr;
- //~^ WARN private trait `PrivTr` in public interface
- //~| WARN this was previously accepted
+ //~^ WARN trait `PrivTr` is more private than the item `PubTr::Alias1`
type Alias2: PubTrAux1<Priv> = u8;
- //~^ WARN private type `Priv` in public interface
- //~| WARN this was previously accepted
+ //~^ WARN type `Priv` is more private than the item `PubTr::Alias2`
type Alias3: PubTrAux2<A = Priv> = u8;
- //~^ WARN private type `Priv` in public interface
- //~| WARN this was previously accepted
+ //~^ WARN type `Priv` is more private than the item `PubTr::Alias3`
type Alias4 = Priv;
//~^ ERROR private type `Priv` in public interface
diff --git a/tests/ui/privacy/private-in-public-assoc-ty.stderr b/tests/ui/privacy/private-in-public-assoc-ty.stderr
index a59027d81..0931e6d99 100644
--- a/tests/ui/privacy/private-in-public-assoc-ty.stderr
+++ b/tests/ui/privacy/private-in-public-assoc-ty.stderr
@@ -7,36 +7,45 @@ LL | struct Priv;
LL | type A = Priv;
| ^^^^^^ can't leak private type
-warning: private trait `PrivTr` in public interface (error E0445)
+warning: trait `PrivTr` is more private than the item `PubTr::Alias1`
--> $DIR/private-in-public-assoc-ty.rs:24:9
|
LL | type Alias1: PrivTr;
- | ^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^ associated type `PubTr::Alias1` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
- = note: `#[warn(private_in_public)]` on by default
+note: but trait `PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-assoc-ty.rs:9:5
+ |
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
+ = note: `#[warn(private_bounds)]` on by default
-warning: private type `Priv` in public interface (error E0446)
- --> $DIR/private-in-public-assoc-ty.rs:27:9
+warning: type `Priv` is more private than the item `PubTr::Alias2`
+ --> $DIR/private-in-public-assoc-ty.rs:26:9
|
LL | type Alias2: PubTrAux1<Priv> = u8;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated type `PubTr::Alias2` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but type `Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-assoc-ty.rs:8:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
-warning: private type `Priv` in public interface (error E0446)
- --> $DIR/private-in-public-assoc-ty.rs:30:9
+warning: type `Priv` is more private than the item `PubTr::Alias3`
+ --> $DIR/private-in-public-assoc-ty.rs:28:9
|
LL | type Alias3: PubTrAux2<A = Priv> = u8;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated type `PubTr::Alias3` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but type `Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-assoc-ty.rs:8:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
error[E0446]: private type `Priv` in public interface
- --> $DIR/private-in-public-assoc-ty.rs:34:9
+ --> $DIR/private-in-public-assoc-ty.rs:31:9
|
LL | struct Priv;
| ----------- `Priv` declared as private
@@ -45,7 +54,7 @@ LL | type Alias4 = Priv;
| ^^^^^^^^^^^ can't leak private type
error[E0446]: private type `Priv` in public interface
- --> $DIR/private-in-public-assoc-ty.rs:41:9
+ --> $DIR/private-in-public-assoc-ty.rs:38:9
|
LL | struct Priv;
| ----------- `Priv` declared as private
@@ -53,8 +62,8 @@ LL | struct Priv;
LL | type Alias1 = Priv;
| ^^^^^^^^^^^ can't leak private type
-error[E0445]: private trait `PrivTr` in public interface
- --> $DIR/private-in-public-assoc-ty.rs:44:9
+error[E0446]: private trait `PrivTr` in public interface
+ --> $DIR/private-in-public-assoc-ty.rs:41:9
|
LL | trait PrivTr {}
| ------------ `PrivTr` declared as private
@@ -64,5 +73,4 @@ LL | type Exist = impl PrivTr;
error: aborting due to 4 previous errors; 3 warnings emitted
-Some errors have detailed explanations: E0445, E0446.
-For more information about an error, try `rustc --explain E0445`.
+For more information about this error, try `rustc --explain E0446`.
diff --git a/tests/ui/privacy/private-in-public-lint.rs b/tests/ui/privacy/private-in-public-lint.rs
deleted file mode 100644
index 8b6e43601..000000000
--- a/tests/ui/privacy/private-in-public-lint.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-mod m1 {
- pub struct Pub;
- struct Priv;
-
- impl Pub {
- pub fn f() -> Priv {Priv} //~ ERROR private type `m1::Priv` in public interface
- }
-}
-
-mod m2 {
- pub struct Pub;
- struct Priv;
-
- impl Pub {
- pub fn f() -> Priv {Priv} //~ ERROR private type `m2::Priv` in public interface
- }
-}
-
-fn main() {}
diff --git a/tests/ui/privacy/private-in-public-lint.stderr b/tests/ui/privacy/private-in-public-lint.stderr
deleted file mode 100644
index 1e98e3bed..000000000
--- a/tests/ui/privacy/private-in-public-lint.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0446]: private type `m1::Priv` in public interface
- --> $DIR/private-in-public-lint.rs:6:9
- |
-LL | struct Priv;
- | ----------- `m1::Priv` declared as private
-...
-LL | pub fn f() -> Priv {Priv}
- | ^^^^^^^^^^^^^^^^^^ can't leak private type
-
-error[E0446]: private type `m2::Priv` in public interface
- --> $DIR/private-in-public-lint.rs:15:9
- |
-LL | struct Priv;
- | ----------- `m2::Priv` declared as private
-...
-LL | pub fn f() -> Priv {Priv}
- | ^^^^^^^^^^^^^^^^^^ can't leak private type
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0446`.
diff --git a/tests/ui/privacy/private-in-public-non-principal-2.rs b/tests/ui/privacy/private-in-public-non-principal-2.rs
index db451d334..d7223c647 100644
--- a/tests/ui/privacy/private-in-public-non-principal-2.rs
+++ b/tests/ui/privacy/private-in-public-non-principal-2.rs
@@ -1,7 +1,7 @@
#![feature(auto_traits)]
#![feature(negative_impls)]
-#[allow(private_in_public)]
+#[allow(private_interfaces)]
mod m {
pub trait PubPrincipal {}
auto trait PrivNonPrincipal {}
diff --git a/tests/ui/privacy/private-in-public-non-principal.rs b/tests/ui/privacy/private-in-public-non-principal.rs
index a2284c930..e348a1816 100644
--- a/tests/ui/privacy/private-in-public-non-principal.rs
+++ b/tests/ui/privacy/private-in-public-non-principal.rs
@@ -1,19 +1,11 @@
#![feature(auto_traits)]
#![feature(negative_impls)]
-#![feature(type_privacy_lints)]
-#![deny(private_interfaces)]
-
-// In this test both old and new private-in-public diagnostic were emitted.
-// Old diagnostic will be deleted soon.
-// See https://rust-lang.github.io/rfcs/2145-type-privacy.html.
pub trait PubPrincipal {}
auto trait PrivNonPrincipal {}
pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loop {} }
-//~^ WARN private trait `PrivNonPrincipal` in public interface
-//~| WARN this was previously accepted
-//~| ERROR trait `PrivNonPrincipal` is more private than the item `leak_dyn_nonprincipal`
+//~^ WARN trait `PrivNonPrincipal` is more private than the item `leak_dyn_nonprincipal`
#[deny(missing_docs)]
fn container() {
diff --git a/tests/ui/privacy/private-in-public-non-principal.stderr b/tests/ui/privacy/private-in-public-non-principal.stderr
index 1387f59cb..63512f462 100644
--- a/tests/ui/privacy/private-in-public-non-principal.stderr
+++ b/tests/ui/privacy/private-in-public-non-principal.stderr
@@ -1,41 +1,27 @@
-warning: private trait `PrivNonPrincipal` in public interface (error E0445)
- --> $DIR/private-in-public-non-principal.rs:13:1
- |
-LL | pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loop {} }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
- = note: `#[warn(private_in_public)]` on by default
-
-error: trait `PrivNonPrincipal` is more private than the item `leak_dyn_nonprincipal`
- --> $DIR/private-in-public-non-principal.rs:13:1
+warning: trait `PrivNonPrincipal` is more private than the item `leak_dyn_nonprincipal`
+ --> $DIR/private-in-public-non-principal.rs:7:1
|
LL | pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loop {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `leak_dyn_nonprincipal` is reachable at visibility `pub`
|
note: but trait `PrivNonPrincipal` is only usable at visibility `pub(crate)`
- --> $DIR/private-in-public-non-principal.rs:11:1
+ --> $DIR/private-in-public-non-principal.rs:5:1
|
LL | auto trait PrivNonPrincipal {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: the lint level is defined here
- --> $DIR/private-in-public-non-principal.rs:4:9
- |
-LL | #![deny(private_interfaces)]
- | ^^^^^^^^^^^^^^^^^^
+ = note: `#[warn(private_interfaces)]` on by default
error: missing documentation for an associated function
- --> $DIR/private-in-public-non-principal.rs:21:9
+ --> $DIR/private-in-public-non-principal.rs:13:9
|
LL | pub fn check_doc_lint() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
- --> $DIR/private-in-public-non-principal.rs:18:8
+ --> $DIR/private-in-public-non-principal.rs:10:8
|
LL | #[deny(missing_docs)]
| ^^^^^^^^^^^^
-error: aborting due to 2 previous errors; 1 warning emitted
+error: aborting due to previous error; 1 warning emitted
diff --git a/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs b/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs
index fe6ed4673..3fb543e96 100644
--- a/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs
+++ b/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs
@@ -1,7 +1,7 @@
// build-pass (FIXME(62277): could be check-pass?)
#![feature(impl_trait_in_assoc_type)]
#![feature(type_alias_impl_trait)]
-#![deny(private_in_public)]
+#![deny(private_interfaces, private_bounds)]
pub type Pub = impl Default;
diff --git a/tests/ui/privacy/private-in-public-warn.rs b/tests/ui/privacy/private-in-public-warn.rs
index 0fa1de975..99d318e36 100644
--- a/tests/ui/privacy/private-in-public-warn.rs
+++ b/tests/ui/privacy/private-in-public-warn.rs
@@ -2,7 +2,7 @@
// This test also ensures that the checks are performed even inside private modules.
#![feature(associated_type_defaults)]
-#![deny(private_in_public)]
+#![deny(private_interfaces, private_bounds)]
#![allow(improper_ctypes)]
mod types {
@@ -12,30 +12,21 @@ mod types {
type Alias;
}
- pub type Alias = Priv; //~ ERROR private type `types::Priv` in public interface
- //~^ WARNING hard error
+ pub type Alias = Priv; //~ ERROR type `types::Priv` is more private than the item `types::Alias`
pub enum E {
- V1(Priv), //~ ERROR private type `types::Priv` in public interface
- //~^ WARNING hard error
- V2 { field: Priv }, //~ ERROR private type `types::Priv` in public interface
- //~^ WARNING hard error
+ V1(Priv), //~ ERROR type `types::Priv` is more private than the item `E::V1::0`
+ V2 { field: Priv }, //~ ERROR type `types::Priv` is more private than the item `E::V2::field`
}
pub trait Tr {
- const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface
- //~^ WARNING hard error
+ const C: Priv = Priv; //~ ERROR type `types::Priv` is more private than the item `Tr::C`
type Alias = Priv; //~ ERROR private type `types::Priv` in public interface
- fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface
- //~^ WARNING hard error
- fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface
- //~^ WARNING hard error
+ fn f1(arg: Priv) {} //~ ERROR type `types::Priv` is more private than the item `Tr::f1`
+ fn f2() -> Priv { panic!() } //~ ERROR type `types::Priv` is more private than the item `Tr::f2`
}
extern "C" {
- pub static ES: Priv; //~ ERROR private type `types::Priv` in public interface
- //~^ WARNING hard error
- pub fn ef1(arg: Priv); //~ ERROR private type `types::Priv` in public interface
- //~^ WARNING hard error
- pub fn ef2() -> Priv; //~ ERROR private type `types::Priv` in public interface
- //~^ WARNING hard error
+ pub static ES: Priv; //~ ERROR type `types::Priv` is more private than the item `types::ES`
+ pub fn ef1(arg: Priv); //~ ERROR type `types::Priv` is more private than the item `types::ef1`
+ pub fn ef2() -> Priv; //~ ERROR type `types::Priv` is more private than the item `types::ef2`
}
impl PubTr for Pub {
type Alias = Priv; //~ ERROR private type `types::Priv` in public interface
@@ -47,22 +38,16 @@ mod traits {
pub struct Pub<T>(T);
pub trait PubTr {}
- pub type Alias<T: PrivTr> = T; //~ ERROR private trait `traits::PrivTr` in public interface
- //~| WARNING hard error
- //~| WARNING bounds on generic parameters are not enforced in type aliases
- pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface
- //~^ WARNING hard error
- pub trait Tr2<T: PrivTr> {} //~ ERROR private trait `traits::PrivTr` in public interface
- //~^ WARNING hard error
+ pub type Alias<T: PrivTr> = T; //~ ERROR trait `traits::PrivTr` is more private than the item `traits::Alias`
+ //~^ WARNING bounds on generic parameters are not enforced in type aliases
+ pub trait Tr1: PrivTr {} //~ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr1`
+ pub trait Tr2<T: PrivTr> {} //~ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr2`
pub trait Tr3 {
type Alias: PrivTr;
- //~^ ERROR private trait `traits::PrivTr` in public interface
- //~| WARNING hard error
- fn f<T: PrivTr>(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface
- //~^ WARNING hard error
+ //~^ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::Alias`
+ fn f<T: PrivTr>(arg: T) {} //~ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::f`
}
- impl<T: PrivTr> Pub<T> {} //~ ERROR private trait `traits::PrivTr` in public interface
- //~^ WARNING hard error
+ 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
}
@@ -72,20 +57,16 @@ mod traits_where {
pub trait PubTr {}
pub type Alias<T> where T: PrivTr = T;
- //~^ ERROR private trait `traits_where::PrivTr` in public interface
- //~| WARNING hard error
+ //~^ ERROR trait `traits_where::PrivTr` is more private than the item `traits_where::Alias`
//~| WARNING where clauses are not enforced in type aliases
pub trait Tr2<T> where T: PrivTr {}
- //~^ ERROR private trait `traits_where::PrivTr` in public interface
- //~| WARNING hard error
+ //~^ ERROR trait `traits_where::PrivTr` is more private than the item `traits_where::Tr2`
pub trait Tr3 {
fn f<T>(arg: T) where T: PrivTr {}
- //~^ ERROR private trait `traits_where::PrivTr` in public interface
- //~| WARNING hard error
+ //~^ ERROR trait `traits_where::PrivTr` is more private than the item `traits_where::Tr3::f`
}
impl<T> Pub<T> where T: PrivTr {}
- //~^ ERROR private trait `traits_where::PrivTr` in public interface
- //~| WARNING hard error
+ //~^ ERROR trait `traits_where::PrivTr` is more private than the item `traits_where::Pub<T>`
impl<T> PubTr for Pub<T> where T: PrivTr {} // OK, trait impl predicates
}
@@ -96,14 +77,10 @@ mod generics {
pub trait PubTr<T> {}
pub trait Tr1: PrivTr<Pub> {}
- //~^ ERROR private trait `generics::PrivTr<generics::Pub>` in public interface
- //~| WARNING hard error
- pub trait Tr2: PubTr<Priv> {} //~ ERROR private type `generics::Priv` in public interface
- //~^ WARNING hard error
- pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR private type `generics::Priv` in public interface
- //~^ WARNING hard error
- pub trait Tr4: PubTr<Pub<Priv>> {} //~ ERROR private type `generics::Priv` in public interface
- //~^ WARNING hard error
+ //~^ ERROR trait `generics::PrivTr<generics::Pub>` is more private than the item `generics::Tr1`
+ pub trait Tr2: PubTr<Priv> {} //~ ERROR type `generics::Priv` is more private than the item `generics::Tr2`
+ pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR type `generics::Priv` is more private than the item `generics::Tr3`
+ pub trait Tr4: PubTr<Pub<Priv>> {} //~ ERROR type `generics::Priv` is more private than the item `Tr4`
}
mod impls {
@@ -200,8 +177,7 @@ mod aliases_pub {
pub trait Tr2: PrivUseAliasTr<PrivAlias> {} // OK
impl PrivAlias {
- pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` in public interface
- //~^ WARNING hard error
+ pub fn f(arg: Priv) {} //~ ERROR type `aliases_pub::Priv` is more private than the item `aliases_pub::<impl Pub2>::f`
}
impl PrivUseAliasTr for PrivUseAlias {
type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in public interface
@@ -244,13 +220,10 @@ mod aliases_priv {
}
pub trait Tr1: PrivUseAliasTr {}
- //~^ ERROR private trait `PrivTr1` in public interface
- //~| WARNING hard error
+ //~^ ERROR trait `PrivTr1` is more private than the item `aliases_priv::Tr1`
pub trait Tr2: PrivUseAliasTr<PrivAlias> {}
- //~^ ERROR private trait `PrivTr1<Priv2>` in public interface
- //~| WARNING hard error
- //~| ERROR private type `Priv2` in public interface
- //~| WARNING hard error
+ //~^ ERROR trait `PrivTr1<Priv2>` is more private than the item `aliases_priv::Tr2`
+ //~| ERROR type `Priv2` is more private than the item `aliases_priv::Tr2`
impl PrivUseAlias {
pub fn f(arg: Priv) {} // OK
diff --git a/tests/ui/privacy/private-in-public-warn.stderr b/tests/ui/privacy/private-in-public-warn.stderr
index 66f91ce6f..6497b7ff5 100644
--- a/tests/ui/privacy/private-in-public-warn.stderr
+++ b/tests/ui/privacy/private-in-public-warn.stderr
@@ -1,46 +1,58 @@
-error: private type `types::Priv` in public interface (error E0446)
+error: type `types::Priv` is more private than the item `types::Alias`
--> $DIR/private-in-public-warn.rs:15:5
|
LL | pub type Alias = Priv;
- | ^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^ type alias `types::Alias` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:9:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
note: the lint level is defined here
--> $DIR/private-in-public-warn.rs:5:9
|
-LL | #![deny(private_in_public)]
- | ^^^^^^^^^^^^^^^^^
+LL | #![deny(private_interfaces, private_bounds)]
+ | ^^^^^^^^^^^^^^^^^^
-error: private type `types::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:18:12
+error: type `types::Priv` is more private than the item `E::V1::0`
+ --> $DIR/private-in-public-warn.rs:17:12
|
LL | V1(Priv),
- | ^^^^
+ | ^^^^ field `E::V1::0` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:9:5
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | struct Priv;
+ | ^^^^^^^^^^^
-error: private type `types::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:20:14
+error: type `types::Priv` is more private than the item `E::V2::field`
+ --> $DIR/private-in-public-warn.rs:18:14
|
LL | V2 { field: Priv },
- | ^^^^^^^^^^^
+ | ^^^^^^^^^^^ field `E::V2::field` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:9:5
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | struct Priv;
+ | ^^^^^^^^^^^
-error: private type `types::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:24:9
+error: type `types::Priv` is more private than the item `Tr::C`
+ --> $DIR/private-in-public-warn.rs:21:9
|
LL | const C: Priv = Priv;
- | ^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^ associated constant `Tr::C` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:9:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
error[E0446]: private type `types::Priv` in public interface
- --> $DIR/private-in-public-warn.rs:26:9
+ --> $DIR/private-in-public-warn.rs:22:9
|
LL | struct Priv;
| ----------- `types::Priv` declared as private
@@ -48,53 +60,68 @@ LL | struct Priv;
LL | type Alias = Priv;
| ^^^^^^^^^^ can't leak private type
-error: private type `types::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:27:9
+error: type `types::Priv` is more private than the item `Tr::f1`
+ --> $DIR/private-in-public-warn.rs:23:9
|
LL | fn f1(arg: Priv) {}
- | ^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^ associated function `Tr::f1` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:9:5
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | struct Priv;
+ | ^^^^^^^^^^^
-error: private type `types::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:29:9
+error: type `types::Priv` is more private than the item `Tr::f2`
+ --> $DIR/private-in-public-warn.rs:24:9
|
LL | fn f2() -> Priv { panic!() }
- | ^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^ associated function `Tr::f2` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:9:5
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | struct Priv;
+ | ^^^^^^^^^^^
-error: private type `types::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:33:9
+error: type `types::Priv` is more private than the item `types::ES`
+ --> $DIR/private-in-public-warn.rs:27:9
|
LL | pub static ES: Priv;
- | ^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^ static `types::ES` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:9:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
-error: private type `types::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:35:9
+error: type `types::Priv` is more private than the item `types::ef1`
+ --> $DIR/private-in-public-warn.rs:28:9
|
LL | pub fn ef1(arg: Priv);
- | ^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^ function `types::ef1` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:9:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
-error: private type `types::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:37:9
+error: type `types::Priv` is more private than the item `types::ef2`
+ --> $DIR/private-in-public-warn.rs:29:9
|
LL | pub fn ef2() -> Priv;
- | ^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^ function `types::ef2` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:9:5
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | struct Priv;
+ | ^^^^^^^^^^^
error[E0446]: private type `types::Priv` in public interface
- --> $DIR/private-in-public-warn.rs:41:9
+ --> $DIR/private-in-public-warn.rs:32:9
|
LL | struct Priv;
| ----------- `types::Priv` declared as private
@@ -102,134 +129,181 @@ LL | struct Priv;
LL | type Alias = Priv;
| ^^^^^^^^^^ can't leak private type
-error: private trait `traits::PrivTr` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:50:5
+error: trait `traits::PrivTr` is more private than the item `traits::Alias`
+ --> $DIR/private-in-public-warn.rs:41:5
|
LL | pub type Alias<T: PrivTr> = T;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ type alias `traits::Alias` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but trait `traits::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:37:5
+ |
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
+note: the lint level is defined here
+ --> $DIR/private-in-public-warn.rs:5:29
+ |
+LL | #![deny(private_interfaces, private_bounds)]
+ | ^^^^^^^^^^^^^^
-error: private trait `traits::PrivTr` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:53:5
+error: trait `traits::PrivTr` is more private than the item `traits::Tr1`
+ --> $DIR/private-in-public-warn.rs:43:5
|
LL | pub trait Tr1: PrivTr {}
- | ^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^ trait `traits::Tr1` 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
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
-error: private trait `traits::PrivTr` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:55:5
+error: trait `traits::PrivTr` is more private than the item `traits::Tr2`
+ --> $DIR/private-in-public-warn.rs:44:5
|
LL | pub trait Tr2<T: PrivTr> {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ trait `traits::Tr2` 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
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
-error: private trait `traits::PrivTr` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:58:9
+error: trait `traits::PrivTr` is more private than the item `traits::Tr3::Alias`
+ --> $DIR/private-in-public-warn.rs:46:9
|
LL | type Alias: PrivTr;
- | ^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^ associated type `traits::Tr3::Alias` 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
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
-error: private trait `traits::PrivTr` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:61:9
+error: trait `traits::PrivTr` is more private than the item `traits::Tr3::f`
+ --> $DIR/private-in-public-warn.rs:48:9
|
LL | fn f<T: PrivTr>(arg: T) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^ associated function `traits::Tr3::f` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but trait `traits::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:37:5
+ |
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
-error: private trait `traits::PrivTr` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:64:5
+error: trait `traits::PrivTr` is more private than the item `traits::Pub<T>`
+ --> $DIR/private-in-public-warn.rs:50:5
|
LL | impl<T: PrivTr> Pub<T> {}
- | ^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^ implementation `traits::Pub<T>` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but trait `traits::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:37:5
+ |
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
-error: private trait `traits_where::PrivTr` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:74:5
+error: trait `traits_where::PrivTr` is more private than the item `traits_where::Alias`
+ --> $DIR/private-in-public-warn.rs:59:5
|
LL | pub type Alias<T> where T: PrivTr = T;
- | ^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^ type alias `traits_where::Alias` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:55:5
+ |
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
-error: private trait `traits_where::PrivTr` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:78:5
+error: trait `traits_where::PrivTr` is more private than the item `traits_where::Tr2`
+ --> $DIR/private-in-public-warn.rs:62: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:55:5
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
-error: private trait `traits_where::PrivTr` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:82:9
+error: trait `traits_where::PrivTr` is more private than the item `traits_where::Tr3::f`
+ --> $DIR/private-in-public-warn.rs:65:9
|
LL | fn f<T>(arg: T) where T: PrivTr {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated function `traits_where::Tr3::f` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:55:5
+ |
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
-error: private trait `traits_where::PrivTr` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:86:5
+error: trait `traits_where::PrivTr` is more private than the item `traits_where::Pub<T>`
+ --> $DIR/private-in-public-warn.rs:68: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:55:5
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
-error: private trait `generics::PrivTr<generics::Pub>` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:98:5
+error: trait `generics::PrivTr<generics::Pub>` is more private than the item `generics::Tr1`
+ --> $DIR/private-in-public-warn.rs:79: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:76:5
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | trait PrivTr<T> {}
+ | ^^^^^^^^^^^^^^^
-error: private type `generics::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:101:5
+error: type `generics::Priv` is more private than the item `generics::Tr2`
+ --> $DIR/private-in-public-warn.rs:81: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:74:5
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | struct Priv<T = u8>(T);
+ | ^^^^^^^^^^^^^^^^^^^
-error: private type `generics::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:103:5
+error: type `generics::Priv` is more private than the item `generics::Tr3`
+ --> $DIR/private-in-public-warn.rs:82:5
|
LL | pub trait Tr3: PubTr<[Priv; 1]> {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `generics::Tr3` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but type `generics::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:74:5
+ |
+LL | struct Priv<T = u8>(T);
+ | ^^^^^^^^^^^^^^^^^^^
-error: private type `generics::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:105:5
+error: type `generics::Priv` is more private than the item `Tr4`
+ --> $DIR/private-in-public-warn.rs:83: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:74:5
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | struct Priv<T = u8>(T);
+ | ^^^^^^^^^^^^^^^^^^^
error[E0446]: private type `impls::Priv` in public interface
- --> $DIR/private-in-public-warn.rs:132:9
+ --> $DIR/private-in-public-warn.rs:109:9
|
LL | struct Priv;
| ----------- `impls::Priv` declared as private
@@ -237,17 +311,20 @@ LL | struct Priv;
LL | type Alias = Priv;
| ^^^^^^^^^^ can't leak private type
-error: private type `aliases_pub::Priv` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:203:9
+error: type `aliases_pub::Priv` is more private than the item `aliases_pub::<impl Pub2>::f`
+ --> $DIR/private-in-public-warn.rs:180:9
|
LL | pub fn f(arg: Priv) {}
- | ^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^ associated function `aliases_pub::<impl Pub2>::f` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but type `aliases_pub::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:153:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
error[E0446]: private type `aliases_pub::Priv` in public interface
- --> $DIR/private-in-public-warn.rs:207:9
+ --> $DIR/private-in-public-warn.rs:183:9
|
LL | struct Priv;
| ----------- `aliases_pub::Priv` declared as private
@@ -256,7 +333,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:210:9
+ --> $DIR/private-in-public-warn.rs:186:9
|
LL | struct Priv;
| ----------- `aliases_pub::Priv` declared as private
@@ -265,7 +342,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:213:9
+ --> $DIR/private-in-public-warn.rs:189:9
|
LL | struct Priv;
| ----------- `aliases_pub::Priv` declared as private
@@ -274,7 +351,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:216:9
+ --> $DIR/private-in-public-warn.rs:192:9
|
LL | struct Priv;
| ----------- `aliases_pub::Priv` declared as private
@@ -282,35 +359,44 @@ LL | struct Priv;
LL | type Check = Priv;
| ^^^^^^^^^^ can't leak private type
-error: private trait `PrivTr1` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:246:5
+error: trait `PrivTr1` is more private than the item `aliases_priv::Tr1`
+ --> $DIR/private-in-public-warn.rs:222:5
|
LL | pub trait Tr1: PrivUseAliasTr {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `aliases_priv::Tr1` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but trait `PrivTr1` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:208:5
+ |
+LL | trait PrivTr1<T = u8> {
+ | ^^^^^^^^^^^^^^^^^^^^^
-error: private trait `PrivTr1<Priv2>` in public interface (error E0445)
- --> $DIR/private-in-public-warn.rs:249:5
+error: trait `PrivTr1<Priv2>` is more private than the item `aliases_priv::Tr2`
+ --> $DIR/private-in-public-warn.rs:224:5
|
LL | pub trait Tr2: PrivUseAliasTr<PrivAlias> {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait `aliases_priv::Tr2` is reachable at visibility `pub(crate)`
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+note: but trait `PrivTr1<Priv2>` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public-warn.rs:208:5
+ |
+LL | trait PrivTr1<T = u8> {
+ | ^^^^^^^^^^^^^^^^^^^^^
-error: private type `Priv2` in public interface (error E0446)
- --> $DIR/private-in-public-warn.rs:249:5
+error: type `Priv2` is more private than the item `aliases_priv::Tr2`
+ --> $DIR/private-in-public-warn.rs:224: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:206:5
|
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+LL | struct Priv2;
+ | ^^^^^^^^^^^^
warning: bounds on generic parameters are not enforced in type aliases
- --> $DIR/private-in-public-warn.rs:50:23
+ --> $DIR/private-in-public-warn.rs:41:23
|
LL | pub type Alias<T: PrivTr> = T;
| ^^^^^^
@@ -323,7 +409,7 @@ LL + pub type Alias<T> = T;
|
warning: where clauses are not enforced in type aliases
- --> $DIR/private-in-public-warn.rs:74:29
+ --> $DIR/private-in-public-warn.rs:59:29
|
LL | pub type Alias<T> where T: PrivTr = T;
| ^^^^^^^^^
diff --git a/tests/ui/privacy/private-in-public.rs b/tests/ui/privacy/private-in-public.rs
index dbd1c483f..f54f9e38f 100644
--- a/tests/ui/privacy/private-in-public.rs
+++ b/tests/ui/privacy/private-in-public.rs
@@ -1,3 +1,5 @@
+// check-pass
+
// Private types and traits are not allowed in public interfaces.
// This test also ensures that the checks are performed even inside private modules.
@@ -10,16 +12,16 @@ mod types {
type Alias;
}
- pub const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface
- pub static S: Priv = Priv; //~ ERROR private type `types::Priv` in public interface
- pub fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface
- pub fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface
- pub struct S1(pub Priv); //~ ERROR private type `types::Priv` in public interface
- pub struct S2 { pub field: Priv } //~ ERROR private type `types::Priv` in public interface
+ pub const C: Priv = Priv; //~ WARNING type `types::Priv` is more private than the item `C`
+ pub static S: Priv = Priv; //~ WARNING type `types::Priv` is more private than the item `S`
+ pub fn f1(arg: Priv) {} //~ WARNING `types::Priv` is more private than the item `types::f1`
+ pub fn f2() -> Priv { panic!() } //~ WARNING type `types::Priv` is more private than the item `types::f2`
+ pub struct S1(pub Priv); //~ WARNING type `types::Priv` is more private than the item `types::S1::0`
+ pub struct S2 { pub field: Priv } //~ WARNING `types::Priv` is more private than the item `S2::field`
impl Pub {
- pub const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface
- pub fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface
- pub fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface
+ pub const C: Priv = Priv; //~ WARNING type `types::Priv` is more private than the item `types::Pub::C`
+ pub fn f1(arg: Priv) {} //~ WARNING type `types::Priv` is more private than the item `types::Pub::f1`
+ pub fn f2() -> Priv { panic!() } //~ WARNING type `types::Priv` is more private than the item `types::Pub::f2`
}
}
@@ -28,11 +30,11 @@ mod traits {
pub struct Pub<T>(T);
pub trait PubTr {}
- pub enum E<T: PrivTr> { V(T) } //~ ERROR private trait `traits::PrivTr` in public interface
- pub fn f<T: PrivTr>(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface
- pub struct S1<T: PrivTr>(T); //~ ERROR private trait `traits::PrivTr` in public interface
- impl<T: PrivTr> Pub<T> { //~ ERROR private trait `traits::PrivTr` in public interface
- pub fn f<U: PrivTr>(arg: U) {} //~ ERROR private trait `traits::PrivTr` in public interface
+ pub enum E<T: PrivTr> { V(T) } //~ WARNING trait `traits::PrivTr` is more private than the item `traits::E`
+ pub fn f<T: PrivTr>(arg: T) {} //~ WARNING trait `traits::PrivTr` is more private than the item `traits::f`
+ pub struct S1<T: PrivTr>(T); //~ WARNING trait `traits::PrivTr` is more private than the item `traits::S1`
+ impl<T: PrivTr> Pub<T> { //~ WARNING trait `traits::PrivTr` is more private than the item `traits::Pub<T>`
+ pub fn f<U: PrivTr>(arg: U) {} //~ WARNING trait `traits::PrivTr` is more private than the item `traits::Pub::<T>::f`
}
}
@@ -42,15 +44,15 @@ mod traits_where {
pub trait PubTr {}
pub enum E<T> where T: PrivTr { V(T) }
- //~^ ERROR private trait `traits_where::PrivTr` in public interface
+ //~^ WARNING trait `traits_where::PrivTr` is more private than the item `traits_where::E`
pub fn f<T>(arg: T) where T: PrivTr {}
- //~^ ERROR private trait `traits_where::PrivTr` in public interface
+ //~^ WARNING trait `traits_where::PrivTr` is more private than the item `traits_where::f`
pub struct S1<T>(T) where T: PrivTr;
- //~^ ERROR private trait `traits_where::PrivTr` in public interface
+ //~^ WARNING trait `traits_where::PrivTr` is more private than the item `traits_where::S1`
impl<T> Pub<T> where T: PrivTr {
- //~^ ERROR private trait `traits_where::PrivTr` in public interface
+ //~^ WARNING trait `traits_where::PrivTr` is more private than the item `traits_where::Pub<T>`
pub fn f<U>(arg: U) where U: PrivTr {}
- //~^ ERROR private trait `traits_where::PrivTr` in public interface
+ //~^ WARNING trait `traits_where::PrivTr` is more private than the item `traits_where::Pub::<T>::f`
}
}
@@ -60,10 +62,10 @@ mod generics {
trait PrivTr<T> {}
pub trait PubTr<T> {}
- pub fn f1(arg: [Priv; 1]) {} //~ ERROR private type `generics::Priv` in public interface
- pub fn f2(arg: Pub<Priv>) {} //~ ERROR private type `generics::Priv` in public interface
+ pub fn f1(arg: [Priv; 1]) {} //~ WARNING type `generics::Priv` is more private than the item `generics::f1`
+ pub fn f2(arg: Pub<Priv>) {} //~ WARNING type `generics::Priv` is more private than the item `generics::f2`
pub fn f3(arg: Priv<Pub>) {}
- //~^ ERROR private type `generics::Priv<generics::Pub>` in public interface
+ //~^ WARNING type `generics::Priv<generics::Pub>` is more private than the item `generics::f3`
}
mod impls {
@@ -77,7 +79,7 @@ mod impls {
}
impl Pub {
- pub fn f(arg: Priv) {} //~ ERROR private type `impls::Priv` in public interface
+ pub fn f(arg: Priv) {} //~ WARNING type `impls::Priv` is more private than the item `impls::Pub::f`
}
}
@@ -102,11 +104,11 @@ mod aliases_pub {
// This should be OK, but associated type aliases are not substituted yet
pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
- //~^ ERROR private trait `aliases_pub::PrivTr` in public interface
- //~| ERROR private type `aliases_pub::Priv` in public interface
+ //~^ WARNING trait `aliases_pub::PrivTr` is more private than the item `aliases_pub::f3`
+ //~| WARNING type `aliases_pub::Priv` is more private than the item `aliases_pub::f3`
impl PrivUseAlias {
- pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` in public interface
+ pub fn f(arg: Priv) {}
}
}
@@ -128,11 +130,11 @@ mod aliases_priv {
}
impl PrivTr for Priv {}
- pub fn f1(arg: PrivUseAlias) {} //~ ERROR private type `Priv1` in public interface
- pub fn f2(arg: PrivAlias) {} //~ ERROR private type `Priv2` in public interface
+ pub fn f1(arg: PrivUseAlias) {} //~ WARNING type `Priv1` is more private than the item `aliases_priv::f1`
+ pub fn f2(arg: PrivAlias) {} //~ WARNING type `Priv2` is more private than the item `aliases_priv::f2`
pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
- //~^ ERROR private trait `aliases_priv::PrivTr` in public interface
- //~| ERROR private type `aliases_priv::Priv` in public interface
+ //~^ WARNING trait `aliases_priv::PrivTr` is more private than the item `aliases_priv::f3`
+ //~| WARNING type `aliases_priv::Priv` is more private than the item `aliases_priv::f3`
}
mod aliases_params {
@@ -141,8 +143,8 @@ mod aliases_params {
type Result<T> = ::std::result::Result<T, Priv>;
pub fn f2(arg: PrivAliasGeneric) {}
- //~^ ERROR private type `aliases_params::Priv` in public interface
- pub fn f3(arg: Result<u8>) {} //~ ERROR private type `aliases_params::Priv` in public interface
+ //~^ WARNING type `aliases_params::Priv` is more private than the item `aliases_params::f2`
+ pub fn f3(arg: Result<u8>) {} //~ WARNING type `aliases_params::Priv` is more private than the item `aliases_params::f3`
}
fn main() {}
diff --git a/tests/ui/privacy/private-in-public.stderr b/tests/ui/privacy/private-in-public.stderr
index 887eebf53..d8f9fd007 100644
--- a/tests/ui/privacy/private-in-public.stderr
+++ b/tests/ui/privacy/private-in-public.stderr
@@ -1,292 +1,376 @@
-error[E0446]: private type `types::Priv` in public interface
- --> $DIR/private-in-public.rs:13:5
+warning: type `types::Priv` is more private than the item `C`
+ --> $DIR/private-in-public.rs:15:5
|
-LL | struct Priv;
- | ----------- `types::Priv` declared as private
-...
LL | pub const C: Priv = Priv;
- | ^^^^^^^^^^^^^^^^^ can't leak private type
-
-error[E0446]: private type `types::Priv` in public interface
- --> $DIR/private-in-public.rs:14:5
+ | ^^^^^^^^^^^^^^^^^ constant `C` is reachable at visibility `pub(crate)`
|
-LL | struct Priv;
- | ----------- `types::Priv` declared as private
-...
-LL | pub static S: Priv = Priv;
- | ^^^^^^^^^^^^^^^^^^ can't leak private type
-
-error[E0446]: private type `types::Priv` in public interface
- --> $DIR/private-in-public.rs:15:5
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:9:5
|
LL | struct Priv;
- | ----------- `types::Priv` declared as private
-...
-LL | pub fn f1(arg: Priv) {}
- | ^^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^
+ = note: `#[warn(private_interfaces)]` on by default
-error[E0446]: private type `types::Priv` in public interface
+warning: type `types::Priv` is more private than the item `S`
--> $DIR/private-in-public.rs:16:5
|
+LL | pub static S: Priv = Priv;
+ | ^^^^^^^^^^^^^^^^^^ static `S` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:9:5
+ |
LL | struct Priv;
- | ----------- `types::Priv` declared as private
-...
-LL | pub fn f2() -> Priv { panic!() }
- | ^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^
-error[E0446]: private type `types::Priv` in public interface
- --> $DIR/private-in-public.rs:17:19
+warning: type `types::Priv` is more private than the item `types::f1`
+ --> $DIR/private-in-public.rs:17:5
+ |
+LL | pub fn f1(arg: Priv) {}
+ | ^^^^^^^^^^^^^^^^^^^^ function `types::f1` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:9:5
|
LL | struct Priv;
- | ----------- `types::Priv` declared as private
-...
-LL | pub struct S1(pub Priv);
- | ^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^
-error[E0446]: private type `types::Priv` in public interface
- --> $DIR/private-in-public.rs:18:21
+warning: type `types::Priv` is more private than the item `types::f2`
+ --> $DIR/private-in-public.rs:18:5
+ |
+LL | pub fn f2() -> Priv { panic!() }
+ | ^^^^^^^^^^^^^^^^^^^ function `types::f2` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:9:5
|
LL | struct Priv;
- | ----------- `types::Priv` declared as private
-...
-LL | pub struct S2 { pub field: Priv }
- | ^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^
-error[E0446]: private type `types::Priv` in public interface
- --> $DIR/private-in-public.rs:20:9
+warning: type `types::Priv` is more private than the item `types::S1::0`
+ --> $DIR/private-in-public.rs:19:19
+ |
+LL | pub struct S1(pub Priv);
+ | ^^^^^^^^ field `types::S1::0` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:9:5
|
LL | struct Priv;
- | ----------- `types::Priv` declared as private
-...
-LL | pub const C: Priv = Priv;
- | ^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^
-error[E0446]: private type `types::Priv` in public interface
- --> $DIR/private-in-public.rs:21:9
+warning: type `types::Priv` is more private than the item `S2::field`
+ --> $DIR/private-in-public.rs:20:21
+ |
+LL | pub struct S2 { pub field: Priv }
+ | ^^^^^^^^^^^^^^^ field `S2::field` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:9:5
|
LL | struct Priv;
- | ----------- `types::Priv` declared as private
-...
-LL | pub fn f1(arg: Priv) {}
- | ^^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^
-error[E0446]: private type `types::Priv` in public interface
+warning: type `types::Priv` is more private than the item `types::Pub::C`
--> $DIR/private-in-public.rs:22:9
|
+LL | pub const C: Priv = Priv;
+ | ^^^^^^^^^^^^^^^^^ associated constant `types::Pub::C` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:9:5
+ |
LL | struct Priv;
- | ----------- `types::Priv` declared as private
-...
-LL | pub fn f2() -> Priv { panic!() }
- | ^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^
-error[E0445]: private trait `traits::PrivTr` in public interface
- --> $DIR/private-in-public.rs:31:5
+warning: type `types::Priv` is more private than the item `types::Pub::f1`
+ --> $DIR/private-in-public.rs:23:9
|
-LL | trait PrivTr {}
- | ------------ `traits::PrivTr` declared as private
-...
-LL | pub enum E<T: PrivTr> { V(T) }
- | ^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+LL | pub fn f1(arg: Priv) {}
+ | ^^^^^^^^^^^^^^^^^^^^ associated function `types::Pub::f1` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:9:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
-error[E0445]: private trait `traits::PrivTr` in public interface
- --> $DIR/private-in-public.rs:32:5
+warning: type `types::Priv` is more private than the item `types::Pub::f2`
+ --> $DIR/private-in-public.rs:24:9
|
-LL | trait PrivTr {}
- | ------------ `traits::PrivTr` declared as private
-...
-LL | pub fn f<T: PrivTr>(arg: T) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+LL | pub fn f2() -> Priv { panic!() }
+ | ^^^^^^^^^^^^^^^^^^^ associated function `types::Pub::f2` is reachable at visibility `pub(crate)`
+ |
+note: but type `types::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:9:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
-error[E0445]: private trait `traits::PrivTr` in public interface
+warning: trait `traits::PrivTr` is more private than the item `traits::E`
--> $DIR/private-in-public.rs:33:5
|
+LL | pub enum E<T: PrivTr> { V(T) }
+ | ^^^^^^^^^^^^^^^^^^^^^ enum `traits::E` is reachable at visibility `pub(crate)`
+ |
+note: but trait `traits::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:29:5
+ |
LL | trait PrivTr {}
- | ------------ `traits::PrivTr` declared as private
-...
-LL | pub struct S1<T: PrivTr>(T);
- | ^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+ | ^^^^^^^^^^^^
+ = note: `#[warn(private_bounds)]` on by default
-error[E0445]: private trait `traits::PrivTr` in public interface
+warning: trait `traits::PrivTr` is more private than the item `traits::f`
--> $DIR/private-in-public.rs:34:5
|
+LL | pub fn f<T: PrivTr>(arg: T) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `traits::f` is reachable at visibility `pub(crate)`
+ |
+note: but trait `traits::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:29:5
+ |
LL | trait PrivTr {}
- | ------------ `traits::PrivTr` declared as private
-...
-LL | impl<T: PrivTr> Pub<T> {
- | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+ | ^^^^^^^^^^^^
-error[E0445]: private trait `traits::PrivTr` in public interface
- --> $DIR/private-in-public.rs:35:9
+warning: trait `traits::PrivTr` is more private than the item `traits::S1`
+ --> $DIR/private-in-public.rs:35:5
+ |
+LL | pub struct S1<T: PrivTr>(T);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ struct `traits::S1` is reachable at visibility `pub(crate)`
+ |
+note: but trait `traits::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:29:5
|
LL | trait PrivTr {}
- | ------------ `traits::PrivTr` declared as private
-...
-LL | pub fn f<U: PrivTr>(arg: U) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+ | ^^^^^^^^^^^^
-error[E0445]: private trait `traits_where::PrivTr` in public interface
- --> $DIR/private-in-public.rs:44:5
+warning: trait `traits::PrivTr` is more private than the item `traits::Pub<T>`
+ --> $DIR/private-in-public.rs:36:5
+ |
+LL | impl<T: PrivTr> Pub<T> {
+ | ^^^^^^^^^^^^^^^^^^^^^^ implementation `traits::Pub<T>` is reachable at visibility `pub(crate)`
+ |
+note: but trait `traits::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:29:5
|
LL | trait PrivTr {}
- | ------------ `traits_where::PrivTr` declared as private
-...
-LL | pub enum E<T> where T: PrivTr { V(T) }
- | ^^^^^^^^^^^^^ can't leak private trait
+ | ^^^^^^^^^^^^
-error[E0445]: private trait `traits_where::PrivTr` in public interface
+warning: trait `traits::PrivTr` is more private than the item `traits::Pub::<T>::f`
+ --> $DIR/private-in-public.rs:37:9
+ |
+LL | pub fn f<U: PrivTr>(arg: U) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated function `traits::Pub::<T>::f` is reachable at visibility `pub(crate)`
+ |
+note: but trait `traits::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:29:5
+ |
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
+
+warning: trait `traits_where::PrivTr` is more private than the item `traits_where::E`
--> $DIR/private-in-public.rs:46:5
|
+LL | pub enum E<T> where T: PrivTr { V(T) }
+ | ^^^^^^^^^^^^^ enum `traits_where::E` is reachable at visibility `pub(crate)`
+ |
+note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:42:5
+ |
LL | trait PrivTr {}
- | ------------ `traits_where::PrivTr` declared as private
-...
-LL | pub fn f<T>(arg: T) where T: PrivTr {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+ | ^^^^^^^^^^^^
-error[E0445]: private trait `traits_where::PrivTr` in public interface
+warning: trait `traits_where::PrivTr` is more private than the item `traits_where::f`
--> $DIR/private-in-public.rs:48:5
|
+LL | pub fn f<T>(arg: T) where T: PrivTr {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `traits_where::f` is reachable at visibility `pub(crate)`
+ |
+note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:42:5
+ |
LL | trait PrivTr {}
- | ------------ `traits_where::PrivTr` declared as private
-...
-LL | pub struct S1<T>(T) where T: PrivTr;
- | ^^^^^^^^^^^^^^^^ can't leak private trait
+ | ^^^^^^^^^^^^
-error[E0445]: private trait `traits_where::PrivTr` in public interface
+warning: trait `traits_where::PrivTr` is more private than the item `traits_where::S1`
--> $DIR/private-in-public.rs:50:5
|
+LL | pub struct S1<T>(T) where T: PrivTr;
+ | ^^^^^^^^^^^^^^^^ struct `traits_where::S1` is reachable at visibility `pub(crate)`
+ |
+note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:42:5
+ |
LL | trait PrivTr {}
- | ------------ `traits_where::PrivTr` declared as private
-...
-LL | impl<T> Pub<T> where T: PrivTr {
- | ^^^^^^^^^^^^^^ can't leak private trait
+ | ^^^^^^^^^^^^
-error[E0445]: private trait `traits_where::PrivTr` in public interface
- --> $DIR/private-in-public.rs:52:9
+warning: trait `traits_where::PrivTr` is more private than the item `traits_where::Pub<T>`
+ --> $DIR/private-in-public.rs:52: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.rs:42:5
|
LL | trait PrivTr {}
- | ------------ `traits_where::PrivTr` declared as private
-...
+ | ^^^^^^^^^^^^
+
+warning: trait `traits_where::PrivTr` is more private than the item `traits_where::Pub::<T>::f`
+ --> $DIR/private-in-public.rs:54:9
+ |
LL | pub fn f<U>(arg: U) where U: PrivTr {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated function `traits_where::Pub::<T>::f` is reachable at visibility `pub(crate)`
+ |
+note: but trait `traits_where::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:42:5
+ |
+LL | trait PrivTr {}
+ | ^^^^^^^^^^^^
-error[E0446]: private type `generics::Priv` in public interface
- --> $DIR/private-in-public.rs:63:5
+warning: type `generics::Priv` is more private than the item `generics::f1`
+ --> $DIR/private-in-public.rs:65:5
|
-LL | struct Priv<T = u8>(T);
- | ------------------- `generics::Priv` declared as private
-...
LL | pub fn f1(arg: [Priv; 1]) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
-
-error[E0446]: private type `generics::Priv` in public interface
- --> $DIR/private-in-public.rs:64:5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ function `generics::f1` is reachable at visibility `pub(crate)`
+ |
+note: but type `generics::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:60:5
|
LL | struct Priv<T = u8>(T);
- | ------------------- `generics::Priv` declared as private
-...
-LL | pub fn f2(arg: Pub<Priv>) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^^^^^^^^^
-error[E0446]: private type `generics::Priv<generics::Pub>` in public interface
- --> $DIR/private-in-public.rs:65:5
+warning: type `generics::Priv` is more private than the item `generics::f2`
+ --> $DIR/private-in-public.rs:66:5
+ |
+LL | pub fn f2(arg: Pub<Priv>) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ function `generics::f2` is reachable at visibility `pub(crate)`
+ |
+note: but type `generics::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:60:5
|
LL | struct Priv<T = u8>(T);
- | ------------------- `generics::Priv<generics::Pub>` declared as private
-...
+ | ^^^^^^^^^^^^^^^^^^^
+
+warning: type `generics::Priv<generics::Pub>` is more private than the item `generics::f3`
+ --> $DIR/private-in-public.rs:67:5
+ |
LL | pub fn f3(arg: Priv<Pub>) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ function `generics::f3` is reachable at visibility `pub(crate)`
+ |
+note: but type `generics::Priv<generics::Pub>` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:60:5
+ |
+LL | struct Priv<T = u8>(T);
+ | ^^^^^^^^^^^^^^^^^^^
-error[E0446]: private type `impls::Priv` in public interface
- --> $DIR/private-in-public.rs:80:9
+warning: type `impls::Priv` is more private than the item `impls::Pub::f`
+ --> $DIR/private-in-public.rs:82:9
|
-LL | struct Priv;
- | ----------- `impls::Priv` declared as private
-...
LL | pub fn f(arg: Priv) {}
- | ^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^^^^^^^^^ associated function `impls::Pub::f` is reachable at visibility `pub(crate)`
+ |
+note: but type `impls::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:72:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
-error[E0445]: private trait `aliases_pub::PrivTr` in public interface
- --> $DIR/private-in-public.rs:104:5
+warning: trait `aliases_pub::PrivTr` is more private than the item `aliases_pub::f3`
+ --> $DIR/private-in-public.rs:106:5
|
-LL | trait PrivTr {
- | ------------ `aliases_pub::PrivTr` declared as private
-...
LL | pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_pub::f3` is reachable at visibility `pub(crate)`
+ |
+note: but trait `aliases_pub::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:100:5
+ |
+LL | trait PrivTr {
+ | ^^^^^^^^^^^^
-error[E0446]: private type `aliases_pub::Priv` in public interface
- --> $DIR/private-in-public.rs:104:5
+warning: type `aliases_pub::Priv` is more private than the item `aliases_pub::f3`
+ --> $DIR/private-in-public.rs:106:5
|
-LL | struct Priv;
- | ----------- `aliases_pub::Priv` declared as private
-...
LL | pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
-
-error[E0446]: private type `aliases_pub::Priv` in public interface
- --> $DIR/private-in-public.rs:109:9
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_pub::f3` is reachable at visibility `pub(crate)`
+ |
+note: but type `aliases_pub::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:87:5
|
LL | struct Priv;
- | ----------- `aliases_pub::Priv` declared as private
-...
-LL | pub fn f(arg: Priv) {}
- | ^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^
-error[E0446]: private type `Priv1` in public interface
- --> $DIR/private-in-public.rs:131:5
+warning: type `Priv1` is more private than the item `aliases_priv::f1`
+ --> $DIR/private-in-public.rs:133:5
|
-LL | struct Priv1;
- | ------------ `Priv1` declared as private
-...
LL | pub fn f1(arg: PrivUseAlias) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_priv::f1` is reachable at visibility `pub(crate)`
+ |
+note: but type `Priv1` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:118:5
+ |
+LL | struct Priv1;
+ | ^^^^^^^^^^^^
-error[E0446]: private type `Priv2` in public interface
- --> $DIR/private-in-public.rs:132:5
+warning: type `Priv2` is more private than the item `aliases_priv::f2`
+ --> $DIR/private-in-public.rs:134:5
|
-LL | struct Priv2;
- | ------------ `Priv2` declared as private
-...
LL | pub fn f2(arg: PrivAlias) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_priv::f2` is reachable at visibility `pub(crate)`
+ |
+note: but type `Priv2` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:119:5
+ |
+LL | struct Priv2;
+ | ^^^^^^^^^^^^
-error[E0445]: private trait `aliases_priv::PrivTr` in public interface
- --> $DIR/private-in-public.rs:133:5
+warning: trait `aliases_priv::PrivTr` is more private than the item `aliases_priv::f3`
+ --> $DIR/private-in-public.rs:135:5
|
-LL | trait PrivTr {
- | ------------ `aliases_priv::PrivTr` declared as private
-...
LL | pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_priv::f3` is reachable at visibility `pub(crate)`
+ |
+note: but trait `aliases_priv::PrivTr` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:128:5
+ |
+LL | trait PrivTr {
+ | ^^^^^^^^^^^^
-error[E0446]: private type `aliases_priv::Priv` in public interface
- --> $DIR/private-in-public.rs:133:5
+warning: type `aliases_priv::Priv` is more private than the item `aliases_priv::f3`
+ --> $DIR/private-in-public.rs:135:5
|
-LL | struct Priv;
- | ----------- `aliases_priv::Priv` declared as private
-...
LL | pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
-
-error[E0446]: private type `aliases_params::Priv` in public interface
- --> $DIR/private-in-public.rs:143:5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_priv::f3` is reachable at visibility `pub(crate)`
+ |
+note: but type `aliases_priv::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:116:5
|
LL | struct Priv;
- | ----------- `aliases_params::Priv` declared as private
-...
-LL | pub fn f2(arg: PrivAliasGeneric) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^
-error[E0446]: private type `aliases_params::Priv` in public interface
+warning: type `aliases_params::Priv` is more private than the item `aliases_params::f2`
--> $DIR/private-in-public.rs:145:5
|
+LL | pub fn f2(arg: PrivAliasGeneric) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_params::f2` is reachable at visibility `pub(crate)`
+ |
+note: but type `aliases_params::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:141:5
+ |
LL | struct Priv;
- | ----------- `aliases_params::Priv` declared as private
-...
+ | ^^^^^^^^^^^
+
+warning: type `aliases_params::Priv` is more private than the item `aliases_params::f3`
+ --> $DIR/private-in-public.rs:147:5
+ |
LL | pub fn f3(arg: Result<u8>) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ function `aliases_params::f3` is reachable at visibility `pub(crate)`
+ |
+note: but type `aliases_params::Priv` is only usable at visibility `pub(self)`
+ --> $DIR/private-in-public.rs:141:5
+ |
+LL | struct Priv;
+ | ^^^^^^^^^^^
-error: aborting due to 32 previous errors
+warning: 31 warnings emitted
-Some errors have detailed explanations: E0445, E0446.
-For more information about an error, try `rustc --explain E0445`.
diff --git a/tests/ui/privacy/private-inferred-type-2.rs b/tests/ui/privacy/private-inferred-type-2.rs
index 15b263b38..1c4c52bea 100644
--- a/tests/ui/privacy/private-inferred-type-2.rs
+++ b/tests/ui/privacy/private-inferred-type-2.rs
@@ -1,4 +1,5 @@
// aux-build:private-inferred-type.rs
+#![allow(private_interfaces)]
extern crate private_inferred_type as ext;
diff --git a/tests/ui/privacy/private-inferred-type-2.stderr b/tests/ui/privacy/private-inferred-type-2.stderr
index 3a0fc03b4..8a905f5d8 100644
--- a/tests/ui/privacy/private-inferred-type-2.stderr
+++ b/tests/ui/privacy/private-inferred-type-2.stderr
@@ -1,17 +1,17 @@
error: type `Priv` is private
- --> $DIR/private-inferred-type-2.rs:16:5
+ --> $DIR/private-inferred-type-2.rs:17:5
|
LL | m::Pub::get_priv;
| ^^^^^^^^^^^^^^^^ private type
error: type `Priv` is private
- --> $DIR/private-inferred-type-2.rs:17:5
+ --> $DIR/private-inferred-type-2.rs:18:5
|
LL | m::Pub::static_method;
| ^^^^^^^^^^^^^^^^^^^^^ private type
error: type `ext::Priv` is private
- --> $DIR/private-inferred-type-2.rs:18:5
+ --> $DIR/private-inferred-type-2.rs:19:5
|
LL | ext::Pub::static_method;
| ^^^^^^^^^^^^^^^^^^^^^^^ private type
diff --git a/tests/ui/privacy/private-inferred-type.rs b/tests/ui/privacy/private-inferred-type.rs
index e8743dd96..8c07226fe 100644
--- a/tests/ui/privacy/private-inferred-type.rs
+++ b/tests/ui/privacy/private-inferred-type.rs
@@ -1,5 +1,5 @@
#![feature(decl_macro)]
-#![allow(private_in_public)]
+#![allow(private_interfaces)]
mod m {
fn priv_fn() {}
diff --git a/tests/ui/privacy/private-type-in-interface.rs b/tests/ui/privacy/private-type-in-interface.rs
index 7fbdbaf5f..39e0bf23c 100644
--- a/tests/ui/privacy/private-type-in-interface.rs
+++ b/tests/ui/privacy/private-type-in-interface.rs
@@ -1,6 +1,7 @@
// aux-build:private-inferred-type.rs
#![allow(warnings)]
+#![allow(private_interfaces)]
extern crate private_inferred_type as ext;
diff --git a/tests/ui/privacy/private-type-in-interface.stderr b/tests/ui/privacy/private-type-in-interface.stderr
index 4e87caa34..03225d84f 100644
--- a/tests/ui/privacy/private-type-in-interface.stderr
+++ b/tests/ui/privacy/private-type-in-interface.stderr
@@ -1,53 +1,53 @@
error: type `Priv` is private
- --> $DIR/private-type-in-interface.rs:15:9
+ --> $DIR/private-type-in-interface.rs:16:9
|
LL | fn f(_: m::Alias) {}
| ^^^^^^^^ private type
error: type `Priv` is private
- --> $DIR/private-type-in-interface.rs:15:6
+ --> $DIR/private-type-in-interface.rs:16:6
|
LL | fn f(_: m::Alias) {}
| ^ private type
error: type `ext::Priv` is private
- --> $DIR/private-type-in-interface.rs:17:13
+ --> $DIR/private-type-in-interface.rs:18:13
|
LL | fn f_ext(_: ext::Alias) {}
| ^^^^^^^^^^ private type
error: type `ext::Priv` is private
- --> $DIR/private-type-in-interface.rs:17:10
+ --> $DIR/private-type-in-interface.rs:18:10
|
LL | fn f_ext(_: ext::Alias) {}
| ^ private type
error: type `Priv` is private
- --> $DIR/private-type-in-interface.rs:21:6
+ --> $DIR/private-type-in-interface.rs:22:6
|
LL | impl m::Alias {}
| ^^^^^^^^ private type
error: type `ext::Priv` is private
- --> $DIR/private-type-in-interface.rs:22:14
+ --> $DIR/private-type-in-interface.rs:23:14
|
LL | impl Tr1 for ext::Alias {}
| ^^^^^^^^^^ private type
error: type `Priv` is private
- --> $DIR/private-type-in-interface.rs:23:10
+ --> $DIR/private-type-in-interface.rs:24:10
|
LL | type A = <m::Alias as m::Trait>::X;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ private type
error: type `Priv` is private
- --> $DIR/private-type-in-interface.rs:27:11
+ --> $DIR/private-type-in-interface.rs:28:11
|
LL | fn g() -> impl Tr2<m::Alias> { 0 }
| ^^^^^^^^^^^^^^^^^^ private type
error: type `ext::Priv` is private
- --> $DIR/private-type-in-interface.rs:28:15
+ --> $DIR/private-type-in-interface.rs:29:15
|
LL | fn g_ext() -> impl Tr2<ext::Alias> { 0 }
| ^^^^^^^^^^^^^^^^^^^^ private type
diff --git a/tests/ui/privacy/restricted/private-in-public.rs b/tests/ui/privacy/restricted/private-in-public.rs
index 1e3dbdf73..80a7e6ad0 100644
--- a/tests/ui/privacy/restricted/private-in-public.rs
+++ b/tests/ui/privacy/restricted/private-in-public.rs
@@ -1,10 +1,11 @@
+// check-pass
mod foo {
struct Priv;
mod bar {
use foo::Priv;
pub(super) fn f(_: Priv) {}
- pub(crate) fn g(_: Priv) {} //~ ERROR E0446
- pub(crate) fn h(_: Priv) {} //~ ERROR E0446
+ pub(crate) fn g(_: Priv) {}
+ pub(crate) fn h(_: Priv) {}
}
}
diff --git a/tests/ui/privacy/restricted/private-in-public.stderr b/tests/ui/privacy/restricted/private-in-public.stderr
deleted file mode 100644
index 65d996f0f..000000000
--- a/tests/ui/privacy/restricted/private-in-public.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0446]: private type `Priv` in public interface
- --> $DIR/private-in-public.rs:6:9
- |
-LL | struct Priv;
- | ----------- `Priv` declared as private
-...
-LL | pub(crate) fn g(_: Priv) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
-
-error[E0446]: private type `Priv` in public interface
- --> $DIR/private-in-public.rs:7:9
- |
-LL | struct Priv;
- | ----------- `Priv` declared as private
-...
-LL | pub(crate) fn h(_: Priv) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0446`.
diff --git a/tests/ui/privacy/unnameable_types.rs b/tests/ui/privacy/unnameable_types.rs
index 46e249152..c6c5561c3 100644
--- a/tests/ui/privacy/unnameable_types.rs
+++ b/tests/ui/privacy/unnameable_types.rs
@@ -1,5 +1,4 @@
#![feature(type_privacy_lints)]
-#![allow(private_in_public)]
#![deny(unnameable_types)]
mod m {
@@ -21,10 +20,10 @@ mod m {
}
}
-pub trait Voldemort<T> {}
+pub trait Unnameable<T> {}
-impl Voldemort<m::PubStruct> for i32 {}
-impl Voldemort<m::PubE> for i32 {}
-impl<T> Voldemort<T> for u32 where T: m::PubTr {}
+impl Unnameable<m::PubStruct> for i32 {}
+impl Unnameable<m::PubE> for i32 {}
+impl<T> Unnameable<T> for u32 where T: m::PubTr {}
fn main() {}
diff --git a/tests/ui/privacy/unnameable_types.stderr b/tests/ui/privacy/unnameable_types.stderr
index 904127525..d68a11c97 100644
--- a/tests/ui/privacy/unnameable_types.stderr
+++ b/tests/ui/privacy/unnameable_types.stderr
@@ -1,23 +1,23 @@
error: struct `PubStruct` is reachable but cannot be named
- --> $DIR/unnameable_types.rs:6:5
+ --> $DIR/unnameable_types.rs:5:5
|
LL | pub struct PubStruct(pub i32);
| ^^^^^^^^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)`
|
note: the lint level is defined here
- --> $DIR/unnameable_types.rs:3:9
+ --> $DIR/unnameable_types.rs:2:9
|
LL | #![deny(unnameable_types)]
| ^^^^^^^^^^^^^^^^
error: enum `PubE` is reachable but cannot be named
- --> $DIR/unnameable_types.rs:8:5
+ --> $DIR/unnameable_types.rs:7:5
|
LL | pub enum PubE {
| ^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)`
error: trait `PubTr` is reachable but cannot be named
- --> $DIR/unnameable_types.rs:12:5
+ --> $DIR/unnameable_types.rs:11:5
|
LL | pub trait PubTr {
| ^^^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)`
diff --git a/tests/ui/privacy/where-priv-type.rs b/tests/ui/privacy/where-priv-type.rs
index 2e0a6b3e7..cd9cce7ec 100644
--- a/tests/ui/privacy/where-priv-type.rs
+++ b/tests/ui/privacy/where-priv-type.rs
@@ -3,14 +3,7 @@
#![crate_type = "lib"]
#![feature(generic_const_exprs)]
-#![feature(type_privacy_lints)]
#![allow(incomplete_features)]
-#![warn(private_bounds)]
-#![warn(private_interfaces)]
-
-// In this test both old and new private-in-public diagnostic were emitted.
-// Old diagnostic will be deleted soon.
-// See https://rust-lang.github.io/rfcs/2145-type-privacy.html.
struct PrivTy;
trait PrivTr {}
@@ -23,42 +16,33 @@ impl PubTrWithAssocTy for PrivTy { type AssocTy = PrivTy; }
pub struct S
-//~^ WARNING private type `PrivTy` in public interface
-//~| WARNING hard error
-//~| WARNING type `PrivTy` is more private than the item `S`
+//~^ WARNING type `PrivTy` is more private than the item `S`
where
PrivTy:
{}
pub enum E
-//~^ WARNING private type `PrivTy` in public interface
-//~| WARNING hard error
-//~| WARNING type `PrivTy` is more private than the item `E`
+//~^ WARNING type `PrivTy` is more private than the item `E`
where
PrivTy:
{}
pub fn f()
-//~^ WARNING private type `PrivTy` in public interface
-//~| WARNING hard error
-//~| WARNING type `PrivTy` is more private than the item `f`
+//~^ WARNING type `PrivTy` is more private than the item `f`
where
PrivTy:
{}
impl S
-//~^ ERROR private type `PrivTy` in public interface
-//~| WARNING type `PrivTy` is more private than the item `S`
+//~^ WARNING type `PrivTy` is more private than the item `S`
where
PrivTy:
{
pub fn f()
- //~^ WARNING private type `PrivTy` in public interface
- //~| WARNING hard error
- //~| WARNING type `PrivTy` is more private than the item `S::f`
+ //~^ WARNING type `PrivTy` is more private than the item `S::f`
where
PrivTy:
{}
@@ -90,7 +74,6 @@ where
{
type AssocTy = Const<{ my_const_fn(U) }>;
//~^ ERROR private type
- //~| WARNING type `fn(u8) -> u8 {my_const_fn}` is more private than the item `<Const<U> as Trait>::AssocTy`
fn assoc_fn() -> Self::AssocTy {
Const
}
diff --git a/tests/ui/privacy/where-priv-type.stderr b/tests/ui/privacy/where-priv-type.stderr
index d6baf22b3..dcc249c63 100644
--- a/tests/ui/privacy/where-priv-type.stderr
+++ b/tests/ui/privacy/where-priv-type.stderr
@@ -1,136 +1,72 @@
-warning: private type `PrivTy` in public interface (error E0446)
- --> $DIR/where-priv-type.rs:25:1
- |
-LL | pub struct S
- | ^^^^^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
- = note: `#[warn(private_in_public)]` on by default
-
warning: type `PrivTy` is more private than the item `S`
- --> $DIR/where-priv-type.rs:25:1
+ --> $DIR/where-priv-type.rs:18:1
|
LL | pub struct S
| ^^^^^^^^^^^^ struct `S` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)`
- --> $DIR/where-priv-type.rs:15:1
+ --> $DIR/where-priv-type.rs:8:1
|
LL | struct PrivTy;
| ^^^^^^^^^^^^^
-note: the lint level is defined here
- --> $DIR/where-priv-type.rs:8:9
- |
-LL | #![warn(private_bounds)]
- | ^^^^^^^^^^^^^^
-
-warning: private type `PrivTy` in public interface (error E0446)
- --> $DIR/where-priv-type.rs:34:1
- |
-LL | pub enum E
- | ^^^^^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+ = note: `#[warn(private_bounds)]` on by default
warning: type `PrivTy` is more private than the item `E`
- --> $DIR/where-priv-type.rs:34:1
+ --> $DIR/where-priv-type.rs:25:1
|
LL | pub enum E
| ^^^^^^^^^^ enum `E` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)`
- --> $DIR/where-priv-type.rs:15:1
+ --> $DIR/where-priv-type.rs:8:1
|
LL | struct PrivTy;
| ^^^^^^^^^^^^^
-warning: private type `PrivTy` in public interface (error E0446)
- --> $DIR/where-priv-type.rs:43:1
- |
-LL | / pub fn f()
-LL | |
-LL | |
-LL | |
-LL | | where
-LL | | PrivTy:
- | |___________^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
-
warning: type `PrivTy` is more private than the item `f`
- --> $DIR/where-priv-type.rs:43:1
+ --> $DIR/where-priv-type.rs:32:1
|
LL | / pub fn f()
LL | |
-LL | |
-LL | |
LL | | where
LL | | PrivTy:
| |___________^ function `f` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)`
- --> $DIR/where-priv-type.rs:15:1
+ --> $DIR/where-priv-type.rs:8:1
|
LL | struct PrivTy;
| ^^^^^^^^^^^^^
-error[E0446]: private type `PrivTy` in public interface
- --> $DIR/where-priv-type.rs:52:1
- |
-LL | struct PrivTy;
- | ------------- `PrivTy` declared as private
-...
-LL | impl S
- | ^^^^^^ can't leak private type
-
warning: type `PrivTy` is more private than the item `S`
- --> $DIR/where-priv-type.rs:52:1
+ --> $DIR/where-priv-type.rs:39:1
|
LL | impl S
| ^^^^^^ implementation `S` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)`
- --> $DIR/where-priv-type.rs:15:1
+ --> $DIR/where-priv-type.rs:8:1
|
LL | struct PrivTy;
| ^^^^^^^^^^^^^
-warning: private type `PrivTy` in public interface (error E0446)
- --> $DIR/where-priv-type.rs:58:5
- |
-LL | / pub fn f()
-LL | |
-LL | |
-LL | |
-LL | | where
-LL | | PrivTy:
- | |_______________^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
-
warning: type `PrivTy` is more private than the item `S::f`
- --> $DIR/where-priv-type.rs:58:5
+ --> $DIR/where-priv-type.rs:44:5
|
LL | / pub fn f()
LL | |
-LL | |
-LL | |
LL | | where
LL | | PrivTy:
| |_______________^ associated function `S::f` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)`
- --> $DIR/where-priv-type.rs:15:1
+ --> $DIR/where-priv-type.rs:8:1
|
LL | struct PrivTy;
| ^^^^^^^^^^^^^
error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface
- --> $DIR/where-priv-type.rs:91:5
+ --> $DIR/where-priv-type.rs:75:5
|
LL | type AssocTy = Const<{ my_const_fn(U) }>;
| ^^^^^^^^^^^^ can't leak private type
@@ -138,23 +74,6 @@ LL | type AssocTy = Const<{ my_const_fn(U) }>;
LL | const fn my_const_fn(val: u8) -> u8 {
| ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private
-warning: type `fn(u8) -> u8 {my_const_fn}` is more private than the item `<Const<U> as Trait>::AssocTy`
- --> $DIR/where-priv-type.rs:91:5
- |
-LL | type AssocTy = Const<{ my_const_fn(U) }>;
- | ^^^^^^^^^^^^ associated type `<Const<U> as Trait>::AssocTy` is reachable at visibility `pub`
- |
-note: but type `fn(u8) -> u8 {my_const_fn}` is only usable at visibility `pub(crate)`
- --> $DIR/where-priv-type.rs:99:1
- |
-LL | const fn my_const_fn(val: u8) -> u8 {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: the lint level is defined here
- --> $DIR/where-priv-type.rs:9:9
- |
-LL | #![warn(private_interfaces)]
- | ^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors; 10 warnings emitted
+error: aborting due to previous error; 5 warnings emitted
For more information about this error, try `rustc --explain E0446`.
diff --git a/tests/ui/privacy/where-pub-type-impls-priv-trait.rs b/tests/ui/privacy/where-pub-type-impls-priv-trait.rs
index c59fdb7c7..d5e797b52 100644
--- a/tests/ui/privacy/where-pub-type-impls-priv-trait.rs
+++ b/tests/ui/privacy/where-pub-type-impls-priv-trait.rs
@@ -1,14 +1,10 @@
+// check-pass
+
// priv-in-pub lint tests where the private trait bounds a public type
#![crate_type = "lib"]
#![feature(generic_const_exprs)]
-#![feature(type_privacy_lints)]
#![allow(incomplete_features)]
-#![warn(private_bounds)]
-
-// In this test both old and new private-in-public diagnostic were emitted.
-// Old diagnostic will be deleted soon.
-// See https://rust-lang.github.io/rfcs/2145-type-privacy.html.
struct PrivTy;
trait PrivTr {}
@@ -22,38 +18,33 @@ impl PubTrWithAssocTy for PrivTy { type AssocTy = PrivTy; }
pub struct S
-//~^ ERROR private trait `PrivTr` in public interface
-//~| WARNING trait `PrivTr` is more private than the item `S`
+//~^ WARNING trait `PrivTr` is more private than the item `S`
where
PubTy: PrivTr
{}
pub enum E
-//~^ ERROR private trait `PrivTr` in public interface
-//~| WARNING trait `PrivTr` is more private than the item `E`
+//~^ WARNING trait `PrivTr` is more private than the item `E`
where
PubTy: PrivTr
{}
pub fn f()
-//~^ ERROR private trait `PrivTr` in public interface
-//~| WARNING trait `PrivTr` is more private than the item `f`
+//~^ WARNING trait `PrivTr` is more private than the item `f`
where
PubTy: PrivTr
{}
impl S
-//~^ ERROR private trait `PrivTr` in public interface
-//~| WARNING trait `PrivTr` is more private than the item `S`
+//~^ WARNING trait `PrivTr` is more private than the item `S`
where
PubTy: PrivTr
{
pub fn f()
- //~^ ERROR private trait `PrivTr` in public interface
- //~| WARNING trait `PrivTr` is more private than the item `S::f`
+ //~^ WARNING trait `PrivTr` is more private than the item `S::f`
where
PubTy: PrivTr
{}
diff --git a/tests/ui/privacy/where-pub-type-impls-priv-trait.stderr b/tests/ui/privacy/where-pub-type-impls-priv-trait.stderr
index e2d7ce446..c47687433 100644
--- a/tests/ui/privacy/where-pub-type-impls-priv-trait.stderr
+++ b/tests/ui/privacy/where-pub-type-impls-priv-trait.stderr
@@ -1,129 +1,69 @@
-error[E0445]: private trait `PrivTr` in public interface
- --> $DIR/where-pub-type-impls-priv-trait.rs:24:1
- |
-LL | trait PrivTr {}
- | ------------ `PrivTr` declared as private
-...
-LL | pub struct S
- | ^^^^^^^^^^^^ can't leak private trait
-
warning: trait `PrivTr` is more private than the item `S`
- --> $DIR/where-pub-type-impls-priv-trait.rs:24:1
+ --> $DIR/where-pub-type-impls-priv-trait.rs:20:1
|
LL | pub struct S
| ^^^^^^^^^^^^ struct `S` is reachable at visibility `pub`
|
note: but trait `PrivTr` is only usable at visibility `pub(crate)`
- --> $DIR/where-pub-type-impls-priv-trait.rs:14:1
+ --> $DIR/where-pub-type-impls-priv-trait.rs:10:1
|
LL | trait PrivTr {}
| ^^^^^^^^^^^^
-note: the lint level is defined here
- --> $DIR/where-pub-type-impls-priv-trait.rs:7:9
- |
-LL | #![warn(private_bounds)]
- | ^^^^^^^^^^^^^^
-
-error[E0445]: private trait `PrivTr` in public interface
- --> $DIR/where-pub-type-impls-priv-trait.rs:32:1
- |
-LL | trait PrivTr {}
- | ------------ `PrivTr` declared as private
-...
-LL | pub enum E
- | ^^^^^^^^^^ can't leak private trait
+ = note: `#[warn(private_bounds)]` on by default
warning: trait `PrivTr` is more private than the item `E`
- --> $DIR/where-pub-type-impls-priv-trait.rs:32:1
+ --> $DIR/where-pub-type-impls-priv-trait.rs:27:1
|
LL | pub enum E
| ^^^^^^^^^^ enum `E` is reachable at visibility `pub`
|
note: but trait `PrivTr` is only usable at visibility `pub(crate)`
- --> $DIR/where-pub-type-impls-priv-trait.rs:14:1
+ --> $DIR/where-pub-type-impls-priv-trait.rs:10:1
|
LL | trait PrivTr {}
| ^^^^^^^^^^^^
-error[E0445]: private trait `PrivTr` in public interface
- --> $DIR/where-pub-type-impls-priv-trait.rs:40:1
- |
-LL | trait PrivTr {}
- | ------------ `PrivTr` declared as private
-...
-LL | / pub fn f()
-LL | |
-LL | |
-LL | | where
-LL | | PubTy: PrivTr
- | |_________________^ can't leak private trait
-
warning: trait `PrivTr` is more private than the item `f`
- --> $DIR/where-pub-type-impls-priv-trait.rs:40:1
+ --> $DIR/where-pub-type-impls-priv-trait.rs:34:1
|
LL | / pub fn f()
LL | |
-LL | |
LL | | where
LL | | PubTy: PrivTr
| |_________________^ function `f` is reachable at visibility `pub`
|
note: but trait `PrivTr` is only usable at visibility `pub(crate)`
- --> $DIR/where-pub-type-impls-priv-trait.rs:14:1
+ --> $DIR/where-pub-type-impls-priv-trait.rs:10:1
|
LL | trait PrivTr {}
| ^^^^^^^^^^^^
-error[E0445]: private trait `PrivTr` in public interface
- --> $DIR/where-pub-type-impls-priv-trait.rs:48:1
- |
-LL | trait PrivTr {}
- | ------------ `PrivTr` declared as private
-...
-LL | impl S
- | ^^^^^^ can't leak private trait
-
warning: trait `PrivTr` is more private than the item `S`
- --> $DIR/where-pub-type-impls-priv-trait.rs:48:1
+ --> $DIR/where-pub-type-impls-priv-trait.rs:41:1
|
LL | impl S
| ^^^^^^ implementation `S` is reachable at visibility `pub`
|
note: but trait `PrivTr` is only usable at visibility `pub(crate)`
- --> $DIR/where-pub-type-impls-priv-trait.rs:14:1
+ --> $DIR/where-pub-type-impls-priv-trait.rs:10:1
|
LL | trait PrivTr {}
| ^^^^^^^^^^^^
-error[E0445]: private trait `PrivTr` in public interface
- --> $DIR/where-pub-type-impls-priv-trait.rs:54:5
- |
-LL | trait PrivTr {}
- | ------------ `PrivTr` declared as private
-...
-LL | / pub fn f()
-LL | |
-LL | |
-LL | | where
-LL | | PubTy: PrivTr
- | |_____________________^ can't leak private trait
-
warning: trait `PrivTr` is more private than the item `S::f`
- --> $DIR/where-pub-type-impls-priv-trait.rs:54:5
+ --> $DIR/where-pub-type-impls-priv-trait.rs:46:5
|
LL | / pub fn f()
LL | |
-LL | |
LL | | where
LL | | PubTy: PrivTr
| |_____________________^ associated function `S::f` is reachable at visibility `pub`
|
note: but trait `PrivTr` is only usable at visibility `pub(crate)`
- --> $DIR/where-pub-type-impls-priv-trait.rs:14:1
+ --> $DIR/where-pub-type-impls-priv-trait.rs:10:1
|
LL | trait PrivTr {}
| ^^^^^^^^^^^^
-error: aborting due to 5 previous errors; 5 warnings emitted
+warning: 5 warnings emitted
-For more information about this error, try `rustc --explain E0445`.