Rollup merge of #113161 - Bryanskiy:err_msg, r=petrochenkov

Fix type privacy lints error message

Type privacy lints diagnostic messages are not related to spans.

r? `@petrochenkov`
This commit is contained in:
Matthias Krüger 2023-06-29 16:36:33 +02:00 committed by GitHub
commit 4338683b94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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}`
.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}`
privacy_report_effective_visibility = {$descr}

View File

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

View File

@ -1865,9 +1865,10 @@ fn check_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display)
} else {
lint::builtin::PRIVATE_BOUNDS
};
self.tcx.emit_lint(
self.tcx.emit_spanned_lint(
lint,
hir_id,
span,
PrivateInterfacesOrBoundsLint {
item_span: span,
item_kind: self.tcx.def_descr(self.item_def_id.to_def_id()),

View File

@ -12,12 +12,15 @@
pub type PubAlias0 = PubTy::PrivAssocTy;
//~^ ERROR private associated type `PubTy::PrivAssocTy` in public interface (error E0446)
//~| WARNING this was previously accepted
//~| WARNING associated type `PubTy::PrivAssocTy` is more private than the item `PubAlias0`
pub type PubAlias1 = PrivTy::PubAssocTy;
//~^ ERROR private type `PrivTy` in public interface (error E0446)
//~| WARNING this was previously accepted
//~| WARNING type `PrivTy` is more private than the item `PubAlias1`
pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>;
//~^ ERROR private type `PrivTy` in public interface (error E0446)
//~| WARNING this was previously accepted
//~| WARNING type `PrivTy` is more private than the item `PubAlias2`
pub struct 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`
|
note: type alias `PubAlias0` is reachable at visibility `pub`
--> $DIR/private-in-public.rs:12:1
|
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)`
--> $DIR/private-in-public.rs:24:5
--> $DIR/private-in-public.rs:27:5
|
LL | type PrivAssocTy = ();
| ^^^^^^^^^^^^^^^^
@ -31,7 +30,7 @@ LL | #![warn(private_interfaces)]
| ^^^^^^^^^^^^^^^^^^
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;
| ^^^^^^^^^^^^^^^^^^
@ -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>
warning: type `PrivTy` is more private than the item `PubAlias1`
|
note: type alias `PubAlias1` is reachable at visibility `pub`
--> $DIR/private-in-public.rs:15:1
--> $DIR/private-in-public.rs:16:1
|
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)`
--> $DIR/private-in-public.rs:28:1
--> $DIR/private-in-public.rs:31:1
|
LL | struct PrivTy;
| ^^^^^^^^^^^^^
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>;
| ^^^^^^^^^^^^^^^^^^
@ -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>
warning: type `PrivTy` is more private than the item `PubAlias2`
|
note: type alias `PubAlias2` is reachable at visibility `pub`
--> $DIR/private-in-public.rs:18:1
--> $DIR/private-in-public.rs:20:1
|
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)`
--> $DIR/private-in-public.rs:28:1
--> $DIR/private-in-public.rs:31:1
|
LL | struct PrivTy;
| ^^^^^^^^^^^^^

View File

@ -21,6 +21,7 @@ impl<const U: u8> Trait for Const<U> // OK, trait impl predicates
{
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
}

View File

@ -8,14 +8,13 @@ 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`
|
note: associated type `<Const<U> as Trait>::AssocTy` is reachable at visibility `pub`
--> $DIR/eval-privacy.rs:22: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/eval-privacy.rs:29:1
--> $DIR/eval-privacy.rs:30:1
|
LL | const fn my_const_fn(val: u8) -> u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -12,9 +12,12 @@ fn dummy(&self) { }
pub trait Bar : Foo {}
//~^ 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);
//~^ 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) {}
//~^ ERROR private trait `Foo` in public interface [E0445]
//~| WARNING trait `Foo` is more private than the item `foo`
fn main() {}

View File

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

View File

@ -13,6 +13,7 @@ trait Private<P, R> {
}
pub trait Public: Private<
//~^ 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>::R
> {

View File

@ -6,22 +6,23 @@ LL | trait Private<P, R> {
...
LL | / pub trait Public: Private<
LL | |
LL | |
LL | | <Self as Public>::P,
LL | | <Self as Public>::R
LL | | > {
| |_^ can't leak private trait
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
|
LL | / pub trait Public: Private<
LL | |
LL | |
LL | | <Self as Public>::P,
LL | | <Self as Public>::R
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)`
--> $DIR/issue-18389.rs:11:1
|

View File

@ -13,6 +13,7 @@ pub trait PubPrincipal {}
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`
#[deny(missing_docs)]
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
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
|
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
|
@ -27,13 +26,13 @@ LL | #![deny(private_interfaces)]
| ^^^^^^^^^^^^^^^^^^
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() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
|
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)]
| ^^^^^^^^^^^^

View File

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

View File

@ -9,12 +9,11 @@ LL | pub struct S
= note: `#[warn(private_in_public)]` on by default
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
|
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
|
@ -27,7 +26,7 @@ LL | #![warn(private_bounds)]
| ^^^^^^^^^^^^^^
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
| ^^^^^^^^^^
@ -36,12 +35,11 @@ LL | pub enum E
= 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`
|
note: enum `E` is reachable at visibility `pub`
--> $DIR/where-priv-type.rs:33:1
--> $DIR/where-priv-type.rs:34: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
|
@ -49,11 +47,12 @@ LL | struct PrivTy;
| ^^^^^^^^^^^^^
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 | |
LL | |
LL | |
LL | | where
LL | | PrivTy:
| |___________^
@ -62,16 +61,16 @@ LL | | PrivTy:
= 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`
|
note: function `f` is reachable at visibility `pub`
--> $DIR/where-priv-type.rs:41:1
--> $DIR/where-priv-type.rs:43: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
|
@ -79,7 +78,7 @@ LL | struct PrivTy;
| ^^^^^^^^^^^^^
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;
| ------------- `PrivTy` declared as private
@ -88,12 +87,11 @@ LL | impl S
| ^^^^^^ can't leak private type
warning: type `PrivTy` is more private than the item `S`
|
note: implementation `S` is reachable at visibility `pub`
--> $DIR/where-priv-type.rs:49:1
--> $DIR/where-priv-type.rs:52: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
|
@ -101,11 +99,12 @@ LL | struct PrivTy;
| ^^^^^^^^^^^^^
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 | |
LL | |
LL | |
LL | | where
LL | | PrivTy:
| |_______________^
@ -114,16 +113,16 @@ LL | | PrivTy:
= 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`
|
note: associated function `S::f` is reachable at visibility `pub`
--> $DIR/where-priv-type.rs:54:5
--> $DIR/where-priv-type.rs:58: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
|
@ -131,7 +130,7 @@ LL | struct PrivTy;
| ^^^^^^^^^^^^^
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) }>;
| ^^^^^^^^^^^^ 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
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/where-priv-type.rs:86:5
--> $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:93:1
--> $DIR/where-priv-type.rs:99:1
|
LL | const fn my_const_fn(val: u8) -> u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

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

View File

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

View File

@ -27,14 +27,17 @@ pub struct Shell<T> {
pub type Helix_pomatia = Shell<Snail>;
//~^ 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 type alias `Helix_pomatia` is reachable at visibility `pub`
pub type Dermochelys_coriacea = Shell<sea::Turtle>;
//~^ 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 type alias `Dermochelys_coriacea` is reachable at visibility `pub`
pub type Testudo_graeca = Shell<Tortoise>;
//~^ 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 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
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
|
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)`
--> $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
--> $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;
| ------------------------ `Turtle` declared as crate-private
@ -35,12 +34,11 @@ LL | pub type Dermochelys_coriacea = Shell<sea::Turtle>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak crate-private type
warning: type `Turtle` is more private than the item `Dermochelys_coriacea`
|
note: type alias `Dermochelys_coriacea` is reachable at visibility `pub`
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:32:1
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:33:1
|
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)`
--> $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
--> $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;
| --------------- `Tortoise` declared as private
@ -57,12 +55,11 @@ LL | pub type Testudo_graeca = Shell<Tortoise>;
| ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
warning: type `Tortoise` is more private than the item `Testudo_graeca`
|
note: type alias `Testudo_graeca` is reachable at visibility `pub`
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:36:1
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:38:1
|
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)`
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:20:1
|