1
Fork 0

Fix type privacy lints error message

This commit is contained in:
Bryanskiy 2023-06-29 16:24:07 +03:00
parent 0a32ca9831
commit 35c6a1d0f3
19 changed files with 120 additions and 109 deletions

View file

@ -18,7 +18,7 @@ privacy_private_in_public_lint =
}) })
privacy_private_interface_or_bounds_lint = {$ty_kind} `{$ty_descr}` is more private than the item `{$item_descr}` privacy_private_interface_or_bounds_lint = {$ty_kind} `{$ty_descr}` is more private than the item `{$item_descr}`
.item_note = {$item_kind} `{$item_descr}` is reachable at visibility `{$item_vis_descr}` .item_label = {$item_kind} `{$item_descr}` is reachable at visibility `{$item_vis_descr}`
.ty_note = but {$ty_kind} `{$ty_descr}` is only usable at visibility `{$ty_vis_descr}` .ty_note = but {$ty_kind} `{$ty_descr}` is only usable at visibility `{$ty_vis_descr}`
privacy_report_effective_visibility = {$descr} privacy_report_effective_visibility = {$descr}

View file

@ -116,7 +116,7 @@ pub struct UnnameableTypesLint<'a> {
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(privacy_private_interface_or_bounds_lint)] #[diag(privacy_private_interface_or_bounds_lint)]
pub struct PrivateInterfacesOrBoundsLint<'a> { pub struct PrivateInterfacesOrBoundsLint<'a> {
#[note(privacy_item_note)] #[label(privacy_item_label)]
pub item_span: Span, pub item_span: Span,
pub item_kind: &'a str, pub item_kind: &'a str,
pub item_descr: DiagnosticArgFromDisplay<'a>, pub item_descr: DiagnosticArgFromDisplay<'a>,

View file

@ -1865,9 +1865,10 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
} else { } else {
lint::builtin::PRIVATE_BOUNDS lint::builtin::PRIVATE_BOUNDS
}; };
self.tcx.emit_lint( self.tcx.emit_spanned_lint(
lint, lint,
hir_id, hir_id,
span,
PrivateInterfacesOrBoundsLint { PrivateInterfacesOrBoundsLint {
item_span: span, item_span: span,
item_kind: self.tcx.def_descr(self.item_def_id.to_def_id()), item_kind: self.tcx.def_descr(self.item_def_id.to_def_id()),

View file

@ -12,12 +12,15 @@
pub type PubAlias0 = PubTy::PrivAssocTy; pub type PubAlias0 = PubTy::PrivAssocTy;
//~^ ERROR private associated type `PubTy::PrivAssocTy` in public interface (error E0446) //~^ ERROR private associated type `PubTy::PrivAssocTy` in public interface (error E0446)
//~| WARNING this was previously accepted //~| WARNING this was previously accepted
//~| WARNING associated type `PubTy::PrivAssocTy` is more private than the item `PubAlias0`
pub type PubAlias1 = PrivTy::PubAssocTy; pub type PubAlias1 = PrivTy::PubAssocTy;
//~^ ERROR private type `PrivTy` in public interface (error E0446) //~^ ERROR private type `PrivTy` in public interface (error E0446)
//~| WARNING this was previously accepted //~| WARNING this was previously accepted
//~| WARNING type `PrivTy` is more private than the item `PubAlias1`
pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>; pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>;
//~^ ERROR private type `PrivTy` in public interface (error E0446) //~^ ERROR private type `PrivTy` in public interface (error E0446)
//~| WARNING this was previously accepted //~| WARNING this was previously accepted
//~| WARNING type `PrivTy` is more private than the item `PubAlias2`
pub struct PubTy; pub struct PubTy;
impl PubTy { impl PubTy {

View file

@ -13,14 +13,13 @@ LL | #![deny(private_in_public)]
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
warning: associated type `PubTy::PrivAssocTy` is more private than the item `PubAlias0` warning: associated type `PubTy::PrivAssocTy` is more private than the item `PubAlias0`
|
note: type alias `PubAlias0` is reachable at visibility `pub`
--> $DIR/private-in-public.rs:12:1 --> $DIR/private-in-public.rs:12:1
| |
LL | pub type PubAlias0 = PubTy::PrivAssocTy; LL | pub type PubAlias0 = PubTy::PrivAssocTy;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^ type alias `PubAlias0` is reachable at visibility `pub`
|
note: but associated type `PubTy::PrivAssocTy` is only usable at visibility `pub(crate)` note: but associated type `PubTy::PrivAssocTy` is only usable at visibility `pub(crate)`
--> $DIR/private-in-public.rs:24:5 --> $DIR/private-in-public.rs:27:5
| |
LL | type PrivAssocTy = (); LL | type PrivAssocTy = ();
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
@ -31,7 +30,7 @@ LL | #![warn(private_interfaces)]
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: private type `PrivTy` in public interface (error E0446) error: private type `PrivTy` in public interface (error E0446)
--> $DIR/private-in-public.rs:15:1 --> $DIR/private-in-public.rs:16:1
| |
LL | pub type PubAlias1 = PrivTy::PubAssocTy; LL | pub type PubAlias1 = PrivTy::PubAssocTy;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
@ -40,20 +39,19 @@ LL | pub type PubAlias1 = PrivTy::PubAssocTy;
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
warning: type `PrivTy` is more private than the item `PubAlias1` warning: type `PrivTy` is more private than the item `PubAlias1`
| --> $DIR/private-in-public.rs:16:1
note: type alias `PubAlias1` is reachable at visibility `pub`
--> $DIR/private-in-public.rs:15:1
| |
LL | pub type PubAlias1 = PrivTy::PubAssocTy; LL | pub type PubAlias1 = PrivTy::PubAssocTy;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^ type alias `PubAlias1` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)` note: but type `PrivTy` is only usable at visibility `pub(crate)`
--> $DIR/private-in-public.rs:28:1 --> $DIR/private-in-public.rs:31:1
| |
LL | struct PrivTy; LL | struct PrivTy;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: private type `PrivTy` in public interface (error E0446) error: private type `PrivTy` in public interface (error E0446)
--> $DIR/private-in-public.rs:18:1 --> $DIR/private-in-public.rs:20:1
| |
LL | pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>; LL | pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
@ -62,14 +60,13 @@ LL | pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>;
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
warning: type `PrivTy` is more private than the item `PubAlias2` warning: type `PrivTy` is more private than the item `PubAlias2`
| --> $DIR/private-in-public.rs:20:1
note: type alias `PubAlias2` is reachable at visibility `pub`
--> $DIR/private-in-public.rs:18:1
| |
LL | pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>; LL | pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^ type alias `PubAlias2` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)` note: but type `PrivTy` is only usable at visibility `pub(crate)`
--> $DIR/private-in-public.rs:28:1 --> $DIR/private-in-public.rs:31:1
| |
LL | struct PrivTy; LL | struct PrivTy;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^

View file

@ -21,6 +21,7 @@ where
{ {
type AssocTy = Const<{ my_const_fn(U) }>; type AssocTy = Const<{ my_const_fn(U) }>;
//~^ ERROR private type //~^ 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 { fn assoc_fn() -> Self::AssocTy {
Const Const
} }

View file

@ -8,14 +8,13 @@ LL | const fn my_const_fn(val: u8) -> u8 {
| ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private | ----------------------------------- `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` warning: type `fn(u8) -> u8 {my_const_fn}` is more private than the item `<Const<U> as Trait>::AssocTy`
|
note: associated type `<Const<U> as Trait>::AssocTy` is reachable at visibility `pub`
--> $DIR/eval-privacy.rs:22:5 --> $DIR/eval-privacy.rs:22:5
| |
LL | type AssocTy = Const<{ my_const_fn(U) }>; 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)` note: but type `fn(u8) -> u8 {my_const_fn}` is only usable at visibility `pub(crate)`
--> $DIR/eval-privacy.rs:29:1 --> $DIR/eval-privacy.rs:30:1
| |
LL | const fn my_const_fn(val: u8) -> u8 { LL | const fn my_const_fn(val: u8) -> u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -12,9 +12,12 @@ trait Foo {
pub trait Bar : Foo {} pub trait Bar : Foo {}
//~^ ERROR private trait `Foo` in public interface [E0445] //~^ ERROR private trait `Foo` in public interface [E0445]
//~| WARNING trait `Foo` is more private than the item `Bar`
pub struct Bar2<T: Foo>(pub T); pub struct Bar2<T: Foo>(pub T);
//~^ ERROR private trait `Foo` in public interface [E0445] //~^ ERROR private trait `Foo` in public interface [E0445]
//~| WARNING trait `Foo` is more private than the item `Bar2`
pub fn foo<T: Foo> (t: T) {} pub fn foo<T: Foo> (t: T) {}
//~^ ERROR private trait `Foo` in public interface [E0445] //~^ ERROR private trait `Foo` in public interface [E0445]
//~| WARNING trait `Foo` is more private than the item `foo`
fn main() {} fn main() {}

View file

@ -8,12 +8,11 @@ LL | pub trait Bar : Foo {}
| ^^^^^^^^^^^^^^^^^^^ can't leak private trait | ^^^^^^^^^^^^^^^^^^^ can't leak private trait
warning: trait `Foo` is more private than the item `Bar` warning: trait `Foo` is more private than the item `Bar`
|
note: trait `Bar` is reachable at visibility `pub`
--> $DIR/E0445.rs:13:1 --> $DIR/E0445.rs:13:1
| |
LL | pub trait Bar : Foo {} LL | pub trait Bar : Foo {}
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^ trait `Bar` is reachable at visibility `pub`
|
note: but trait `Foo` is only usable at visibility `pub(crate)` note: but trait `Foo` is only usable at visibility `pub(crate)`
--> $DIR/E0445.rs:9:1 --> $DIR/E0445.rs:9:1
| |
@ -26,7 +25,7 @@ LL | #[warn(private_bounds)]
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
error[E0445]: private trait `Foo` in public interface error[E0445]: private trait `Foo` in public interface
--> $DIR/E0445.rs:15:1 --> $DIR/E0445.rs:16:1
| |
LL | trait Foo { LL | trait Foo {
| --------- `Foo` declared as private | --------- `Foo` declared as private
@ -35,12 +34,11 @@ LL | pub struct Bar2<T: Foo>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait | ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
warning: trait `Foo` is more private than the item `Bar2` warning: trait `Foo` is more private than the item `Bar2`
| --> $DIR/E0445.rs:16:1
note: struct `Bar2` is reachable at visibility `pub`
--> $DIR/E0445.rs:15:1
| |
LL | pub struct Bar2<T: Foo>(pub T); LL | pub struct Bar2<T: Foo>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^ struct `Bar2` is reachable at visibility `pub`
|
note: but trait `Foo` is only usable at visibility `pub(crate)` note: but trait `Foo` is only usable at visibility `pub(crate)`
--> $DIR/E0445.rs:9:1 --> $DIR/E0445.rs:9:1
| |
@ -48,7 +46,7 @@ LL | trait Foo {
| ^^^^^^^^^ | ^^^^^^^^^
error[E0445]: private trait `Foo` in public interface error[E0445]: private trait `Foo` in public interface
--> $DIR/E0445.rs:17:1 --> $DIR/E0445.rs:19:1
| |
LL | trait Foo { LL | trait Foo {
| --------- `Foo` declared as private | --------- `Foo` declared as private
@ -57,12 +55,11 @@ LL | pub fn foo<T: Foo> (t: T) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
warning: trait `Foo` is more private than the item `foo` warning: trait `Foo` is more private than the item `foo`
| --> $DIR/E0445.rs:19:1
note: function `foo` is reachable at visibility `pub`
--> $DIR/E0445.rs:17:1
| |
LL | pub fn foo<T: Foo> (t: T) {} LL | pub fn foo<T: Foo> (t: T) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^ function `foo` is reachable at visibility `pub`
|
note: but trait `Foo` is only usable at visibility `pub(crate)` note: but trait `Foo` is only usable at visibility `pub(crate)`
--> $DIR/E0445.rs:9:1 --> $DIR/E0445.rs:9:1
| |

View file

@ -13,6 +13,7 @@ trait Private<P, R> {
} }
pub trait Public: Private< pub trait Public: Private<
//~^ ERROR private trait `Private<<Self as Public>::P, <Self as Public>::R>` in public interface //~^ ERROR private trait `Private<<Self as Public>::P, <Self as Public>::R>` in public interface
//~| WARNING trait `Private<<Self as Public>::P, <Self as Public>::R>` is more private than the item `Public`
<Self as Public>::P, <Self as Public>::P,
<Self as Public>::R <Self as Public>::R
> { > {

View file

@ -6,22 +6,23 @@ LL | trait Private<P, R> {
... ...
LL | / pub trait Public: Private< LL | / pub trait Public: Private<
LL | | LL | |
LL | |
LL | | <Self as Public>::P, LL | | <Self as Public>::P,
LL | | <Self as Public>::R LL | | <Self as Public>::R
LL | | > { LL | | > {
| |_^ can't leak private trait | |_^ can't leak private trait
warning: trait `Private<<Self as Public>::P, <Self as Public>::R>` is more private than the item `Public` warning: trait `Private<<Self as Public>::P, <Self as Public>::R>` is more private than the item `Public`
|
note: trait `Public` is reachable at visibility `pub`
--> $DIR/issue-18389.rs:14:1 --> $DIR/issue-18389.rs:14:1
| |
LL | / pub trait Public: Private< LL | / pub trait Public: Private<
LL | | LL | |
LL | |
LL | | <Self as Public>::P, LL | | <Self as Public>::P,
LL | | <Self as Public>::R LL | | <Self as Public>::R
LL | | > { LL | | > {
| |_^ | |_^ trait `Public` is reachable at visibility `pub`
|
note: but trait `Private<<Self as Public>::P, <Self as Public>::R>` is only usable at visibility `pub(crate)` note: but trait `Private<<Self as Public>::P, <Self as Public>::R>` is only usable at visibility `pub(crate)`
--> $DIR/issue-18389.rs:11:1 --> $DIR/issue-18389.rs:11:1
| |

View file

@ -13,6 +13,7 @@ auto trait PrivNonPrincipal {}
pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loop {} } pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loop {} }
//~^ WARN private trait `PrivNonPrincipal` in public interface //~^ WARN private trait `PrivNonPrincipal` in public interface
//~| WARN this was previously accepted //~| WARN this was previously accepted
//~| ERROR trait `PrivNonPrincipal` is more private than the item `leak_dyn_nonprincipal`
#[deny(missing_docs)] #[deny(missing_docs)]
fn container() { fn container() {

View file

@ -9,12 +9,11 @@ LL | pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal>
= note: `#[warn(private_in_public)]` on by default = note: `#[warn(private_in_public)]` on by default
error: trait `PrivNonPrincipal` is more private than the item `leak_dyn_nonprincipal` error: trait `PrivNonPrincipal` is more private than the item `leak_dyn_nonprincipal`
|
note: function `leak_dyn_nonprincipal` is reachable at visibility `pub`
--> $DIR/private-in-public-non-principal.rs:13:1 --> $DIR/private-in-public-non-principal.rs:13:1
| |
LL | pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loop {} } 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)` 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:11:1
| |
@ -27,13 +26,13 @@ LL | #![deny(private_interfaces)]
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: missing documentation for an associated function error: missing documentation for an associated function
--> $DIR/private-in-public-non-principal.rs:20:9 --> $DIR/private-in-public-non-principal.rs:21:9
| |
LL | pub fn check_doc_lint() {} LL | pub fn check_doc_lint() {}
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
| |
note: the lint level is defined here note: the lint level is defined here
--> $DIR/private-in-public-non-principal.rs:17:8 --> $DIR/private-in-public-non-principal.rs:18:8
| |
LL | #[deny(missing_docs)] LL | #[deny(missing_docs)]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^

View file

@ -25,6 +25,7 @@ impl PubTrWithAssocTy for PrivTy { type AssocTy = PrivTy; }
pub struct S pub struct S
//~^ WARNING private type `PrivTy` in public interface //~^ WARNING private type `PrivTy` in public interface
//~| WARNING hard error //~| WARNING hard error
//~| WARNING type `PrivTy` is more private than the item `S`
where where
PrivTy: PrivTy:
{} {}
@ -33,6 +34,7 @@ where
pub enum E pub enum E
//~^ WARNING private type `PrivTy` in public interface //~^ WARNING private type `PrivTy` in public interface
//~| WARNING hard error //~| WARNING hard error
//~| WARNING type `PrivTy` is more private than the item `E`
where where
PrivTy: PrivTy:
{} {}
@ -41,6 +43,7 @@ where
pub fn f() pub fn f()
//~^ WARNING private type `PrivTy` in public interface //~^ WARNING private type `PrivTy` in public interface
//~| WARNING hard error //~| WARNING hard error
//~| WARNING type `PrivTy` is more private than the item `f`
where where
PrivTy: PrivTy:
{} {}
@ -48,12 +51,14 @@ where
impl S impl S
//~^ ERROR private type `PrivTy` in public interface //~^ ERROR private type `PrivTy` in public interface
//~| WARNING type `PrivTy` is more private than the item `S`
where where
PrivTy: PrivTy:
{ {
pub fn f() pub fn f()
//~^ WARNING private type `PrivTy` in public interface //~^ WARNING private type `PrivTy` in public interface
//~| WARNING hard error //~| WARNING hard error
//~| WARNING type `PrivTy` is more private than the item `S::f`
where where
PrivTy: PrivTy:
{} {}
@ -85,6 +90,7 @@ where
{ {
type AssocTy = Const<{ my_const_fn(U) }>; type AssocTy = Const<{ my_const_fn(U) }>;
//~^ ERROR private type //~^ 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 { fn assoc_fn() -> Self::AssocTy {
Const Const
} }

View file

@ -9,12 +9,11 @@ LL | pub struct S
= note: `#[warn(private_in_public)]` on by default = note: `#[warn(private_in_public)]` on by default
warning: type `PrivTy` is more private than the item `S` warning: type `PrivTy` is more private than the item `S`
|
note: struct `S` is reachable at visibility `pub`
--> $DIR/where-priv-type.rs:25:1 --> $DIR/where-priv-type.rs:25:1
| |
LL | pub struct S LL | pub struct S
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ struct `S` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)` note: but type `PrivTy` is only usable at visibility `pub(crate)`
--> $DIR/where-priv-type.rs:15:1 --> $DIR/where-priv-type.rs:15:1
| |
@ -27,7 +26,7 @@ LL | #![warn(private_bounds)]
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
warning: private type `PrivTy` in public interface (error E0446) warning: private type `PrivTy` in public interface (error E0446)
--> $DIR/where-priv-type.rs:33:1 --> $DIR/where-priv-type.rs:34:1
| |
LL | pub enum E LL | pub enum E
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -36,12 +35,11 @@ LL | pub enum E
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
warning: type `PrivTy` is more private than the item `E` warning: type `PrivTy` is more private than the item `E`
| --> $DIR/where-priv-type.rs:34:1
note: enum `E` is reachable at visibility `pub`
--> $DIR/where-priv-type.rs:33:1
| |
LL | pub enum E LL | pub enum E
| ^^^^^^^^^^ | ^^^^^^^^^^ enum `E` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)` note: but type `PrivTy` is only usable at visibility `pub(crate)`
--> $DIR/where-priv-type.rs:15:1 --> $DIR/where-priv-type.rs:15:1
| |
@ -49,11 +47,12 @@ LL | struct PrivTy;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
warning: private type `PrivTy` in public interface (error E0446) warning: private type `PrivTy` in public interface (error E0446)
--> $DIR/where-priv-type.rs:41:1 --> $DIR/where-priv-type.rs:43:1
| |
LL | / pub fn f() LL | / pub fn f()
LL | | LL | |
LL | | LL | |
LL | |
LL | | where LL | | where
LL | | PrivTy: LL | | PrivTy:
| |___________^ | |___________^
@ -62,16 +61,16 @@ LL | | PrivTy:
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> = 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` warning: type `PrivTy` is more private than the item `f`
| --> $DIR/where-priv-type.rs:43:1
note: function `f` is reachable at visibility `pub`
--> $DIR/where-priv-type.rs:41:1
| |
LL | / pub fn f() LL | / pub fn f()
LL | | LL | |
LL | | LL | |
LL | |
LL | | where LL | | where
LL | | PrivTy: LL | | PrivTy:
| |___________^ | |___________^ function `f` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)` note: but type `PrivTy` is only usable at visibility `pub(crate)`
--> $DIR/where-priv-type.rs:15:1 --> $DIR/where-priv-type.rs:15:1
| |
@ -79,7 +78,7 @@ LL | struct PrivTy;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error[E0446]: private type `PrivTy` in public interface error[E0446]: private type `PrivTy` in public interface
--> $DIR/where-priv-type.rs:49:1 --> $DIR/where-priv-type.rs:52:1
| |
LL | struct PrivTy; LL | struct PrivTy;
| ------------- `PrivTy` declared as private | ------------- `PrivTy` declared as private
@ -88,12 +87,11 @@ LL | impl S
| ^^^^^^ can't leak private type | ^^^^^^ can't leak private type
warning: type `PrivTy` is more private than the item `S` warning: type `PrivTy` is more private than the item `S`
| --> $DIR/where-priv-type.rs:52:1
note: implementation `S` is reachable at visibility `pub`
--> $DIR/where-priv-type.rs:49:1
| |
LL | impl S LL | impl S
| ^^^^^^ | ^^^^^^ implementation `S` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)` note: but type `PrivTy` is only usable at visibility `pub(crate)`
--> $DIR/where-priv-type.rs:15:1 --> $DIR/where-priv-type.rs:15:1
| |
@ -101,11 +99,12 @@ LL | struct PrivTy;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
warning: private type `PrivTy` in public interface (error E0446) warning: private type `PrivTy` in public interface (error E0446)
--> $DIR/where-priv-type.rs:54:5 --> $DIR/where-priv-type.rs:58:5
| |
LL | / pub fn f() LL | / pub fn f()
LL | | LL | |
LL | | LL | |
LL | |
LL | | where LL | | where
LL | | PrivTy: LL | | PrivTy:
| |_______________^ | |_______________^
@ -114,16 +113,16 @@ LL | | PrivTy:
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> = 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` warning: type `PrivTy` is more private than the item `S::f`
| --> $DIR/where-priv-type.rs:58:5
note: associated function `S::f` is reachable at visibility `pub`
--> $DIR/where-priv-type.rs:54:5
| |
LL | / pub fn f() LL | / pub fn f()
LL | | LL | |
LL | | LL | |
LL | |
LL | | where LL | | where
LL | | PrivTy: LL | | PrivTy:
| |_______________^ | |_______________^ associated function `S::f` is reachable at visibility `pub`
|
note: but type `PrivTy` is only usable at visibility `pub(crate)` note: but type `PrivTy` is only usable at visibility `pub(crate)`
--> $DIR/where-priv-type.rs:15:1 --> $DIR/where-priv-type.rs:15:1
| |
@ -131,7 +130,7 @@ LL | struct PrivTy;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface
--> $DIR/where-priv-type.rs:86:5 --> $DIR/where-priv-type.rs:91:5
| |
LL | type AssocTy = Const<{ my_const_fn(U) }>; LL | type AssocTy = Const<{ my_const_fn(U) }>;
| ^^^^^^^^^^^^ can't leak private type | ^^^^^^^^^^^^ can't leak private type
@ -140,14 +139,13 @@ LL | const fn my_const_fn(val: u8) -> u8 {
| ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private | ----------------------------------- `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` 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
note: associated type `<Const<U> as Trait>::AssocTy` is reachable at visibility `pub`
--> $DIR/where-priv-type.rs:86:5
| |
LL | type AssocTy = Const<{ my_const_fn(U) }>; 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)` note: but type `fn(u8) -> u8 {my_const_fn}` is only usable at visibility `pub(crate)`
--> $DIR/where-priv-type.rs:93:1 --> $DIR/where-priv-type.rs:99:1
| |
LL | const fn my_const_fn(val: u8) -> u8 { LL | const fn my_const_fn(val: u8) -> u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -23,6 +23,7 @@ impl PubTrWithAssocTy for PrivTy { type AssocTy = PrivTy; }
pub struct S pub struct S
//~^ ERROR private trait `PrivTr` in public interface //~^ ERROR private trait `PrivTr` in public interface
//~| WARNING trait `PrivTr` is more private than the item `S`
where where
PubTy: PrivTr PubTy: PrivTr
{} {}
@ -30,6 +31,7 @@ where
pub enum E pub enum E
//~^ ERROR private trait `PrivTr` in public interface //~^ ERROR private trait `PrivTr` in public interface
//~| WARNING trait `PrivTr` is more private than the item `E`
where where
PubTy: PrivTr PubTy: PrivTr
{} {}
@ -37,6 +39,7 @@ where
pub fn f() pub fn f()
//~^ ERROR private trait `PrivTr` in public interface //~^ ERROR private trait `PrivTr` in public interface
//~| WARNING trait `PrivTr` is more private than the item `f`
where where
PubTy: PrivTr PubTy: PrivTr
{} {}
@ -44,11 +47,13 @@ where
impl S impl S
//~^ ERROR private trait `PrivTr` in public interface //~^ ERROR private trait `PrivTr` in public interface
//~| WARNING trait `PrivTr` is more private than the item `S`
where where
PubTy: PrivTr PubTy: PrivTr
{ {
pub fn f() pub fn f()
//~^ ERROR private trait `PrivTr` in public interface //~^ ERROR private trait `PrivTr` in public interface
//~| WARNING trait `PrivTr` is more private than the item `S::f`
where where
PubTy: PrivTr PubTy: PrivTr
{} {}

View file

@ -8,12 +8,11 @@ LL | pub struct S
| ^^^^^^^^^^^^ can't leak private trait | ^^^^^^^^^^^^ can't leak private trait
warning: trait `PrivTr` is more private than the item `S` warning: trait `PrivTr` is more private than the item `S`
|
note: struct `S` is reachable at visibility `pub`
--> $DIR/where-pub-type-impls-priv-trait.rs:24:1 --> $DIR/where-pub-type-impls-priv-trait.rs:24:1
| |
LL | pub struct S LL | pub struct S
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ struct `S` is reachable at visibility `pub`
|
note: but trait `PrivTr` is only usable at visibility `pub(crate)` 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:14:1
| |
@ -26,7 +25,7 @@ LL | #![warn(private_bounds)]
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
error[E0445]: private trait `PrivTr` in public interface error[E0445]: private trait `PrivTr` in public interface
--> $DIR/where-pub-type-impls-priv-trait.rs:31:1 --> $DIR/where-pub-type-impls-priv-trait.rs:32:1
| |
LL | trait PrivTr {} LL | trait PrivTr {}
| ------------ `PrivTr` declared as private | ------------ `PrivTr` declared as private
@ -35,12 +34,11 @@ LL | pub enum E
| ^^^^^^^^^^ can't leak private trait | ^^^^^^^^^^ can't leak private trait
warning: trait `PrivTr` is more private than the item `E` warning: trait `PrivTr` is more private than the item `E`
| --> $DIR/where-pub-type-impls-priv-trait.rs:32:1
note: enum `E` is reachable at visibility `pub`
--> $DIR/where-pub-type-impls-priv-trait.rs:31:1
| |
LL | pub enum E LL | pub enum E
| ^^^^^^^^^^ | ^^^^^^^^^^ enum `E` is reachable at visibility `pub`
|
note: but trait `PrivTr` is only usable at visibility `pub(crate)` 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:14:1
| |
@ -48,27 +46,28 @@ LL | trait PrivTr {}
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error[E0445]: private trait `PrivTr` in public interface error[E0445]: private trait `PrivTr` in public interface
--> $DIR/where-pub-type-impls-priv-trait.rs:38:1 --> $DIR/where-pub-type-impls-priv-trait.rs:40:1
| |
LL | trait PrivTr {} LL | trait PrivTr {}
| ------------ `PrivTr` declared as private | ------------ `PrivTr` declared as private
... ...
LL | / pub fn f() LL | / pub fn f()
LL | | LL | |
LL | |
LL | | where LL | | where
LL | | PubTy: PrivTr LL | | PubTy: PrivTr
| |_________________^ can't leak private trait | |_________________^ can't leak private trait
warning: trait `PrivTr` is more private than the item `f` warning: trait `PrivTr` is more private than the item `f`
| --> $DIR/where-pub-type-impls-priv-trait.rs:40:1
note: function `f` is reachable at visibility `pub`
--> $DIR/where-pub-type-impls-priv-trait.rs:38:1
| |
LL | / pub fn f() LL | / pub fn f()
LL | | LL | |
LL | |
LL | | where LL | | where
LL | | PubTy: PrivTr LL | | PubTy: PrivTr
| |_________________^ | |_________________^ function `f` is reachable at visibility `pub`
|
note: but trait `PrivTr` is only usable at visibility `pub(crate)` 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:14:1
| |
@ -76,7 +75,7 @@ LL | trait PrivTr {}
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error[E0445]: private trait `PrivTr` in public interface error[E0445]: private trait `PrivTr` in public interface
--> $DIR/where-pub-type-impls-priv-trait.rs:45:1 --> $DIR/where-pub-type-impls-priv-trait.rs:48:1
| |
LL | trait PrivTr {} LL | trait PrivTr {}
| ------------ `PrivTr` declared as private | ------------ `PrivTr` declared as private
@ -85,12 +84,11 @@ LL | impl S
| ^^^^^^ can't leak private trait | ^^^^^^ can't leak private trait
warning: trait `PrivTr` is more private than the item `S` warning: trait `PrivTr` is more private than the item `S`
| --> $DIR/where-pub-type-impls-priv-trait.rs:48:1
note: implementation `S` is reachable at visibility `pub`
--> $DIR/where-pub-type-impls-priv-trait.rs:45:1
| |
LL | impl S LL | impl S
| ^^^^^^ | ^^^^^^ implementation `S` is reachable at visibility `pub`
|
note: but trait `PrivTr` is only usable at visibility `pub(crate)` 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:14:1
| |
@ -98,27 +96,28 @@ LL | trait PrivTr {}
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error[E0445]: private trait `PrivTr` in public interface error[E0445]: private trait `PrivTr` in public interface
--> $DIR/where-pub-type-impls-priv-trait.rs:50:5 --> $DIR/where-pub-type-impls-priv-trait.rs:54:5
| |
LL | trait PrivTr {} LL | trait PrivTr {}
| ------------ `PrivTr` declared as private | ------------ `PrivTr` declared as private
... ...
LL | / pub fn f() LL | / pub fn f()
LL | | LL | |
LL | |
LL | | where LL | | where
LL | | PubTy: PrivTr LL | | PubTy: PrivTr
| |_____________________^ can't leak private trait | |_____________________^ can't leak private trait
warning: trait `PrivTr` is more private than the item `S::f` warning: trait `PrivTr` is more private than the item `S::f`
| --> $DIR/where-pub-type-impls-priv-trait.rs:54:5
note: associated function `S::f` is reachable at visibility `pub`
--> $DIR/where-pub-type-impls-priv-trait.rs:50:5
| |
LL | / pub fn f() LL | / pub fn f()
LL | | LL | |
LL | |
LL | | where LL | | where
LL | | PubTy: PrivTr LL | | PubTy: PrivTr
| |_____________________^ | |_____________________^ associated function `S::f` is reachable at visibility `pub`
|
note: but trait `PrivTr` is only usable at visibility `pub(crate)` 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:14:1
| |

View file

@ -27,14 +27,17 @@ pub struct Shell<T> {
pub type Helix_pomatia = Shell<Snail>; pub type Helix_pomatia = Shell<Snail>;
//~^ ERROR private type `Snail` in public interface //~^ ERROR private type `Snail` in public interface
//~| WARNING type `Snail` is more private than the item `Helix_pomatia`
//~| NOTE can't leak private type //~| NOTE can't leak private type
//~| NOTE type alias `Helix_pomatia` is reachable at visibility `pub` //~| NOTE type alias `Helix_pomatia` is reachable at visibility `pub`
pub type Dermochelys_coriacea = Shell<sea::Turtle>; pub type Dermochelys_coriacea = Shell<sea::Turtle>;
//~^ ERROR crate-private type `Turtle` in public interface //~^ ERROR crate-private type `Turtle` in public interface
//~| WARNING type `Turtle` is more private than the item `Dermochelys_coriacea`
//~| NOTE can't leak crate-private type //~| NOTE can't leak crate-private type
//~| NOTE type alias `Dermochelys_coriacea` is reachable at visibility `pub` //~| NOTE type alias `Dermochelys_coriacea` is reachable at visibility `pub`
pub type Testudo_graeca = Shell<Tortoise>; pub type Testudo_graeca = Shell<Tortoise>;
//~^ ERROR private type `Tortoise` in public interface //~^ ERROR private type `Tortoise` in public interface
//~| WARNING type `Tortoise` is more private than the item `Testudo_graeca`
//~| NOTE can't leak private type //~| NOTE can't leak private type
//~| NOTE type alias `Testudo_graeca` is reachable at visibility `pub` //~| NOTE type alias `Testudo_graeca` is reachable at visibility `pub`

View file

@ -8,12 +8,11 @@ LL | pub type Helix_pomatia = Shell<Snail>;
| ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
warning: type `Snail` is more private than the item `Helix_pomatia` warning: type `Snail` is more private than the item `Helix_pomatia`
|
note: type alias `Helix_pomatia` is reachable at visibility `pub`
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:28:1 --> $DIR/issue-33174-restricted-type-in-public-interface.rs:28:1
| |
LL | pub type Helix_pomatia = Shell<Snail>; LL | pub type Helix_pomatia = Shell<Snail>;
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^ type alias `Helix_pomatia` is reachable at visibility `pub`
|
note: but type `Snail` is only usable at visibility `pub(crate)` note: but type `Snail` is only usable at visibility `pub(crate)`
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:10:1 --> $DIR/issue-33174-restricted-type-in-public-interface.rs:10:1
| |
@ -26,7 +25,7 @@ LL | #![warn(private_interfaces)]
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error[E0446]: crate-private type `Turtle` in public interface error[E0446]: crate-private type `Turtle` in public interface
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:32:1 --> $DIR/issue-33174-restricted-type-in-public-interface.rs:33:1
| |
LL | pub(super) struct Turtle; LL | pub(super) struct Turtle;
| ------------------------ `Turtle` declared as crate-private | ------------------------ `Turtle` declared as crate-private
@ -35,12 +34,11 @@ LL | pub type Dermochelys_coriacea = Shell<sea::Turtle>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak crate-private type | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak crate-private type
warning: type `Turtle` is more private than the item `Dermochelys_coriacea` warning: type `Turtle` is more private than the item `Dermochelys_coriacea`
| --> $DIR/issue-33174-restricted-type-in-public-interface.rs:33:1
note: type alias `Dermochelys_coriacea` is reachable at visibility `pub`
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:32:1
| |
LL | pub type Dermochelys_coriacea = Shell<sea::Turtle>; LL | pub type Dermochelys_coriacea = Shell<sea::Turtle>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type alias `Dermochelys_coriacea` is reachable at visibility `pub`
|
note: but type `Turtle` is only usable at visibility `pub(crate)` note: but type `Turtle` is only usable at visibility `pub(crate)`
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:15:5 --> $DIR/issue-33174-restricted-type-in-public-interface.rs:15:5
| |
@ -48,7 +46,7 @@ LL | pub(super) struct Turtle;
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0446]: private type `Tortoise` in public interface error[E0446]: private type `Tortoise` in public interface
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:36:1 --> $DIR/issue-33174-restricted-type-in-public-interface.rs:38:1
| |
LL | struct Tortoise; LL | struct Tortoise;
| --------------- `Tortoise` declared as private | --------------- `Tortoise` declared as private
@ -57,12 +55,11 @@ LL | pub type Testudo_graeca = Shell<Tortoise>;
| ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type | ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
warning: type `Tortoise` is more private than the item `Testudo_graeca` warning: type `Tortoise` is more private than the item `Testudo_graeca`
| --> $DIR/issue-33174-restricted-type-in-public-interface.rs:38:1
note: type alias `Testudo_graeca` is reachable at visibility `pub`
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:36:1
| |
LL | pub type Testudo_graeca = Shell<Tortoise>; LL | pub type Testudo_graeca = Shell<Tortoise>;
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^ type alias `Testudo_graeca` is reachable at visibility `pub`
|
note: but type `Tortoise` is only usable at visibility `pub(crate)` note: but type `Tortoise` is only usable at visibility `pub(crate)`
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:20:1 --> $DIR/issue-33174-restricted-type-in-public-interface.rs:20:1
| |