]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/lint-stability-fields.rs
Move parse-fail tests to UI
[rust.git] / src / test / ui / lint / lint-stability-fields.rs
1 // Copyright 2015 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:lint_stability_fields.rs
12 #![allow(deprecated)]
13 #![allow(dead_code)]
14 #![feature(staged_api)]
15
16 #![stable(feature = "rust1", since = "1.0.0")]
17
18 mod cross_crate {
19     extern crate lint_stability_fields;
20
21     mod reexport {
22         #[stable(feature = "rust1", since = "1.0.0")]
23         pub use super::lint_stability_fields::*;
24     }
25
26     use self::lint_stability_fields::*;
27
28     pub fn foo() {
29         let x = Stable {
30             inherit: 1,
31             override1: 2, //~ ERROR use of unstable
32             override2: 3, //~ ERROR use of unstable
33         };
34
35         let _ = x.inherit;
36         let _ = x.override1; //~ ERROR use of unstable
37         let _ = x.override2; //~ ERROR use of unstable
38
39         let Stable {
40             inherit: _,
41             override1: _, //~ ERROR use of unstable
42             override2: _ //~ ERROR use of unstable
43         } = x;
44         // all fine
45         let Stable { .. } = x;
46
47         let x = Stable2(1, 2, 3);
48
49         let _ = x.0;
50         let _ = x.1; //~ ERROR use of unstable
51         let _ = x.2; //~ ERROR use of unstable
52
53         let Stable2(_,
54                    _, //~ ERROR use of unstable
55                    _) //~ ERROR use of unstable
56             = x;
57         // all fine
58         let Stable2(..) = x;
59
60
61         let x = Unstable { //~ ERROR use of unstable
62             inherit: 1, //~ ERROR use of unstable
63             override1: 2,
64             override2: 3, //~ ERROR use of unstable
65         };
66
67         let _ = x.inherit; //~ ERROR use of unstable
68         let _ = x.override1;
69         let _ = x.override2; //~ ERROR use of unstable
70
71         let Unstable { //~ ERROR use of unstable
72             inherit: _, //~ ERROR use of unstable
73             override1: _,
74             override2: _ //~ ERROR use of unstable
75         } = x;
76
77         let Unstable  //~ ERROR use of unstable
78             // the patterns are all fine:
79             { .. } = x;
80
81         // Unstable items are still unstable even when used through a stable "pub use".
82         let x = reexport::Unstable2(1, 2, 3); //~ ERROR use of unstable
83
84         let x = Unstable2(1, 2, 3); //~ ERROR use of unstable
85
86         let _ = x.0; //~ ERROR use of unstable
87         let _ = x.1;
88         let _ = x.2; //~ ERROR use of unstable
89
90         let Unstable2  //~ ERROR use of unstable
91             (_, //~ ERROR use of unstable
92              _,
93              _) //~ ERROR use of unstable
94             = x;
95         let Unstable2 //~ ERROR use of unstable
96             // the patterns are all fine:
97             (..) = x;
98
99
100         let x = Deprecated { //~ ERROR use of unstable
101             inherit: 1, //~ ERROR use of unstable
102             override1: 2,
103             override2: 3, //~ ERROR use of unstable
104         };
105
106         let _ = x.inherit; //~ ERROR use of unstable
107         let _ = x.override1;
108         let _ = x.override2; //~ ERROR use of unstable
109
110         let Deprecated { //~ ERROR use of unstable
111             inherit: _, //~ ERROR use of unstable
112             override1: _,
113             override2: _ //~ ERROR use of unstable
114         } = x;
115
116         let Deprecated //~ ERROR use of unstable
117             // the patterns are all fine:
118             { .. } = x;
119
120         let x = Deprecated2(1, 2, 3); //~ ERROR use of unstable
121
122         let _ = x.0; //~ ERROR use of unstable
123         let _ = x.1;
124         let _ = x.2; //~ ERROR use of unstable
125
126         let Deprecated2 //~ ERROR use of unstable
127             (_, //~ ERROR use of unstable
128              _,
129              _) //~ ERROR use of unstable
130             = x;
131         let Deprecated2 //~ ERROR use of unstable
132             // the patterns are all fine:
133             (..) = x;
134     }
135 }
136
137 mod this_crate {
138     #[stable(feature = "rust1", since = "1.0.0")]
139     struct Stable {
140         inherit: u8,
141         #[unstable(feature = "unstable_test_feature", issue = "0")]
142         override1: u8,
143         #[rustc_deprecated(since = "1.0.0", reason = "text")]
144         #[unstable(feature = "unstable_test_feature", issue = "0")]
145         override2: u8,
146     }
147
148     #[stable(feature = "rust1", since = "1.0.0")]
149     struct Stable2(u8,
150                    #[stable(feature = "rust1", since = "1.0.0")] u8,
151                    #[unstable(feature = "unstable_test_feature", issue = "0")]
152                    #[rustc_deprecated(since = "1.0.0", reason = "text")] u8);
153
154     #[unstable(feature = "unstable_test_feature", issue = "0")]
155     struct Unstable {
156         inherit: u8,
157         #[stable(feature = "rust1", since = "1.0.0")]
158         override1: u8,
159         #[rustc_deprecated(since = "1.0.0", reason = "text")]
160         #[unstable(feature = "unstable_test_feature", issue = "0")]
161         override2: u8,
162     }
163
164     #[unstable(feature = "unstable_test_feature", issue = "0")]
165     struct Unstable2(u8,
166                      #[stable(feature = "rust1", since = "1.0.0")] u8,
167                      #[unstable(feature = "unstable_test_feature", issue = "0")]
168                      #[rustc_deprecated(since = "1.0.0", reason = "text")] u8);
169
170     #[unstable(feature = "unstable_test_feature", issue = "0")]
171     #[rustc_deprecated(since = "1.0.0", reason = "text")]
172     struct Deprecated {
173         inherit: u8,
174         #[stable(feature = "rust1", since = "1.0.0")]
175         override1: u8,
176         #[unstable(feature = "unstable_test_feature", issue = "0")]
177         override2: u8,
178     }
179
180     #[unstable(feature = "unstable_test_feature", issue = "0")]
181     #[rustc_deprecated(since = "1.0.0", reason = "text")]
182     struct Deprecated2(u8,
183                        #[stable(feature = "rust1", since = "1.0.0")] u8,
184                        #[unstable(feature = "unstable_test_feature", issue = "0")] u8);
185
186     pub fn foo() {
187         let x = Stable {
188             inherit: 1,
189             override1: 2,
190             override2: 3,
191         };
192
193         let _ = x.inherit;
194         let _ = x.override1;
195         let _ = x.override2;
196
197         let Stable {
198             inherit: _,
199             override1: _,
200             override2: _
201         } = x;
202         // all fine
203         let Stable { .. } = x;
204
205         let x = Stable2(1, 2, 3);
206
207         let _ = x.0;
208         let _ = x.1;
209         let _ = x.2;
210
211         let Stable2(_,
212                    _,
213                    _)
214             = x;
215         // all fine
216         let Stable2(..) = x;
217
218
219         let x = Unstable {
220             inherit: 1,
221             override1: 2,
222             override2: 3,
223         };
224
225         let _ = x.inherit;
226         let _ = x.override1;
227         let _ = x.override2;
228
229         let Unstable {
230             inherit: _,
231             override1: _,
232             override2: _
233         } = x;
234
235         let Unstable
236             // the patterns are all fine:
237             { .. } = x;
238
239
240         let x = Unstable2(1, 2, 3);
241
242         let _ = x.0;
243         let _ = x.1;
244         let _ = x.2;
245
246         let Unstable2
247             (_,
248              _,
249              _)
250             = x;
251         let Unstable2
252             // the patterns are all fine:
253             (..) = x;
254
255
256         let x = Deprecated {
257             inherit: 1,
258             override1: 2,
259             override2: 3,
260         };
261
262         let _ = x.inherit;
263         let _ = x.override1;
264         let _ = x.override2;
265
266         let Deprecated {
267             inherit: _,
268             override1: _,
269             override2: _
270         } = x;
271
272         let Deprecated
273             // the patterns are all fine:
274             { .. } = x;
275
276         let x = Deprecated2(1, 2, 3);
277
278         let _ = x.0;
279         let _ = x.1;
280         let _ = x.2;
281
282         let Deprecated2
283             (_,
284              _,
285              _)
286             = x;
287         let Deprecated2
288             // the patterns are all fine:
289             (..) = x;
290     }
291 }
292
293 fn main() {}