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