2017-11-18 11:32:24 -06:00
|
|
|
// Private types and traits are not allowed in interfaces of associated types.
|
|
|
|
// This test also ensures that the checks are performed even inside private modules.
|
|
|
|
|
2019-07-29 18:11:58 -05:00
|
|
|
#![feature(associated_type_defaults)]
|
2023-04-12 08:32:15 -05:00
|
|
|
#![feature(impl_trait_in_assoc_type)]
|
2017-11-18 11:32:24 -06:00
|
|
|
|
|
|
|
mod m {
|
|
|
|
struct Priv;
|
|
|
|
trait PrivTr {}
|
|
|
|
impl PrivTr for Priv {}
|
|
|
|
pub trait PubTrAux1<T> {}
|
2020-05-10 05:57:58 -05:00
|
|
|
pub trait PubTrAux2 {
|
|
|
|
type A;
|
|
|
|
}
|
2019-06-13 14:36:15 -05:00
|
|
|
impl<T> PubTrAux1<T> for u8 {}
|
|
|
|
impl PubTrAux2 for u8 {
|
|
|
|
type A = Priv;
|
2020-09-02 02:40:56 -05:00
|
|
|
//~^ ERROR private type `Priv` in public interface
|
2019-06-13 14:36:15 -05:00
|
|
|
}
|
2017-11-18 11:32:24 -06:00
|
|
|
|
|
|
|
// "Private-in-public in associated types is hard error" in RFC 2145
|
|
|
|
// applies only to the aliased types, not bounds.
|
|
|
|
pub trait PubTr {
|
2020-09-07 04:01:45 -05:00
|
|
|
type Alias1: PrivTr;
|
2023-06-19 09:06:00 -05:00
|
|
|
//~^ WARN trait `PrivTr` is more private than the item `PubTr::Alias1`
|
2017-11-18 11:32:24 -06:00
|
|
|
type Alias2: PubTrAux1<Priv> = u8;
|
2023-06-19 09:06:00 -05:00
|
|
|
//~^ WARN type `Priv` is more private than the item `PubTr::Alias2`
|
2017-11-18 11:32:24 -06:00
|
|
|
type Alias3: PubTrAux2<A = Priv> = u8;
|
2023-06-19 09:06:00 -05:00
|
|
|
//~^ WARN type `Priv` is more private than the item `PubTr::Alias3`
|
2017-11-18 11:32:24 -06:00
|
|
|
|
|
|
|
type Alias4 = Priv;
|
2020-09-02 02:40:56 -05:00
|
|
|
//~^ ERROR private type `Priv` in public interface
|
2019-01-15 16:47:49 -06:00
|
|
|
|
|
|
|
type Exist;
|
|
|
|
fn infer_exist() -> Self::Exist;
|
2017-11-18 11:32:24 -06:00
|
|
|
}
|
|
|
|
impl PubTr for u8 {
|
|
|
|
type Alias1 = Priv;
|
2020-09-02 02:40:56 -05:00
|
|
|
//~^ ERROR private type `Priv` in public interface
|
2019-01-15 16:47:49 -06:00
|
|
|
|
2019-07-29 18:11:58 -05:00
|
|
|
type Exist = impl PrivTr;
|
2020-09-02 02:40:56 -05:00
|
|
|
//~^ ERROR private trait `PrivTr` in public interface
|
2020-05-10 05:57:58 -05:00
|
|
|
fn infer_exist() -> Self::Exist {
|
|
|
|
Priv
|
|
|
|
}
|
2017-11-18 11:32:24 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|