]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/privacy5.rs
Update compile fail tests to use isize.
[rust.git] / src / test / compile-fail / privacy5.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:privacy-tuple-struct.rs
12 // ignore-fast
13
14 extern crate "privacy-tuple-struct" as other;
15
16 mod a {
17     pub struct A(());
18     pub struct B(isize);
19     pub struct C(pub isize, isize);
20     pub struct D(pub isize);
21
22     fn test() {
23         let a = A(());
24         let b = B(2);
25         let c = C(2, 3);
26         let d = D(4);
27
28         let A(()) = a;
29         let A(_) = a;
30         match a { A(()) => {} }
31         match a { A(_) => {} }
32
33         let B(_) = b;
34         let B(_b) = b;
35         match b { B(_) => {} }
36         match b { B(_b) => {} }
37         match b { B(1) => {} B(_) => {} }
38
39         let C(_, _) = c;
40         let C(_a, _) = c;
41         let C(_, _b) = c;
42         let C(_a, _b) = c;
43         match c { C(_, _) => {} }
44         match c { C(_a, _) => {} }
45         match c { C(_, _b) => {} }
46         match c { C(_a, _b) => {} }
47
48         let D(_) = d;
49         let D(_d) = d;
50         match d { D(_) => {} }
51         match d { D(_d) => {} }
52         match d { D(1) => {} D(_) => {} }
53
54         let a2 = A;
55         let b2 = B;
56         let c2 = C;
57         let d2 = D;
58     }
59 }
60
61 fn this_crate() {
62     let a = a::A(()); //~ ERROR: cannot invoke tuple struct constructor
63     let b = a::B(2); //~ ERROR: cannot invoke tuple struct constructor
64     let c = a::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
65     let d = a::D(4);
66
67     let a::A(()) = a; //~ ERROR: field #1 of struct `a::A` is private
68     let a::A(_) = a;
69     match a { a::A(()) => {} } //~ ERROR: field #1 of struct `a::A` is private
70     match a { a::A(_) => {} }
71
72     let a::B(_) = b;
73     let a::B(_b) = b; //~ ERROR: field #1 of struct `a::B` is private
74     match b { a::B(_) => {} }
75     match b { a::B(_b) => {} } //~ ERROR: field #1 of struct `a::B` is private
76     match b { a::B(1) => {} a::B(_) => {} } //~ ERROR: field #1 of struct `a::B` is private
77
78     let a::C(_, _) = c;
79     let a::C(_a, _) = c;
80     let a::C(_, _b) = c; //~ ERROR: field #2 of struct `a::C` is private
81     let a::C(_a, _b) = c; //~ ERROR: field #2 of struct `a::C` is private
82     match c { a::C(_, _) => {} }
83     match c { a::C(_a, _) => {} }
84     match c { a::C(_, _b) => {} } //~ ERROR: field #2 of struct `a::C` is private
85     match c { a::C(_a, _b) => {} } //~ ERROR: field #2 of struct `a::C` is private
86
87     let a::D(_) = d;
88     let a::D(_d) = d;
89     match d { a::D(_) => {} }
90     match d { a::D(_d) => {} }
91     match d { a::D(1) => {} a::D(_) => {} }
92
93     let a2 = a::A; //~ ERROR: cannot invoke tuple struct constructor
94     let b2 = a::B; //~ ERROR: cannot invoke tuple struct constructor
95     let c2 = a::C; //~ ERROR: cannot invoke tuple struct constructor
96     let d2 = a::D;
97 }
98
99 fn xcrate() {
100     let a = other::A(()); //~ ERROR: cannot invoke tuple struct constructor
101     let b = other::B(2); //~ ERROR: cannot invoke tuple struct constructor
102     let c = other::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
103     let d = other::D(4);
104
105     let other::A(()) = a; //~ ERROR: field #1 of struct `privacy-tuple-struct::A` is private
106     let other::A(_) = a;
107     match a { other::A(()) => {} }
108     //~^ ERROR: field #1 of struct `privacy-tuple-struct::A` is private
109     match a { other::A(_) => {} }
110
111     let other::B(_) = b;
112     let other::B(_b) = b; //~ ERROR: field #1 of struct `privacy-tuple-struct::B` is private
113     match b { other::B(_) => {} }
114     match b { other::B(_b) => {} }
115     //~^ ERROR: field #1 of struct `privacy-tuple-struct::B` is private
116     match b { other::B(1) => {} other::B(_) => {} }
117     //~^ ERROR: field #1 of struct `privacy-tuple-struct::B` is private
118
119     let other::C(_, _) = c;
120     let other::C(_a, _) = c;
121     let other::C(_, _b) = c; //~ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
122     let other::C(_a, _b) = c; //~ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
123     match c { other::C(_, _) => {} }
124     match c { other::C(_a, _) => {} }
125     match c { other::C(_, _b) => {} }
126     //~^ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
127     match c { other::C(_a, _b) => {} }
128     //~^ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
129
130     let other::D(_) = d;
131     let other::D(_d) = d;
132     match d { other::D(_) => {} }
133     match d { other::D(_d) => {} }
134     match d { other::D(1) => {} other::D(_) => {} }
135
136     let a2 = other::A; //~ ERROR: cannot invoke tuple struct constructor
137     let b2 = other::B; //~ ERROR: cannot invoke tuple struct constructor
138     let c2 = other::C; //~ ERROR: cannot invoke tuple struct constructor
139     let d2 = other::D;
140 }
141
142 fn main() {}