]>
Commit | Line | Data |
---|---|---|
476ff2be SL |
1 | // Copyright 2016 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 | ||
12 | // This test case tests the incremental compilation hash (ICH) implementation | |
13 | // for struct constructor expressions. | |
14 | ||
15 | // The general pattern followed here is: Change one thing between rev1 and rev2 | |
16 | // and make sure that the hash has changed, then change nothing between rev2 and | |
17 | // rev3 and make sure that the hash has not changed. | |
18 | ||
83c7162d | 19 | // compile-pass |
476ff2be | 20 | // revisions: cfail1 cfail2 cfail3 |
ff7c6d11 | 21 | // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans |
476ff2be SL |
22 | |
23 | #![allow(warnings)] | |
24 | #![feature(rustc_attrs)] | |
25 | #![crate_type="rlib"] | |
26 | ||
27 | ||
abe05a73 | 28 | pub enum Enum { |
476ff2be SL |
29 | Struct { |
30 | x: i32, | |
31 | y: i64, | |
32 | z: i16, | |
33 | }, | |
34 | Tuple(i32, i64, i16) | |
35 | } | |
36 | ||
37 | // Change field value (struct-like) ----------------------------------------- | |
38 | #[cfg(cfail1)] | |
abe05a73 | 39 | pub fn change_field_value_struct_like() -> Enum { |
476ff2be SL |
40 | Enum::Struct { |
41 | x: 0, | |
42 | y: 1, | |
43 | z: 2, | |
44 | } | |
45 | } | |
46 | ||
47 | #[cfg(not(cfail1))] | |
abe05a73 XL |
48 | #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")] |
49 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 50 | pub fn change_field_value_struct_like() -> Enum { |
476ff2be SL |
51 | Enum::Struct { |
52 | x: 0, | |
53 | y: 2, | |
54 | z: 2, | |
55 | } | |
56 | } | |
57 | ||
58 | ||
59 | ||
60 | // Change field order (struct-like) ----------------------------------------- | |
61 | #[cfg(cfail1)] | |
abe05a73 | 62 | pub fn change_field_order_struct_like() -> Enum { |
476ff2be SL |
63 | Enum::Struct { |
64 | x: 3, | |
65 | y: 4, | |
66 | z: 5, | |
67 | } | |
68 | } | |
69 | ||
70 | #[cfg(not(cfail1))] | |
abe05a73 XL |
71 | #[rustc_clean(cfg="cfail2", except="HirBody,TypeckTables")] |
72 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 XL |
73 | // FIXME(michaelwoerister):Interesting. I would have thought that that changes the MIR. And it |
74 | // would if it were not all constants | |
75 | pub fn change_field_order_struct_like() -> Enum { | |
476ff2be SL |
76 | Enum::Struct { |
77 | y: 4, | |
78 | x: 3, | |
79 | z: 5, | |
80 | } | |
81 | } | |
82 | ||
83 | ||
abe05a73 | 84 | pub enum Enum2 { |
476ff2be SL |
85 | Struct { |
86 | x: i8, | |
87 | y: i8, | |
88 | z: i8, | |
89 | }, | |
90 | Struct2 { | |
91 | x: i8, | |
92 | y: i8, | |
93 | z: i8, | |
94 | }, | |
95 | Tuple(u16, u16, u16), | |
96 | Tuple2(u64, u64, u64), | |
97 | } | |
98 | ||
99 | // Change constructor path (struct-like) ------------------------------------ | |
100 | #[cfg(cfail1)] | |
abe05a73 | 101 | pub fn change_constructor_path_struct_like() { |
476ff2be SL |
102 | let _ = Enum::Struct { |
103 | x: 0, | |
104 | y: 1, | |
105 | z: 2, | |
106 | }; | |
107 | } | |
108 | ||
109 | #[cfg(not(cfail1))] | |
abe05a73 XL |
110 | #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")] |
111 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 112 | pub fn change_constructor_path_struct_like() { |
476ff2be SL |
113 | let _ = Enum2::Struct { |
114 | x: 0, | |
115 | y: 1, | |
116 | z: 2, | |
117 | }; | |
118 | } | |
119 | ||
120 | ||
121 | ||
122 | // Change variant (regular struct) ------------------------------------ | |
123 | #[cfg(cfail1)] | |
abe05a73 | 124 | pub fn change_constructor_variant_struct_like() { |
476ff2be SL |
125 | let _ = Enum2::Struct { |
126 | x: 0, | |
127 | y: 1, | |
128 | z: 2, | |
129 | }; | |
130 | } | |
131 | ||
132 | #[cfg(not(cfail1))] | |
abe05a73 XL |
133 | #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")] |
134 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 135 | pub fn change_constructor_variant_struct_like() { |
476ff2be SL |
136 | let _ = Enum2::Struct2 { |
137 | x: 0, | |
138 | y: 1, | |
139 | z: 2, | |
140 | }; | |
141 | } | |
142 | ||
143 | ||
144 | // Change constructor path indirectly (struct-like) ------------------------- | |
abe05a73 | 145 | pub mod change_constructor_path_indirectly_struct_like { |
476ff2be SL |
146 | #[cfg(cfail1)] |
147 | use super::Enum as TheEnum; | |
148 | #[cfg(not(cfail1))] | |
149 | use super::Enum2 as TheEnum; | |
150 | ||
abe05a73 XL |
151 | #[rustc_clean( |
152 | cfg="cfail2", | |
153 | except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,\ | |
154 | TypeckTables" | |
155 | )] | |
156 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 157 | pub fn function() -> TheEnum { |
476ff2be SL |
158 | TheEnum::Struct { |
159 | x: 0, | |
160 | y: 1, | |
161 | z: 2, | |
162 | } | |
163 | } | |
164 | } | |
165 | ||
166 | ||
167 | // Change constructor variant indirectly (struct-like) --------------------------- | |
abe05a73 | 168 | pub mod change_constructor_variant_indirectly_struct_like { |
476ff2be SL |
169 | use super::Enum2; |
170 | #[cfg(cfail1)] | |
171 | use super::Enum2::Struct as Variant; | |
172 | #[cfg(not(cfail1))] | |
173 | use super::Enum2::Struct2 as Variant; | |
174 | ||
abe05a73 XL |
175 | #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")] |
176 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 177 | pub fn function() -> Enum2 { |
476ff2be SL |
178 | Variant { |
179 | x: 0, | |
180 | y: 1, | |
181 | z: 2, | |
182 | } | |
183 | } | |
184 | } | |
185 | ||
186 | ||
187 | // Change field value (tuple-like) ------------------------------------------- | |
188 | #[cfg(cfail1)] | |
abe05a73 | 189 | pub fn change_field_value_tuple_like() -> Enum { |
476ff2be SL |
190 | Enum::Tuple(0, 1, 2) |
191 | } | |
192 | ||
193 | #[cfg(not(cfail1))] | |
abe05a73 XL |
194 | #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")] |
195 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 196 | pub fn change_field_value_tuple_like() -> Enum { |
476ff2be SL |
197 | Enum::Tuple(0, 1, 3) |
198 | } | |
199 | ||
200 | ||
201 | ||
202 | // Change constructor path (tuple-like) -------------------------------------- | |
203 | #[cfg(cfail1)] | |
abe05a73 | 204 | pub fn change_constructor_path_tuple_like() { |
476ff2be SL |
205 | let _ = Enum::Tuple(0, 1, 2); |
206 | } | |
207 | ||
208 | #[cfg(not(cfail1))] | |
abe05a73 XL |
209 | #[rustc_clean( |
210 | cfg="cfail2", | |
211 | except="HirBody,MirOptimized,MirValidated,TypeckTables" | |
212 | )] | |
213 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 214 | pub fn change_constructor_path_tuple_like() { |
476ff2be SL |
215 | let _ = Enum2::Tuple(0, 1, 2); |
216 | } | |
217 | ||
218 | ||
219 | ||
220 | // Change constructor variant (tuple-like) -------------------------------------- | |
221 | #[cfg(cfail1)] | |
abe05a73 | 222 | pub fn change_constructor_variant_tuple_like() { |
476ff2be SL |
223 | let _ = Enum2::Tuple(0, 1, 2); |
224 | } | |
225 | ||
226 | #[cfg(not(cfail1))] | |
abe05a73 XL |
227 | #[rustc_clean( |
228 | cfg="cfail2", | |
229 | except="HirBody,MirOptimized,MirValidated,TypeckTables" | |
230 | )] | |
231 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 232 | pub fn change_constructor_variant_tuple_like() { |
476ff2be SL |
233 | let _ = Enum2::Tuple2(0, 1, 2); |
234 | } | |
235 | ||
236 | ||
237 | // Change constructor path indirectly (tuple-like) --------------------------- | |
abe05a73 | 238 | pub mod change_constructor_path_indirectly_tuple_like { |
476ff2be SL |
239 | #[cfg(cfail1)] |
240 | use super::Enum as TheEnum; | |
241 | #[cfg(not(cfail1))] | |
242 | use super::Enum2 as TheEnum; | |
243 | ||
abe05a73 XL |
244 | #[rustc_clean( |
245 | cfg="cfail2", | |
246 | except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,\ | |
247 | TypeckTables" | |
248 | )] | |
249 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 250 | pub fn function() -> TheEnum { |
476ff2be SL |
251 | TheEnum::Tuple(0, 1, 2) |
252 | } | |
253 | } | |
254 | ||
255 | ||
256 | ||
257 | // Change constructor variant indirectly (tuple-like) --------------------------- | |
abe05a73 | 258 | pub mod change_constructor_variant_indirectly_tuple_like { |
476ff2be SL |
259 | use super::Enum2; |
260 | #[cfg(cfail1)] | |
261 | use super::Enum2::Tuple as Variant; | |
262 | #[cfg(not(cfail1))] | |
263 | use super::Enum2::Tuple2 as Variant; | |
264 | ||
abe05a73 XL |
265 | #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")] |
266 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 267 | pub fn function() -> Enum2 { |
476ff2be SL |
268 | Variant(0, 1, 2) |
269 | } | |
270 | } | |
271 | ||
272 | ||
abe05a73 | 273 | pub enum Clike { |
476ff2be SL |
274 | A, |
275 | B, | |
276 | C | |
277 | } | |
278 | ||
abe05a73 | 279 | pub enum Clike2 { |
476ff2be SL |
280 | B, |
281 | C, | |
282 | D | |
283 | } | |
284 | ||
285 | // Change constructor path (C-like) -------------------------------------- | |
286 | #[cfg(cfail1)] | |
abe05a73 | 287 | pub fn change_constructor_path_c_like() { |
476ff2be SL |
288 | let _ = Clike::B; |
289 | } | |
290 | ||
291 | #[cfg(not(cfail1))] | |
abe05a73 XL |
292 | #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")] |
293 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 294 | pub fn change_constructor_path_c_like() { |
476ff2be SL |
295 | let _ = Clike2::B; |
296 | } | |
297 | ||
298 | ||
299 | ||
300 | // Change constructor variant (C-like) -------------------------------------- | |
301 | #[cfg(cfail1)] | |
abe05a73 | 302 | pub fn change_constructor_variant_c_like() { |
476ff2be SL |
303 | let _ = Clike::A; |
304 | } | |
305 | ||
306 | #[cfg(not(cfail1))] | |
abe05a73 XL |
307 | #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")] |
308 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 309 | pub fn change_constructor_variant_c_like() { |
476ff2be SL |
310 | let _ = Clike::C; |
311 | } | |
312 | ||
313 | ||
314 | // Change constructor path indirectly (C-like) --------------------------- | |
abe05a73 | 315 | pub mod change_constructor_path_indirectly_c_like { |
476ff2be SL |
316 | #[cfg(cfail1)] |
317 | use super::Clike as TheEnum; | |
318 | #[cfg(not(cfail1))] | |
319 | use super::Clike2 as TheEnum; | |
320 | ||
abe05a73 XL |
321 | #[rustc_clean( |
322 | cfg="cfail2", | |
323 | except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,\ | |
324 | TypeckTables" | |
325 | )] | |
326 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 327 | pub fn function() -> TheEnum { |
476ff2be SL |
328 | TheEnum::B |
329 | } | |
330 | } | |
331 | ||
332 | ||
333 | ||
334 | // Change constructor variant indirectly (C-like) --------------------------- | |
abe05a73 | 335 | pub mod change_constructor_variant_indirectly_c_like { |
476ff2be SL |
336 | use super::Clike; |
337 | #[cfg(cfail1)] | |
338 | use super::Clike::A as Variant; | |
339 | #[cfg(not(cfail1))] | |
340 | use super::Clike::B as Variant; | |
341 | ||
abe05a73 XL |
342 | #[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated")] |
343 | #[rustc_clean(cfg="cfail3")] | |
abe05a73 | 344 | pub fn function() -> Clike { |
476ff2be SL |
345 | Variant |
346 | } | |
347 | } |