2017-11-18 17:32:24 +00: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 23:11:58 +00:00
|
|
|
#![feature(associated_type_defaults)]
|
2021-07-26 20:01:16 +00:00
|
|
|
#![feature(type_alias_impl_trait)]
|
2017-11-18 17:32:24 +00:00
|
|
|
|
|
|
|
mod m {
|
|
|
|
struct Priv;
|
|
|
|
trait PrivTr {}
|
|
|
|
impl PrivTr for Priv {}
|
|
|
|
pub trait PubTrAux1<T> {}
|
2020-05-10 10:57:58 +00:00
|
|
|
pub trait PubTrAux2 {
|
|
|
|
type A;
|
|
|
|
}
|
2019-06-13 19:36:15 +00:00
|
|
|
impl<T> PubTrAux1<T> for u8 {}
|
|
|
|
impl PubTrAux2 for u8 {
|
|
|
|
type A = Priv;
|
2020-09-02 07:40:56 +00:00
|
|
|
//~^ ERROR private type `Priv` in public interface
|
2019-06-13 19:36:15 +00:00
|
|
|
}
|
2017-11-18 17:32:24 +00: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 09:01:45 +00:00
|
|
|
type Alias1: PrivTr;
|
2020-09-02 07:40:56 +00:00
|
|
|
//~^ WARN private trait `PrivTr` in public interface
|
2017-11-18 17:32:24 +00:00
|
|
|
//~| WARN this was previously accepted
|
|
|
|
type Alias2: PubTrAux1<Priv> = u8;
|
2020-09-07 09:01:45 +00:00
|
|
|
//~^ WARN private type `Priv` in public interface
|
2020-06-27 20:36:35 +00:00
|
|
|
//~| WARN this was previously accepted
|
2017-11-18 17:32:24 +00:00
|
|
|
type Alias3: PubTrAux2<A = Priv> = u8;
|
2020-09-07 09:01:45 +00:00
|
|
|
//~^ WARN private type `Priv` in public interface
|
2020-06-27 20:36:35 +00:00
|
|
|
//~| WARN this was previously accepted
|
2017-11-18 17:32:24 +00:00
|
|
|
|
|
|
|
type Alias4 = Priv;
|
2020-09-02 07:40:56 +00:00
|
|
|
//~^ ERROR private type `Priv` in public interface
|
2019-01-15 22:47:49 +00:00
|
|
|
|
|
|
|
type Exist;
|
|
|
|
fn infer_exist() -> Self::Exist;
|
2017-11-18 17:32:24 +00:00
|
|
|
}
|
|
|
|
impl PubTr for u8 {
|
|
|
|
type Alias1 = Priv;
|
2020-09-02 07:40:56 +00:00
|
|
|
//~^ ERROR private type `Priv` in public interface
|
2019-01-15 22:47:49 +00:00
|
|
|
|
2019-07-29 23:11:58 +00:00
|
|
|
type Exist = impl PrivTr;
|
2020-09-02 07:40:56 +00:00
|
|
|
//~^ ERROR private trait `PrivTr` in public interface
|
2020-05-10 10:57:58 +00:00
|
|
|
fn infer_exist() -> Self::Exist {
|
|
|
|
Priv
|
|
|
|
}
|
2017-11-18 17:32:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|