diff options
| author | Bryanskiy <ivakin.kir@gmail.com> | 2023-06-19 17:06:00 +0300 |
|---|---|---|
| committer | Bryanskiy <ivakin.kir@gmail.com> | 2023-08-02 13:40:28 +0300 |
| commit | e26614e6a7f8003dfd2a756db070c6d04ca34c6f (patch) | |
| tree | 22bc39fc5f1b096999c0d39a245e9b6261efcdc8 /tests/ui/error-codes | |
| parent | 5cbfee545543a8e3d91c54997c6bcd24d2054321 (diff) | |
| download | rust-e26614e6a7f8003dfd2a756db070c6d04ca34c6f.tar.gz rust-e26614e6a7f8003dfd2a756db070c6d04ca34c6f.zip | |
Replace old private-in-public diagnostic with type privacy lints
Diffstat (limited to 'tests/ui/error-codes')
| -rw-r--r-- | tests/ui/error-codes/E0445.rs | 23 | ||||
| -rw-r--r-- | tests/ui/error-codes/E0445.stderr | 71 | ||||
| -rw-r--r-- | tests/ui/error-codes/E0446.rs | 15 | ||||
| -rw-r--r-- | tests/ui/error-codes/E0446.stderr | 23 |
4 files changed, 26 insertions, 106 deletions
diff --git a/tests/ui/error-codes/E0445.rs b/tests/ui/error-codes/E0445.rs deleted file mode 100644 index 9f29c81673e..00000000000 --- a/tests/ui/error-codes/E0445.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![feature(type_privacy_lints)] -#[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. - -trait Foo { - 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() {} diff --git a/tests/ui/error-codes/E0445.stderr b/tests/ui/error-codes/E0445.stderr deleted file mode 100644 index 4f940868ff9..00000000000 --- a/tests/ui/error-codes/E0445.stderr +++ /dev/null @@ -1,71 +0,0 @@ -error[E0445]: private trait `Foo` in public interface - --> $DIR/E0445.rs:13:1 - | -LL | trait Foo { - | --------- `Foo` declared as private -... -LL | pub trait Bar : Foo {} - | ^^^^^^^^^^^^^^^^^^^ can't leak private trait - -warning: trait `Foo` is more private than the item `Bar` - --> $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 - | -LL | trait Foo { - | ^^^^^^^^^ -note: the lint level is defined here - --> $DIR/E0445.rs:2:8 - | -LL | #[warn(private_bounds)] - | ^^^^^^^^^^^^^^ - -error[E0445]: private trait `Foo` in public interface - --> $DIR/E0445.rs:16:1 - | -LL | trait Foo { - | --------- `Foo` declared as private -... -LL | pub struct Bar2<T: Foo>(pub T); - | ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait - -warning: trait `Foo` is more private than the item `Bar2` - --> $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 - | -LL | trait Foo { - | ^^^^^^^^^ - -error[E0445]: private trait `Foo` in public interface - --> $DIR/E0445.rs:19:1 - | -LL | trait Foo { - | --------- `Foo` declared as private -... -LL | pub fn foo<T: Foo> (t: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait - -warning: trait `Foo` is more private than the item `foo` - --> $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 - | -LL | trait Foo { - | ^^^^^^^^^ - -error: aborting due to 3 previous errors; 3 warnings emitted - -For more information about this error, try `rustc --explain E0445`. diff --git a/tests/ui/error-codes/E0446.rs b/tests/ui/error-codes/E0446.rs index f61c7e54616..6d6c4f97c06 100644 --- a/tests/ui/error-codes/E0446.rs +++ b/tests/ui/error-codes/E0446.rs @@ -1,9 +1,14 @@ -mod foo { - struct Bar(u32); +struct Bar; +trait PrivTr {} - pub fn bar() -> Bar { //~ ERROR E0446 - Bar(0) - } +pub trait PubTr { + type Alias1; + type Alias2; +} + +impl PubTr for u8 { + type Alias1 = Bar; //~ ERROR E0446 + type Alias2 = Box<dyn PrivTr>; //~ ERROR E0446 } fn main() {} diff --git a/tests/ui/error-codes/E0446.stderr b/tests/ui/error-codes/E0446.stderr index b6a195c40a9..2951e69d1c2 100644 --- a/tests/ui/error-codes/E0446.stderr +++ b/tests/ui/error-codes/E0446.stderr @@ -1,12 +1,21 @@ error[E0446]: private type `Bar` in public interface - --> $DIR/E0446.rs:4:5 + --> $DIR/E0446.rs:10:5 | -LL | struct Bar(u32); - | ---------- `Bar` declared as private -LL | -LL | pub fn bar() -> Bar { - | ^^^^^^^^^^^^^^^^^^^ can't leak private type +LL | struct Bar; + | ---------- `Bar` declared as private +... +LL | type Alias1 = Bar; + | ^^^^^^^^^^^ can't leak private type -error: aborting due to previous error +error[E0446]: private trait `PrivTr` in public interface + --> $DIR/E0446.rs:11:5 + | +LL | trait PrivTr {} + | ------------ `PrivTr` declared as private +... +LL | type Alias2 = Box<dyn PrivTr>; + | ^^^^^^^^^^^ can't leak private trait + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0446`. |
