]> git.proxmox.com Git - rustc.git/blame - src/test/ui/privacy/private-in-public-assoc-ty.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / privacy / private-in-public-assoc-ty.rs
CommitLineData
ff7c6d11
XL
1// Private types and traits are not allowed in interfaces of associated types.
2// This test also ensures that the checks are performed even inside private modules.
3
416331ca 4#![feature(associated_type_defaults)]
6a06907d
XL
5// revisions: min_tait full_tait
6#![feature(min_type_alias_impl_trait)]
7#![cfg_attr(full_tait, feature(type_alias_impl_trait))]
8//[full_tait]~^ WARN incomplete
ff7c6d11
XL
9
10mod m {
11 struct Priv;
12 trait PrivTr {}
13 impl PrivTr for Priv {}
14 pub trait PubTrAux1<T> {}
f035d41b
XL
15 pub trait PubTrAux2 {
16 type A;
17 }
74b04a01
XL
18 impl<T> PubTrAux1<T> for u8 {}
19 impl PubTrAux2 for u8 {
20 type A = Priv;
1b1a35ee 21 //~^ ERROR private type `Priv` in public interface
74b04a01 22 }
ff7c6d11
XL
23
24 // "Private-in-public in associated types is hard error" in RFC 2145
25 // applies only to the aliased types, not bounds.
26 pub trait PubTr {
29967ef6 27 type Alias1: PrivTr;
1b1a35ee 28 //~^ WARN private trait `PrivTr` in public interface
ff7c6d11 29 //~| WARN this was previously accepted
ff7c6d11 30 type Alias2: PubTrAux1<Priv> = u8;
29967ef6
XL
31 //~^ WARN private type `Priv` in public interface
32 //~| WARN this was previously accepted
ff7c6d11 33 type Alias3: PubTrAux2<A = Priv> = u8;
29967ef6
XL
34 //~^ WARN private type `Priv` in public interface
35 //~| WARN this was previously accepted
ff7c6d11
XL
36
37 type Alias4 = Priv;
1b1a35ee 38 //~^ ERROR private type `Priv` in public interface
9fa01778
XL
39
40 type Exist;
41 fn infer_exist() -> Self::Exist;
ff7c6d11
XL
42 }
43 impl PubTr for u8 {
44 type Alias1 = Priv;
1b1a35ee 45 //~^ ERROR private type `Priv` in public interface
9fa01778 46
416331ca 47 type Exist = impl PrivTr;
1b1a35ee 48 //~^ ERROR private trait `PrivTr` in public interface
f035d41b
XL
49 fn infer_exist() -> Self::Exist {
50 Priv
51 }
ff7c6d11
XL
52 }
53}
54
55fn main() {}