Skip to content

Commit e78d086

Browse files
committed
tests: add private rpitit tests
1 parent a9fb610 commit e78d086

File tree

5 files changed

+197
-51
lines changed

5 files changed

+197
-51
lines changed

tests/ui/privacy/private-in-public-warn.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ mod types {
3535

3636
mod traits {
3737
trait PrivTr {}
38+
impl PrivTr for () {}
3839
pub struct Pub<T>(T);
3940
pub trait PubTr {}
4041

@@ -45,7 +46,13 @@ mod traits {
4546
pub trait Tr3 {
4647
type Alias: PrivTr;
4748
//~^ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::Alias`
48-
fn f<T: PrivTr>(arg: T) {} //~ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::f`
49+
fn f<T: PrivTr>(arg: T) {}
50+
//~^ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::f`
51+
fn g() -> impl PrivTr;
52+
//~^ ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::g::{anon_assoc#0}`
53+
fn h() -> impl PrivTr {}
54+
//~^ ERROR private trait `traits::PrivTr` in public interface
55+
//~| ERROR trait `traits::PrivTr` is more private than the item `traits::Tr3::h::{anon_assoc#0}`
4956
}
5057
impl<T: PrivTr> Pub<T> {} //~ ERROR trait `traits::PrivTr` is more private than the item `traits::Pub<T>`
5158
impl<T: PrivTr> PubTr for Pub<T> {} // OK, trait impl predicates
@@ -75,12 +82,24 @@ mod generics {
7582
pub struct Pub<T = u8>(T);
7683
trait PrivTr<T> {}
7784
pub trait PubTr<T> {}
85+
impl PrivTr<Priv<()>> for () {}
7886

7987
pub trait Tr1: PrivTr<Pub> {}
8088
//~^ ERROR trait `generics::PrivTr<generics::Pub>` is more private than the item `generics::Tr1`
8189
pub trait Tr2: PubTr<Priv> {} //~ ERROR type `generics::Priv` is more private than the item `generics::Tr2`
8290
pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR type `generics::Priv` is more private than the item `generics::Tr3`
8391
pub trait Tr4: PubTr<Pub<Priv>> {} //~ ERROR type `generics::Priv` is more private than the item `Tr4`
92+
pub trait Tr5 {
93+
fn required() -> impl PrivTr<Priv<()>>;
94+
//~^ ERROR trait `generics::PrivTr<generics::Priv<()>>` is more private than the item `Tr5::required::{anon_assoc#0}`
95+
//~| ERROR type `generics::Priv<()>` is more private than the item `Tr5::required::{anon_assoc#0}`
96+
fn provided() -> impl PrivTr<Priv<()>> {}
97+
//~^ ERROR private trait `generics::PrivTr<generics::Priv<()>>` in public interface
98+
//~| ERROR private type `generics::Priv<()>` in public interface
99+
//~| ERROR trait `generics::PrivTr<generics::Priv<()>>` is more private than the item `Tr5::provided::{anon_assoc#0}`
100+
//~| ERROR type `generics::Priv<()>` is more private than the item `Tr5::provided::{anon_assoc#0}`
101+
}
102+
84103
}
85104

86105
mod impls {

0 commit comments

Comments
 (0)