Auto merge of #78077 - petrochenkov:qvis, r=davidtwco
Calculate visibilities once in resolve Then use them through a query based on resolver outputs. Item visibilities were previously calculated in three places - initially in `rustc_resolve`, then in `rustc_privacy` during type privacy checkin, and then in `rustc_metadata` during metadata encoding. The visibility logic is not entirely trivial, especially for things like constructors or enum variants, and all of it was duplicated. This PR deduplicates all the visibility calculations, visibilities are determined once during early name resolution and then stored in `ResolverOutputs` and are later available through `tcx` as a query `tcx.visibility(def_id)`. (This query existed previously, but only worked for other crates.) Some special cases (e.g. visibilities for closure types, which are needed for type privacy checking) are not processed in resolve, but deferred and performed directly in the query instead.
This commit is contained in:
commit
1eaadebb3d
26 changed files with 323 additions and 409 deletions
|
|
@ -1,18 +1,27 @@
|
|||
error[E0445]: private trait `Foo` in public interface
|
||||
--> $DIR/E0445.rs:5:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --------- `Foo` declared as private
|
||||
...
|
||||
LL | pub trait Bar : Foo {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
||||
error[E0445]: private trait `Foo` in public interface
|
||||
--> $DIR/E0445.rs:7:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --------- `Foo` declared as private
|
||||
...
|
||||
LL | pub struct Bar2<T: Foo>(pub T);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
||||
error[E0445]: private trait `Foo` in public interface
|
||||
--> $DIR/E0445.rs:9:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --------- `Foo` declared as private
|
||||
...
|
||||
LL | pub fn foo<T: Foo> (t: T) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0446]: private type `Bar` in public interface
|
|||
--> $DIR/E0446.rs:4:5
|
||||
|
|
||||
LL | struct Bar(u32);
|
||||
| - `Bar` declared as private
|
||||
| ---------------- `Bar` declared as private
|
||||
LL |
|
||||
LL | pub fn bar() -> Bar {
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0445]: private trait `Private<<Self as Public>::P, <Self as Public>::R>`
|
|||
--> $DIR/issue-18389.rs:7:1
|
||||
|
|
||||
LL | trait Private<P, R> {
|
||||
| - `Private<<Self as Public>::P, <Self as Public>::R>` declared as private
|
||||
| ------------------- `Private<<Self as Public>::P, <Self as Public>::R>` declared as private
|
||||
...
|
||||
LL | / pub trait Public: Private<
|
||||
LL | |
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ error[E0446]: private type `m2::Priv` in public interface
|
|||
--> $DIR/issue-30079.rs:18:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `m2::Priv` declared as private
|
||||
| ------------ `m2::Priv` declared as private
|
||||
LL | impl ::std::ops::Deref for ::SemiPriv {
|
||||
LL | type Target = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -21,7 +21,7 @@ error[E0446]: private type `m3::Priv` in public interface
|
|||
--> $DIR/issue-30079.rs:35:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `m3::Priv` declared as private
|
||||
| ------------ `m3::Priv` declared as private
|
||||
LL | impl ::SemiPrivTrait for () {
|
||||
LL | type Assoc = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0446]: private type `Priv` in public interface
|
|||
--> $DIR/private-in-public-assoc-ty.rs:17:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `Priv` declared as private
|
||||
| ------------ `Priv` declared as private
|
||||
...
|
||||
LL | type A = Priv;
|
||||
| ^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -39,7 +39,7 @@ error[E0446]: private type `Priv` in public interface
|
|||
--> $DIR/private-in-public-assoc-ty.rs:34:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `Priv` declared as private
|
||||
| ------------ `Priv` declared as private
|
||||
...
|
||||
LL | type Alias4 = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -48,7 +48,7 @@ error[E0446]: private type `Priv` in public interface
|
|||
--> $DIR/private-in-public-assoc-ty.rs:41:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `Priv` declared as private
|
||||
| ------------ `Priv` declared as private
|
||||
...
|
||||
LL | type Alias1 = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -57,7 +57,7 @@ error[E0445]: private trait `PrivTr` in public interface
|
|||
--> $DIR/private-in-public-assoc-ty.rs:44:9
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| - `PrivTr` declared as private
|
||||
| ------------ `PrivTr` declared as private
|
||||
...
|
||||
LL | type Exist = impl PrivTr;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ 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
|
||||
| ------------ `m1::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f() -> Priv {Priv}
|
||||
| ^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -11,7 +11,7 @@ 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
|
||||
| ------------ `m2::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f() -> Priv {Priv}
|
||||
| ^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ error[E0446]: private type `types::Priv` in public interface
|
|||
--> $DIR/private-in-public-warn.rs:26:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `types::Priv` declared as private
|
||||
| ------------ `types::Priv` declared as private
|
||||
...
|
||||
LL | type Alias = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -97,7 +97,7 @@ error[E0446]: private type `types::Priv` in public interface
|
|||
--> $DIR/private-in-public-warn.rs:41:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `types::Priv` declared as private
|
||||
| ------------ `types::Priv` declared as private
|
||||
...
|
||||
LL | type Alias = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -250,7 +250,7 @@ error[E0446]: private type `impls::Priv` in public interface
|
|||
--> $DIR/private-in-public-warn.rs:135:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `impls::Priv` declared as private
|
||||
| ------------ `impls::Priv` declared as private
|
||||
...
|
||||
LL | type Alias = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -268,7 +268,7 @@ error[E0446]: private type `aliases_pub::Priv` in public interface
|
|||
--> $DIR/private-in-public-warn.rs:210:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `aliases_pub::Priv` declared as private
|
||||
| ------------ `aliases_pub::Priv` declared as private
|
||||
...
|
||||
LL | type Check = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -277,7 +277,7 @@ error[E0446]: private type `aliases_pub::Priv` in public interface
|
|||
--> $DIR/private-in-public-warn.rs:213:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `aliases_pub::Priv` declared as private
|
||||
| ------------ `aliases_pub::Priv` declared as private
|
||||
...
|
||||
LL | type Check = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -286,7 +286,7 @@ error[E0446]: private type `aliases_pub::Priv` in public interface
|
|||
--> $DIR/private-in-public-warn.rs:216:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `aliases_pub::Priv` declared as private
|
||||
| ------------ `aliases_pub::Priv` declared as private
|
||||
...
|
||||
LL | type Check = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -295,7 +295,7 @@ error[E0446]: private type `aliases_pub::Priv` in public interface
|
|||
--> $DIR/private-in-public-warn.rs:219:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `aliases_pub::Priv` declared as private
|
||||
| ------------ `aliases_pub::Priv` declared as private
|
||||
...
|
||||
LL | type Check = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0446]: private type `types::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:13:5
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `types::Priv` declared as private
|
||||
| ------------ `types::Priv` declared as private
|
||||
...
|
||||
LL | pub const C: Priv = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -11,7 +11,7 @@ error[E0446]: private type `types::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:14:5
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `types::Priv` declared as private
|
||||
| ------------ `types::Priv` declared as private
|
||||
...
|
||||
LL | pub static S: Priv = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -20,7 +20,7 @@ error[E0446]: private type `types::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:15:5
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `types::Priv` declared as private
|
||||
| ------------ `types::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f1(arg: Priv) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -29,7 +29,7 @@ error[E0446]: private type `types::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:16:5
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `types::Priv` declared as private
|
||||
| ------------ `types::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f2() -> Priv { panic!() }
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -38,7 +38,7 @@ error[E0446]: private type `types::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:17:19
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `types::Priv` declared as private
|
||||
| ------------ `types::Priv` declared as private
|
||||
...
|
||||
LL | pub struct S1(pub Priv);
|
||||
| ^^^^^^^^ can't leak private type
|
||||
|
|
@ -47,7 +47,7 @@ error[E0446]: private type `types::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:18:21
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `types::Priv` declared as private
|
||||
| ------------ `types::Priv` declared as private
|
||||
...
|
||||
LL | pub struct S2 { pub field: Priv }
|
||||
| ^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -56,7 +56,7 @@ error[E0446]: private type `types::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:20:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `types::Priv` declared as private
|
||||
| ------------ `types::Priv` declared as private
|
||||
...
|
||||
LL | pub const C: Priv = Priv;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -65,7 +65,7 @@ error[E0446]: private type `types::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:21:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `types::Priv` declared as private
|
||||
| ------------ `types::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f1(arg: Priv) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -74,7 +74,7 @@ error[E0446]: private type `types::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:22:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `types::Priv` declared as private
|
||||
| ------------ `types::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f2() -> Priv { panic!() }
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -83,7 +83,7 @@ error[E0445]: private trait `traits::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:31:5
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| - `traits::PrivTr` declared as private
|
||||
| ------------ `traits::PrivTr` declared as private
|
||||
...
|
||||
LL | pub enum E<T: PrivTr> { V(T) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
|
@ -92,7 +92,7 @@ error[E0445]: private trait `traits::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:32:5
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| - `traits::PrivTr` declared as private
|
||||
| ------------ `traits::PrivTr` declared as private
|
||||
...
|
||||
LL | pub fn f<T: PrivTr>(arg: T) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
|
@ -101,7 +101,7 @@ error[E0445]: private trait `traits::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:33:5
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| - `traits::PrivTr` declared as private
|
||||
| ------------ `traits::PrivTr` declared as private
|
||||
...
|
||||
LL | pub struct S1<T: PrivTr>(T);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
|
@ -110,7 +110,7 @@ error[E0445]: private trait `traits::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:34:5
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| - `traits::PrivTr` declared as private
|
||||
| ------------ `traits::PrivTr` declared as private
|
||||
...
|
||||
LL | / impl<T: PrivTr> Pub<T> {
|
||||
LL | | pub fn f<U: PrivTr>(arg: U) {}
|
||||
|
|
@ -121,7 +121,7 @@ error[E0445]: private trait `traits::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:35:9
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| - `traits::PrivTr` declared as private
|
||||
| ------------ `traits::PrivTr` declared as private
|
||||
...
|
||||
LL | pub fn f<U: PrivTr>(arg: U) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
|
@ -130,7 +130,7 @@ error[E0445]: private trait `traits_where::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:44:5
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| - `traits_where::PrivTr` declared as private
|
||||
| ------------ `traits_where::PrivTr` declared as private
|
||||
...
|
||||
LL | pub enum E<T> where T: PrivTr { V(T) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
|
@ -139,7 +139,7 @@ error[E0445]: private trait `traits_where::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:46:5
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| - `traits_where::PrivTr` declared as private
|
||||
| ------------ `traits_where::PrivTr` declared as private
|
||||
...
|
||||
LL | pub fn f<T>(arg: T) where T: PrivTr {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
|
@ -148,7 +148,7 @@ error[E0445]: private trait `traits_where::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:48:5
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| - `traits_where::PrivTr` declared as private
|
||||
| ------------ `traits_where::PrivTr` declared as private
|
||||
...
|
||||
LL | pub struct S1<T>(T) where T: PrivTr;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
|
@ -157,7 +157,7 @@ error[E0445]: private trait `traits_where::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:50:5
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| - `traits_where::PrivTr` declared as private
|
||||
| ------------ `traits_where::PrivTr` declared as private
|
||||
...
|
||||
LL | / impl<T> Pub<T> where T: PrivTr {
|
||||
LL | |
|
||||
|
|
@ -170,7 +170,7 @@ error[E0445]: private trait `traits_where::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:52:9
|
||||
|
|
||||
LL | trait PrivTr {}
|
||||
| - `traits_where::PrivTr` declared as private
|
||||
| ------------ `traits_where::PrivTr` declared as private
|
||||
...
|
||||
LL | pub fn f<U>(arg: U) where U: PrivTr {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
|
@ -179,7 +179,7 @@ error[E0446]: private type `generics::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:63:5
|
||||
|
|
||||
LL | struct Priv<T = u8>(T);
|
||||
| - `generics::Priv` declared as private
|
||||
| ----------------------- `generics::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f1(arg: [Priv; 1]) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -188,7 +188,7 @@ error[E0446]: private type `generics::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:64:5
|
||||
|
|
||||
LL | struct Priv<T = u8>(T);
|
||||
| - `generics::Priv` declared as private
|
||||
| ----------------------- `generics::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f2(arg: Pub<Priv>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -197,7 +197,7 @@ error[E0446]: private type `generics::Priv<generics::Pub>` in public interface
|
|||
--> $DIR/private-in-public.rs:65:5
|
||||
|
|
||||
LL | struct Priv<T = u8>(T);
|
||||
| - `generics::Priv<generics::Pub>` declared as private
|
||||
| ----------------------- `generics::Priv<generics::Pub>` declared as private
|
||||
...
|
||||
LL | pub fn f3(arg: Priv<Pub>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -206,7 +206,7 @@ error[E0446]: private type `impls::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:80:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `impls::Priv` declared as private
|
||||
| ------------ `impls::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f(arg: Priv) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -215,7 +215,7 @@ error[E0445]: private trait `aliases_pub::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:104:5
|
||||
|
|
||||
LL | trait PrivTr {
|
||||
| - `aliases_pub::PrivTr` declared as private
|
||||
| ------------ `aliases_pub::PrivTr` declared as private
|
||||
...
|
||||
LL | pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
|
@ -224,7 +224,7 @@ error[E0446]: private type `aliases_pub::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:104:5
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `aliases_pub::Priv` declared as private
|
||||
| ------------ `aliases_pub::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -233,7 +233,7 @@ error[E0446]: private type `aliases_pub::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:109:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `aliases_pub::Priv` declared as private
|
||||
| ------------ `aliases_pub::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f(arg: Priv) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -242,7 +242,7 @@ error[E0446]: private type `Priv1` in public interface
|
|||
--> $DIR/private-in-public.rs:131:5
|
||||
|
|
||||
LL | struct Priv1;
|
||||
| - `Priv1` declared as private
|
||||
| ------------- `Priv1` declared as private
|
||||
...
|
||||
LL | pub fn f1(arg: PrivUseAlias) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -251,7 +251,7 @@ error[E0446]: private type `Priv2` in public interface
|
|||
--> $DIR/private-in-public.rs:132:5
|
||||
|
|
||||
LL | struct Priv2;
|
||||
| - `Priv2` declared as private
|
||||
| ------------- `Priv2` declared as private
|
||||
...
|
||||
LL | pub fn f2(arg: PrivAlias) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -260,7 +260,7 @@ error[E0445]: private trait `aliases_priv::PrivTr` in public interface
|
|||
--> $DIR/private-in-public.rs:133:5
|
||||
|
|
||||
LL | trait PrivTr {
|
||||
| - `aliases_priv::PrivTr` declared as private
|
||||
| ------------ `aliases_priv::PrivTr` declared as private
|
||||
...
|
||||
LL | pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
|
||||
|
|
@ -269,7 +269,7 @@ error[E0446]: private type `aliases_priv::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:133:5
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `aliases_priv::Priv` declared as private
|
||||
| ------------ `aliases_priv::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f3(arg: <Priv as PrivTr>::Assoc) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -278,7 +278,7 @@ error[E0446]: private type `aliases_params::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:143:5
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `aliases_params::Priv` declared as private
|
||||
| ------------ `aliases_params::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f2(arg: PrivAliasGeneric) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -287,7 +287,7 @@ error[E0446]: private type `aliases_params::Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:145:5
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `aliases_params::Priv` declared as private
|
||||
| ------------ `aliases_params::Priv` declared as private
|
||||
...
|
||||
LL | pub fn f3(arg: Result<u8>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0446]: private type `Priv` in public interface
|
|||
--> $DIR/private-inferred-type.rs:61:36
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `Priv` declared as private
|
||||
| ------------ `Priv` declared as private
|
||||
...
|
||||
LL | impl TraitWithAssocTy for u8 { type AssocTy = Priv; }
|
||||
| ^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -11,7 +11,7 @@ error[E0446]: private type `S2` in public interface
|
|||
--> $DIR/private-inferred-type.rs:83:9
|
||||
|
|
||||
LL | struct S2;
|
||||
| - `S2` declared as private
|
||||
| ---------- `S2` declared as private
|
||||
...
|
||||
LL | type Target = S2Alias;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0446]: private type `Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:8:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `Priv` declared as private
|
||||
| ------------ `Priv` declared as private
|
||||
...
|
||||
LL | pub(crate) fn g(_: Priv) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
@ -11,7 +11,7 @@ error[E0446]: private type `Priv` in public interface
|
|||
--> $DIR/private-in-public.rs:9:9
|
||||
|
|
||||
LL | struct Priv;
|
||||
| - `Priv` declared as private
|
||||
| ------------ `Priv` declared as private
|
||||
...
|
||||
LL | crate fn h(_: Priv) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
#[macro_use]
|
||||
extern crate issue_50493;
|
||||
|
||||
#[derive(Derive)] //~ ERROR field `field` of struct `Restricted` is private
|
||||
//~| ERROR field `field` of struct `Restricted` is private
|
||||
#[derive(Derive)]
|
||||
struct Restricted {
|
||||
pub(in restricted) field: usize, //~ visibilities can only be restricted to ancestor modules
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,9 @@
|
|||
error[E0742]: visibilities can only be restricted to ancestor modules
|
||||
--> $DIR/issue-50493.rs:9:12
|
||||
--> $DIR/issue-50493.rs:8:12
|
||||
|
|
||||
LL | pub(in restricted) field: usize,
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error[E0616]: field `field` of struct `Restricted` is private
|
||||
--> $DIR/issue-50493.rs:6:10
|
||||
|
|
||||
LL | #[derive(Derive)]
|
||||
| ^^^^^^ private field
|
||||
|
|
||||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
error: aborting due to previous error
|
||||
|
||||
error[E0616]: field `field` of struct `Restricted` is private
|
||||
--> $DIR/issue-50493.rs:6:10
|
||||
|
|
||||
LL | #[derive(Derive)]
|
||||
| ^^^^^^ private field
|
||||
|
|
||||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0616, E0742.
|
||||
For more information about an error, try `rustc --explain E0616`.
|
||||
For more information about this error, try `rustc --explain E0742`.
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#![allow(non_camel_case_types)] // genus is always capitalized
|
||||
#![allow(non_camel_case_types)] // genus is always capitalized
|
||||
|
||||
pub(crate) struct Snail;
|
||||
//~^ NOTE `Snail` declared as crate-visible
|
||||
//~^ NOTE `Snail` declared as private
|
||||
|
||||
mod sea {
|
||||
pub(super) struct Turtle;
|
||||
//~^ NOTE `Turtle` declared as restricted
|
||||
//~^ NOTE `Turtle` declared as crate-private
|
||||
}
|
||||
|
||||
struct Tortoise;
|
||||
|
|
@ -16,11 +16,11 @@ pub struct Shell<T> {
|
|||
}
|
||||
|
||||
pub type Helix_pomatia = Shell<Snail>;
|
||||
//~^ ERROR crate-visible type `Snail` in public interface
|
||||
//~| NOTE can't leak crate-visible type
|
||||
//~^ ERROR private type `Snail` in public interface
|
||||
//~| NOTE can't leak private type
|
||||
pub type Dermochelys_coriacea = Shell<sea::Turtle>;
|
||||
//~^ ERROR restricted type `Turtle` in public interface
|
||||
//~| NOTE can't leak restricted type
|
||||
//~^ ERROR crate-private type `Turtle` in public interface
|
||||
//~| NOTE can't leak crate-private type
|
||||
pub type Testudo_graeca = Shell<Tortoise>;
|
||||
//~^ ERROR private type `Tortoise` in public interface
|
||||
//~| NOTE can't leak private type
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
error[E0446]: crate-visible type `Snail` in public interface
|
||||
error[E0446]: private type `Snail` in public interface
|
||||
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:18:1
|
||||
|
|
||||
LL | pub(crate) struct Snail;
|
||||
| ---------- `Snail` declared as crate-visible
|
||||
| ------------------------ `Snail` declared as private
|
||||
...
|
||||
LL | pub type Helix_pomatia = Shell<Snail>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak crate-visible type
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
||||
error[E0446]: restricted type `Turtle` in public interface
|
||||
error[E0446]: crate-private type `Turtle` in public interface
|
||||
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:21:1
|
||||
|
|
||||
LL | pub(super) struct Turtle;
|
||||
| ---------- `Turtle` declared as restricted
|
||||
| ------------------------- `Turtle` declared as crate-private
|
||||
...
|
||||
LL | pub type Dermochelys_coriacea = Shell<sea::Turtle>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak restricted type
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak crate-private type
|
||||
|
||||
error[E0446]: private type `Tortoise` in public interface
|
||||
--> $DIR/issue-33174-restricted-type-in-public-interface.rs:24:1
|
||||
|
|
||||
LL | struct Tortoise;
|
||||
| - `Tortoise` declared as private
|
||||
| ---------------- `Tortoise` declared as private
|
||||
...
|
||||
LL | pub type Testudo_graeca = Shell<Tortoise>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue