]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/struct-field-privacy.rs
auto merge of #12301 : FlaPer87/rust/issue-8893, r=alexcrichton
[rust.git] / src / test / compile-fail / struct-field-privacy.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // aux-build:struct-field-privacy.rs
12
13 extern crate xc = "struct-field-privacy";
14
15 struct A {
16     a: int,
17 }
18
19 mod inner {
20     struct A {
21         a: int,
22         pub b: int,
23         priv c: int, //~ ERROR: unnecessary `priv` visibility
24     }
25     pub struct B {
26         a: int,
27         priv b: int,
28         pub c: int, //~ ERROR: unnecessary `pub` visibility
29     }
30 }
31
32 fn test(a: A, b: inner::A, c: inner::B, d: xc::A, e: xc::B) {
33     //~^ ERROR: type `A` is private
34     //~^^ ERROR: struct `A` is private
35
36     a.a;
37     b.a; //~ ERROR: field `a` is private
38     b.b;
39     b.c; //~ ERROR: field `c` is private
40     c.a;
41     c.b; //~ ERROR: field `b` is private
42     c.c;
43
44     d.a; //~ ERROR: field `a` is private
45     d.b;
46
47     e.a;
48     e.b; //~ ERROR: field `b` is private
49 }
50
51 fn main() {}