]>
Commit | Line | Data |
---|---|---|
74b04a01 XL |
1 | // compile-flags: -Zsave-analysis |
2 | // Also regression test for #69416 | |
3 | ||
223e47cc LB |
4 | mod my_mod { |
5 | pub struct MyStruct { | |
1a4d82fc | 6 | priv_field: isize |
223e47cc LB |
7 | } |
8 | pub fn MyStruct () -> MyStruct { | |
9 | MyStruct {priv_field: 4} | |
10 | } | |
970d7e83 | 11 | impl MyStruct { |
1a4d82fc | 12 | fn happyfun(&self) {} |
223e47cc LB |
13 | } |
14 | } | |
15 | ||
16 | fn main() { | |
17 | let my_struct = my_mod::MyStruct(); | |
1a4d82fc | 18 | let _woohoo = (&my_struct).priv_field; |
1b1a35ee | 19 | //~^ ERROR field `priv_field` of struct `MyStruct` is private |
c34b1796 | 20 | |
c34b1796 | 21 | let _woohoo = (Box::new(my_struct)).priv_field; |
1b1a35ee | 22 | //~^ ERROR field `priv_field` of struct `MyStruct` is private |
c34b1796 | 23 | |
ba9703b0 | 24 | (&my_struct).happyfun(); //~ ERROR associated function `happyfun` is private |
c34b1796 | 25 | |
ba9703b0 | 26 | (Box::new(my_struct)).happyfun(); //~ ERROR associated function `happyfun` is private |
1a4d82fc | 27 | let nope = my_struct.priv_field; |
1b1a35ee | 28 | //~^ ERROR field `priv_field` of struct `MyStruct` is private |
223e47cc | 29 | } |