]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-3763.rs
Merge commit '97e504549371d7640cf011d266e3c17394fdddac' into sync_cg_clif-2021-12-20
[rust.git] / src / test / ui / issues / issue-3763.rs
1 // compile-flags: -Zsave-analysis
2 // Also regression test for #69416
3
4 mod my_mod {
5     pub struct MyStruct {
6         priv_field: isize
7     }
8     pub fn MyStruct () -> MyStruct {
9         MyStruct {priv_field: 4}
10     }
11     impl MyStruct {
12         fn happyfun(&self) {}
13     }
14 }
15
16 fn main() {
17     let my_struct = my_mod::MyStruct();
18     let _woohoo = (&my_struct).priv_field;
19     //~^ ERROR field `priv_field` of struct `MyStruct` is private
20
21     let _woohoo = (Box::new(my_struct)).priv_field;
22     //~^ ERROR field `priv_field` of struct `MyStruct` is private
23
24     (&my_struct).happyfun();               //~ ERROR associated function `happyfun` is private
25
26     (Box::new(my_struct)).happyfun();          //~ ERROR associated function `happyfun` is private
27     let nope = my_struct.priv_field;
28     //~^ ERROR field `priv_field` of struct `MyStruct` is private
29 }