]> git.lizzy.rs Git - rust.git/blob - tests/ui/privacy/associated-item-privacy-inherent.rs
Rollup merge of #107015 - cuviper:ra-riscv64, r=Mark-Simulacrum
[rust.git] / tests / ui / privacy / associated-item-privacy-inherent.rs
1 #![feature(decl_macro, associated_type_defaults)]
2 #![allow(unused, private_in_public)]
3
4 mod priv_nominal {
5     pub struct Pub;
6     impl Pub {
7         fn method(&self) {}
8         const CONST: u8 = 0;
9         // type AssocTy = u8;
10     }
11
12     pub macro mac() {
13         let value = Pub::method;
14         //~^ ERROR type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private
15         value;
16         //~^ ERROR type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private
17         Pub.method();
18         //~^ ERROR type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private
19         Pub::CONST;
20         //~^ ERROR associated constant `CONST` is private
21         // let _: Pub::AssocTy;
22         // pub type InSignatureTy = Pub::AssocTy;
23     }
24 }
25 fn priv_nominal() {
26     priv_nominal::mac!();
27 }
28
29 mod priv_signature {
30     struct Priv;
31     pub struct Pub;
32     impl Pub {
33         pub fn method(&self, arg: Priv) {}
34     }
35
36     pub macro mac() {
37         let value = Pub::method;
38         //~^ ERROR type `priv_signature::Priv` is private
39         value;
40         //~^ ERROR type `priv_signature::Priv` is private
41         Pub.method(loop {});
42         //~^ ERROR type `priv_signature::Priv` is private
43     }
44 }
45 fn priv_signature() {
46     priv_signature::mac!();
47 }
48
49 mod priv_substs {
50     struct Priv;
51     pub struct Pub;
52     impl Pub {
53         pub fn method<T>(&self) {}
54     }
55
56     pub macro mac() {
57         let value = Pub::method::<Priv>;
58         //~^ ERROR type `priv_substs::Priv` is private
59         value;
60         //~^ ERROR type `priv_substs::Priv` is private
61         Pub.method::<Priv>();
62         //~^ ERROR type `priv_substs::Priv` is private
63     }
64 }
65 fn priv_substs() {
66     priv_substs::mac!();
67 }
68
69 mod priv_parent_substs {
70     struct Priv;
71     pub struct Pub<T = Priv>(T);
72     impl Pub<Priv> {
73         pub fn method(&self) {}
74         pub fn static_method() {}
75         pub const CONST: u8 = 0;
76         // pub type AssocTy = u8;
77     }
78
79     pub macro mac() {
80         let value = <Pub>::method;
81         //~^ ERROR type `priv_parent_substs::Priv` is private
82         value;
83         //~^ ERROR type `priv_parent_substs::Priv` is private
84         let value = Pub::method;
85         //~^ ERROR type `priv_parent_substs::Priv` is private
86         value;
87         //~^ ERROR type `priv_parent_substs::Priv` is private
88         let value = <Pub>::static_method;
89         //~^ ERROR type `priv_parent_substs::Priv` is private
90         value;
91         //~^ ERROR type `priv_parent_substs::Priv` is private
92         let value = Pub::static_method;
93         //~^ ERROR type `priv_parent_substs::Priv` is private
94         value;
95         //~^ ERROR type `priv_parent_substs::Priv` is private
96         Pub(Priv).method();
97         //~^ ERROR type `priv_parent_substs::Priv` is private
98
99         <Pub>::CONST;
100         //~^ ERROR type `priv_parent_substs::Priv` is private
101         Pub::CONST;
102         //~^ ERROR type `priv_parent_substs::Priv` is private
103
104         // let _: Pub::AssocTy;
105         // pub type InSignatureTy = Pub::AssocTy;
106     }
107 }
108 fn priv_parent_substs() {
109     priv_parent_substs::mac!();
110 }
111
112 fn main() {}