]> git.lizzy.rs Git - rust.git/blob - tests/ui/structs/struct-field-privacy.rs
Rollup merge of #106585 - estebank:issue-46585, r=compiler-errors
[rust.git] / tests / ui / structs / struct-field-privacy.rs
1 // aux-build:struct_field_privacy.rs
2
3 extern crate struct_field_privacy as xc;
4
5 struct A {
6     a: isize,
7 }
8
9 mod inner {
10     pub struct A {
11         a: isize,
12         pub b: isize,
13     }
14     pub struct B {
15         pub a: isize,
16         b: isize,
17     }
18     pub struct Z(pub isize, isize);
19 }
20
21 fn test(a: A, b: inner::A, c: inner::B, d: xc::A, e: xc::B, z: inner::Z) {
22     a.a;
23     b.a; //~ ERROR: field `a` of struct `inner::A` is private
24     b.b;
25     c.a;
26     c.b; //~ ERROR: field `b` of struct `inner::B` is private
27
28     d.a; //~ ERROR: field `a` of struct `xc::A` is private
29     d.b;
30
31     e.a;
32     e.b; //~ ERROR: field `b` of struct `xc::B` is private
33
34     z.0;
35     z.1; //~ ERROR: field `1` of struct `Z` is private
36 }
37
38 fn main() {}