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 
foo()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             override3: 4,
24         };
25 
26         let _ = x.inherit;
27         let _ = x.override1; //~ ERROR use of unstable
28         let _ = x.override2; //~ ERROR use of unstable
29         let _ = x.override3;
30 
31         let Stable {
32             inherit: _,
33             override1: _, //~ ERROR use of unstable
34             override2: _, //~ ERROR use of unstable
35             override3: _
36         } = x;
37         // all fine
38         let Stable { .. } = x;
39 
40         let x = Stable2(1, 2, 3, 4);
41 
42         let _ = x.0;
43         let _ = x.1; //~ ERROR use of unstable
44         let _ = x.2; //~ ERROR use of unstable
45         let _ = x.3;
46 
47         let Stable2(_,
48                    _, //~ ERROR use of unstable
49                    _, //~ ERROR use of unstable
50                    _)
51             = x;
52         // all fine
53         let Stable2(..) = x;
54 
55 
56         let x = Unstable { //~ ERROR use of unstable
57             inherit: 1, //~ ERROR use of unstable
58             override1: 2,
59             override2: 3, //~ ERROR use of unstable
60         };
61 
62         let _ = x.inherit; //~ ERROR use of unstable
63         let _ = x.override1;
64         let _ = x.override2; //~ ERROR use of unstable
65 
66         let Unstable { //~ ERROR use of unstable
67             inherit: _, //~ ERROR use of unstable
68             override1: _,
69             override2: _ //~ ERROR use of unstable
70         } = x;
71 
72         let Unstable  //~ ERROR use of unstable
73             // the patterns are all fine:
74             { .. } = x;
75 
76         // Unstable items are still unstable even when used through a stable "pub use".
77         let x = reexport::Unstable2(1, 2, 3); //~ ERROR use of unstable
78 
79         let x = Unstable2(1, 2, 3); //~ ERROR use of unstable
80 
81         let _ = x.0; //~ ERROR use of unstable
82         let _ = x.1;
83         let _ = x.2; //~ ERROR use of unstable
84 
85         let Unstable2  //~ ERROR use of unstable
86             (_, //~ ERROR use of unstable
87              _,
88              _) //~ ERROR use of unstable
89             = x;
90         let Unstable2 //~ ERROR use of unstable
91             // the patterns are all fine:
92             (..) = x;
93 
94 
95         let x = Deprecated { //~ ERROR use of unstable
96             inherit: 1, //~ ERROR use of unstable
97             override1: 2,
98             override2: 3, //~ ERROR use of unstable
99         };
100 
101         let _ = x.inherit; //~ ERROR use of unstable
102         let _ = x.override1;
103         let _ = x.override2; //~ ERROR use of unstable
104 
105         let Deprecated { //~ ERROR use of unstable
106             inherit: _, //~ ERROR use of unstable
107             override1: _,
108             override2: _ //~ ERROR use of unstable
109         } = x;
110 
111         let Deprecated //~ ERROR use of unstable
112             // the patterns are all fine:
113             { .. } = x;
114 
115         let x = Deprecated2(1, 2, 3); //~ ERROR use of unstable
116 
117         let _ = x.0; //~ ERROR use of unstable
118         let _ = x.1;
119         let _ = x.2; //~ ERROR use of unstable
120 
121         let Deprecated2 //~ ERROR use of unstable
122             (_, //~ ERROR use of unstable
123              _,
124              _) //~ ERROR use of unstable
125             = x;
126         let Deprecated2 //~ ERROR use of unstable
127             // the patterns are all fine:
128             (..) = x;
129     }
130 }
131 
132 mod this_crate {
133     #[stable(feature = "rust1", since = "1.0.0")]
134     struct Stable {
135         inherit: u8,
136         #[unstable(feature = "unstable_test_feature", issue = "none")]
137         override1: u8,
138         #[rustc_deprecated(since = "1.0.0", reason = "text")]
139         #[unstable(feature = "unstable_test_feature", issue = "none")]
140         override2: u8,
141         #[stable(feature = "rust2", since = "2.0.0")]
142         override3: u8,
143     }
144 
145     #[stable(feature = "rust1", since = "1.0.0")]
146     struct Stable2(u8,
147                    #[stable(feature = "rust2", since = "2.0.0")] u8,
148                    #[unstable(feature = "unstable_test_feature", issue = "none")]
149                    #[rustc_deprecated(since = "1.0.0", reason = "text")] u8);
150 
151     #[unstable(feature = "unstable_test_feature", issue = "none")]
152     struct Unstable {
153         inherit: u8,
154         #[stable(feature = "rust1", since = "1.0.0")]
155         override1: u8,
156         #[rustc_deprecated(since = "1.0.0", reason = "text")]
157         #[unstable(feature = "unstable_test_feature", issue = "none")]
158         override2: u8,
159     }
160 
161     #[unstable(feature = "unstable_test_feature", issue = "none")]
162     struct Unstable2(u8,
163                      #[stable(feature = "rust1", since = "1.0.0")] u8,
164                      #[unstable(feature = "unstable_test_feature", issue = "none")]
165                      #[rustc_deprecated(since = "1.0.0", reason = "text")] u8);
166 
167     #[unstable(feature = "unstable_test_feature", issue = "none")]
168     #[rustc_deprecated(since = "1.0.0", reason = "text")]
169     struct Deprecated {
170         inherit: u8,
171         #[stable(feature = "rust1", since = "1.0.0")]
172         override1: u8,
173         #[unstable(feature = "unstable_test_feature", issue = "none")]
174         override2: u8,
175     }
176 
177     #[unstable(feature = "unstable_test_feature", issue = "none")]
178     #[rustc_deprecated(since = "1.0.0", reason = "text")]
179     struct Deprecated2(u8,
180                        #[stable(feature = "rust1", since = "1.0.0")] u8,
181                        #[unstable(feature = "unstable_test_feature", issue = "none")] u8);
182 
foo()183     pub fn foo() {
184         let x = Stable {
185             inherit: 1,
186             override1: 2,
187             override2: 3,
188             override3: 4,
189         };
190 
191         let _ = x.inherit;
192         let _ = x.override1;
193         let _ = x.override2;
194         let _ = x.override3;
195 
196         let Stable {
197             inherit: _,
198             override1: _,
199             override2: _,
200             override3: _
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 
main()293 fn main() {}
294