]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/inherent_impls.rs
Unignore u128 test for stage 0,1
[rust.git] / src / test / incremental / hashes / inherent_impls.rs
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 let 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
19 // must-compile-successfully
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph
22
23
24 #![allow(warnings)]
25 #![feature(rustc_attrs)]
26 #![crate_type="rlib"]
27
28 struct Foo;
29
30 // Change Method Name -----------------------------------------------------------
31 #[cfg(cfail1)]
32 impl Foo {
33     pub fn method_name() { }
34 }
35
36 #[cfg(not(cfail1))]
37 #[rustc_dirty(label="Hir", cfg="cfail2")]
38 #[rustc_clean(label="Hir", cfg="cfail3")]
39 #[rustc_metadata_dirty(cfg="cfail2")]
40 #[rustc_metadata_clean(cfg="cfail3")]
41 impl Foo {
42     #[rustc_dirty(label="Hir", cfg="cfail2")]
43     #[rustc_clean(label="Hir", cfg="cfail3")]
44     #[rustc_metadata_dirty(cfg="cfail2")]
45     #[rustc_metadata_clean(cfg="cfail3")]
46     pub fn method_name2() { }
47 }
48
49 // Change Method Body -----------------------------------------------------------
50 //
51 // This should affect the method itself, but not the impl.
52 #[cfg(cfail1)]
53 impl Foo {
54     pub fn method_body() { }
55 }
56
57 #[cfg(not(cfail1))]
58 #[rustc_clean(label="Hir", cfg="cfail2")]
59 #[rustc_clean(label="Hir", cfg="cfail3")]
60 #[rustc_metadata_clean(cfg="cfail2")]
61 #[rustc_metadata_clean(cfg="cfail3")]
62 impl Foo {
63     #[rustc_dirty(label="Hir", cfg="cfail2")]
64     #[rustc_clean(label="Hir", cfg="cfail3")]
65     #[rustc_metadata_dirty(cfg="cfail2")]
66     #[rustc_metadata_clean(cfg="cfail3")]
67     pub fn method_body() {
68         println!("Hello, world!");
69     }
70 }
71
72 // Change Method Privacy -----------------------------------------------------------
73 #[cfg(cfail1)]
74 impl Foo {
75     pub fn method_privacy() { }
76 }
77
78 #[cfg(not(cfail1))]
79 #[rustc_dirty(label="Hir", cfg="cfail2")]
80 #[rustc_clean(label="Hir", cfg="cfail3")]
81 #[rustc_metadata_dirty(cfg="cfail2")]
82 #[rustc_metadata_clean(cfg="cfail3")]
83 impl Foo {
84     #[rustc_dirty(label="Hir", cfg="cfail2")]
85     #[rustc_clean(label="Hir", cfg="cfail3")]
86     #[rustc_metadata_dirty(cfg="cfail2")]
87     #[rustc_metadata_clean(cfg="cfail3")]
88     fn method_privacy() { }
89 }
90
91 // Change Method Selfness -----------------------------------------------------------
92 #[cfg(cfail1)]
93 impl Foo {
94     pub fn method_selfness() { }
95 }
96
97 #[cfg(not(cfail1))]
98 #[rustc_dirty(label="Hir", cfg="cfail2")]
99 #[rustc_clean(label="Hir", cfg="cfail3")]
100 #[rustc_metadata_dirty(cfg="cfail2")]
101 #[rustc_metadata_clean(cfg="cfail3")]
102 impl Foo {
103     #[rustc_dirty(label="Hir", cfg="cfail2")]
104     #[rustc_clean(label="Hir", cfg="cfail3")]
105     #[rustc_metadata_dirty(cfg="cfail2")]
106     #[rustc_metadata_clean(cfg="cfail3")]
107     pub fn method_selfness(&self) { }
108 }
109
110 // Change Method Selfmutness ---------------------------------------------------
111 #[cfg(cfail1)]
112 impl Foo {
113     pub fn method_selfmutness(&self) { }
114 }
115
116 #[cfg(not(cfail1))]
117 #[rustc_clean(label="Hir", cfg="cfail2")]
118 #[rustc_clean(label="Hir", cfg="cfail3")]
119 #[rustc_metadata_clean(cfg="cfail2")]
120 #[rustc_metadata_clean(cfg="cfail3")]
121 impl Foo {
122     #[rustc_dirty(label="Hir", cfg="cfail2")]
123     #[rustc_clean(label="Hir", cfg="cfail3")]
124     #[rustc_metadata_dirty(cfg="cfail2")]
125     #[rustc_metadata_clean(cfg="cfail3")]
126     pub fn method_selfmutness(&mut self) { }
127 }
128
129
130
131 // Add Method To Impl ----------------------------------------------------------
132 #[cfg(cfail1)]
133 impl Foo {
134     pub fn add_method_to_impl1(&self) { }
135 }
136
137 #[cfg(not(cfail1))]
138 #[rustc_dirty(label="Hir", cfg="cfail2")]
139 #[rustc_clean(label="Hir", cfg="cfail3")]
140 #[rustc_metadata_dirty(cfg="cfail2")]
141 #[rustc_metadata_clean(cfg="cfail3")]
142 impl Foo {
143     #[rustc_clean(label="Hir", cfg="cfail2")]
144     #[rustc_clean(label="Hir", cfg="cfail3")]
145     #[rustc_metadata_clean(cfg="cfail2")]
146     #[rustc_metadata_clean(cfg="cfail3")]
147     pub fn add_method_to_impl1(&self) { }
148
149     #[rustc_dirty(label="Hir", cfg="cfail2")]
150     #[rustc_clean(label="Hir", cfg="cfail3")]
151     #[rustc_metadata_dirty(cfg="cfail2")]
152     #[rustc_metadata_clean(cfg="cfail3")]
153     pub fn add_method_to_impl2(&self) { }
154 }
155
156
157
158 // Add Method Parameter --------------------------------------------------------
159 #[cfg(cfail1)]
160 impl Foo {
161     pub fn add_method_parameter(&self) { }
162 }
163
164 #[cfg(not(cfail1))]
165 #[rustc_clean(label="Hir", cfg="cfail2")]
166 #[rustc_clean(label="Hir", cfg="cfail3")]
167 #[rustc_metadata_clean(cfg="cfail2")]
168 #[rustc_metadata_clean(cfg="cfail3")]
169 impl Foo {
170     #[rustc_dirty(label="Hir", cfg="cfail2")]
171     #[rustc_clean(label="Hir", cfg="cfail3")]
172     #[rustc_metadata_dirty(cfg="cfail2")]
173     #[rustc_metadata_clean(cfg="cfail3")]
174     pub fn add_method_parameter(&self, _: i32) { }
175 }
176
177
178
179 // Change Method Parameter Name ------------------------------------------------
180 #[cfg(cfail1)]
181 impl Foo {
182     pub fn change_method_parameter_name(&self, a: i64) { }
183 }
184
185 #[cfg(not(cfail1))]
186 #[rustc_clean(label="Hir", cfg="cfail2")]
187 #[rustc_clean(label="Hir", cfg="cfail3")]
188 #[rustc_metadata_clean(cfg="cfail2")]
189 #[rustc_metadata_clean(cfg="cfail3")]
190 impl Foo {
191     #[rustc_dirty(label="Hir", cfg="cfail2")]
192     #[rustc_clean(label="Hir", cfg="cfail3")]
193     #[rustc_metadata_dirty(cfg="cfail2")]
194     #[rustc_metadata_clean(cfg="cfail3")]
195     pub fn change_method_parameter_name(&self, b: i64) { }
196 }
197
198
199
200 // Change Method Return Type ---------------------------------------------------
201 #[cfg(cfail1)]
202 impl Foo {
203     pub fn change_method_return_type(&self) -> u16 { 0 }
204 }
205
206 #[cfg(not(cfail1))]
207 #[rustc_clean(label="Hir", cfg="cfail2")]
208 #[rustc_clean(label="Hir", cfg="cfail3")]
209 #[rustc_metadata_clean(cfg="cfail2")]
210 #[rustc_metadata_clean(cfg="cfail3")]
211 impl Foo {
212     #[rustc_dirty(label="Hir", cfg="cfail2")]
213     #[rustc_clean(label="Hir", cfg="cfail3")]
214     #[rustc_metadata_dirty(cfg="cfail2")]
215     #[rustc_metadata_clean(cfg="cfail3")]
216     pub fn change_method_return_type(&self) -> u8 { 0 }
217 }
218
219
220
221 // Make Method #[inline] -------------------------------------------------------
222 #[cfg(cfail1)]
223 impl Foo {
224     pub fn make_method_inline(&self) -> u8 { 0 }
225 }
226
227 #[cfg(not(cfail1))]
228 #[rustc_clean(label="Hir", cfg="cfail2")]
229 #[rustc_clean(label="Hir", cfg="cfail3")]
230 #[rustc_metadata_clean(cfg="cfail2")]
231 #[rustc_metadata_clean(cfg="cfail3")]
232 impl Foo {
233     #[rustc_dirty(label="Hir", cfg="cfail2")]
234     #[rustc_clean(label="Hir", cfg="cfail3")]
235     #[rustc_metadata_dirty(cfg="cfail2")]
236     #[rustc_metadata_clean(cfg="cfail3")]
237     #[inline]
238     pub fn make_method_inline(&self) -> u8 { 0 }
239 }
240
241
242
243 //  Change order of parameters -------------------------------------------------
244 #[cfg(cfail1)]
245 impl Foo {
246     pub fn change_method_parameter_order(&self, a: i64, b: i64) { }
247 }
248
249 #[cfg(not(cfail1))]
250 #[rustc_clean(label="Hir", cfg="cfail2")]
251 #[rustc_clean(label="Hir", cfg="cfail3")]
252 #[rustc_metadata_clean(cfg="cfail2")]
253 #[rustc_metadata_clean(cfg="cfail3")]
254 impl Foo {
255     #[rustc_dirty(label="Hir", cfg="cfail2")]
256     #[rustc_clean(label="Hir", cfg="cfail3")]
257     #[rustc_metadata_dirty(cfg="cfail2")]
258     #[rustc_metadata_clean(cfg="cfail3")]
259     pub fn change_method_parameter_order(&self, b: i64, a: i64) { }
260 }
261
262
263
264 // Make method unsafe ----------------------------------------------------------
265 #[cfg(cfail1)]
266 impl Foo {
267     pub fn make_method_unsafe(&self) { }
268 }
269
270 #[cfg(not(cfail1))]
271 #[rustc_clean(label="Hir", cfg="cfail2")]
272 #[rustc_clean(label="Hir", cfg="cfail3")]
273 #[rustc_metadata_clean(cfg="cfail2")]
274 #[rustc_metadata_clean(cfg="cfail3")]
275 impl Foo {
276     #[rustc_dirty(label="Hir", cfg="cfail2")]
277     #[rustc_clean(label="Hir", cfg="cfail3")]
278     #[rustc_metadata_dirty(cfg="cfail2")]
279     #[rustc_metadata_clean(cfg="cfail3")]
280     pub unsafe fn make_method_unsafe(&self) { }
281 }
282
283
284
285 // Make method extern ----------------------------------------------------------
286 #[cfg(cfail1)]
287 impl Foo {
288     pub fn make_method_extern(&self) { }
289 }
290
291 #[cfg(not(cfail1))]
292 #[rustc_clean(label="Hir", cfg="cfail2")]
293 #[rustc_clean(label="Hir", cfg="cfail3")]
294 #[rustc_metadata_clean(cfg="cfail2")]
295 #[rustc_metadata_clean(cfg="cfail3")]
296 impl Foo {
297     #[rustc_dirty(label="Hir", cfg="cfail2")]
298     #[rustc_clean(label="Hir", cfg="cfail3")]
299     #[rustc_metadata_dirty(cfg="cfail2")]
300     #[rustc_metadata_clean(cfg="cfail3")]
301     pub extern fn make_method_extern(&self) { }
302 }
303
304
305
306 // Change method calling convention --------------------------------------------
307 #[cfg(cfail1)]
308 impl Foo {
309     pub extern "C" fn change_method_calling_convention(&self) { }
310 }
311
312 #[cfg(not(cfail1))]
313 #[rustc_clean(label="Hir", cfg="cfail2")]
314 #[rustc_clean(label="Hir", cfg="cfail3")]
315 #[rustc_metadata_clean(cfg="cfail2")]
316 #[rustc_metadata_clean(cfg="cfail3")]
317 impl Foo {
318     #[rustc_dirty(label="Hir", cfg="cfail2")]
319     #[rustc_clean(label="Hir", cfg="cfail3")]
320     #[rustc_metadata_dirty(cfg="cfail2")]
321     #[rustc_metadata_clean(cfg="cfail3")]
322     pub extern "system" fn change_method_calling_convention(&self) { }
323 }
324
325
326
327 // Add Lifetime Parameter to Method --------------------------------------------
328 #[cfg(cfail1)]
329 impl Foo {
330     pub fn add_lifetime_parameter_to_method(&self) { }
331 }
332
333 #[cfg(not(cfail1))]
334 #[rustc_clean(label="Hir", cfg="cfail2")]
335 #[rustc_clean(label="Hir", cfg="cfail3")]
336 #[rustc_metadata_clean(cfg="cfail2")]
337 #[rustc_metadata_clean(cfg="cfail3")]
338 impl Foo {
339     #[rustc_dirty(label="Hir", cfg="cfail2")]
340     #[rustc_clean(label="Hir", cfg="cfail3")]
341     #[rustc_metadata_dirty(cfg="cfail2")]
342     #[rustc_metadata_clean(cfg="cfail3")]
343     pub fn add_lifetime_parameter_to_method<'a>(&self) { }
344 }
345
346
347
348 // Add Type Parameter To Method ------------------------------------------------
349 #[cfg(cfail1)]
350 impl Foo {
351     pub fn add_type_parameter_to_method(&self) { }
352 }
353
354 #[cfg(not(cfail1))]
355 #[rustc_clean(label="Hir", cfg="cfail2")]
356 #[rustc_clean(label="Hir", cfg="cfail3")]
357 #[rustc_metadata_clean(cfg="cfail2")]
358 #[rustc_metadata_clean(cfg="cfail3")]
359 impl Foo {
360     #[rustc_dirty(label="Hir", cfg="cfail2")]
361     #[rustc_clean(label="Hir", cfg="cfail3")]
362     #[rustc_metadata_dirty(cfg="cfail2")]
363     #[rustc_metadata_clean(cfg="cfail3")]
364     pub fn add_type_parameter_to_method<T>(&self) { }
365 }
366
367
368
369 // Add Lifetime Bound to Lifetime Parameter of Method --------------------------
370 #[cfg(cfail1)]
371 impl Foo {
372     pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b>(&self) { }
373 }
374
375 #[cfg(not(cfail1))]
376 #[rustc_clean(label="Hir", cfg="cfail2")]
377 #[rustc_clean(label="Hir", cfg="cfail3")]
378 #[rustc_metadata_clean(cfg="cfail2")]
379 #[rustc_metadata_clean(cfg="cfail3")]
380 impl Foo {
381     #[rustc_dirty(label="Hir", cfg="cfail2")]
382     #[rustc_clean(label="Hir", cfg="cfail3")]
383     #[rustc_metadata_dirty(cfg="cfail2")]
384     #[rustc_metadata_clean(cfg="cfail3")]
385     pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b: 'a>(&self) { }
386 }
387
388
389
390 // Add Lifetime Bound to Type Parameter of Method ------------------------------
391 #[cfg(cfail1)]
392 impl Foo {
393     pub fn add_lifetime_bound_to_type_param_of_method<'a, T>(&self) { }
394 }
395
396 #[cfg(not(cfail1))]
397 #[rustc_clean(label="Hir", cfg="cfail2")]
398 #[rustc_clean(label="Hir", cfg="cfail3")]
399 #[rustc_metadata_clean(cfg="cfail2")]
400 #[rustc_metadata_clean(cfg="cfail3")]
401 impl Foo {
402     #[rustc_dirty(label="Hir", cfg="cfail2")]
403     #[rustc_clean(label="Hir", cfg="cfail3")]
404     #[rustc_metadata_dirty(cfg="cfail2")]
405     #[rustc_metadata_clean(cfg="cfail3")]
406     pub fn add_lifetime_bound_to_type_param_of_method<'a, T: 'a>(&self) { }
407 }
408
409
410
411 // Add Trait Bound to Type Parameter of Method ------------------------------
412 #[cfg(cfail1)]
413 impl Foo {
414     pub fn add_trait_bound_to_type_param_of_method<T>(&self) { }
415 }
416
417 #[cfg(not(cfail1))]
418 #[rustc_clean(label="Hir", cfg="cfail2")]
419 #[rustc_clean(label="Hir", cfg="cfail3")]
420 #[rustc_metadata_clean(cfg="cfail2")]
421 #[rustc_metadata_clean(cfg="cfail3")]
422 impl Foo {
423     #[rustc_dirty(label="Hir", cfg="cfail2")]
424     #[rustc_clean(label="Hir", cfg="cfail3")]
425     #[rustc_metadata_dirty(cfg="cfail2")]
426     #[rustc_metadata_clean(cfg="cfail3")]
427     pub fn add_trait_bound_to_type_param_of_method<T: Clone>(&self) { }
428 }
429
430
431
432 // Add #[no_mangle] to Method --------------------------------------------------
433 #[cfg(cfail1)]
434 impl Foo {
435     pub fn add_no_mangle_to_method(&self) { }
436 }
437
438 #[cfg(not(cfail1))]
439 #[rustc_clean(label="Hir", cfg="cfail2")]
440 #[rustc_clean(label="Hir", cfg="cfail3")]
441 #[rustc_metadata_clean(cfg="cfail2")]
442 #[rustc_metadata_clean(cfg="cfail3")]
443 impl Foo {
444     #[rustc_dirty(label="Hir", cfg="cfail2")]
445     #[rustc_clean(label="Hir", cfg="cfail3")]
446     #[rustc_metadata_dirty(cfg="cfail2")]
447     #[rustc_metadata_clean(cfg="cfail3")]
448     #[no_mangle]
449     pub fn add_no_mangle_to_method(&self) { }
450 }
451
452
453
454 struct Bar<T>(T);
455
456 // Add Type Parameter To Impl --------------------------------------------------
457 #[cfg(cfail1)]
458 impl Bar<u32> {
459     pub fn add_type_parameter_to_impl(&self) { }
460 }
461
462 #[cfg(not(cfail1))]
463 #[rustc_dirty(label="Hir", cfg="cfail2")]
464 #[rustc_clean(label="Hir", cfg="cfail3")]
465 #[rustc_metadata_dirty(cfg="cfail2")]
466 #[rustc_metadata_clean(cfg="cfail3")]
467 impl<T> Bar<T> {
468     #[rustc_dirty(label="Hir", cfg="cfail2")]
469     #[rustc_clean(label="Hir", cfg="cfail3")]
470     #[rustc_metadata_dirty(cfg="cfail2")]
471     #[rustc_metadata_clean(cfg="cfail3")]
472     pub fn add_type_parameter_to_impl(&self) { }
473 }
474
475
476
477 // Change Self Type of Impl ----------------------------------------------------
478 #[cfg(cfail1)]
479 impl Bar<u32> {
480     pub fn change_impl_self_type(&self) { }
481 }
482
483 #[cfg(not(cfail1))]
484 #[rustc_dirty(label="Hir", cfg="cfail2")]
485 #[rustc_clean(label="Hir", cfg="cfail3")]
486 #[rustc_metadata_dirty(cfg="cfail2")]
487 #[rustc_metadata_clean(cfg="cfail3")]
488 impl Bar<u64> {
489     #[rustc_dirty(label="Hir", cfg="cfail2")]
490     #[rustc_clean(label="Hir", cfg="cfail3")]
491     #[rustc_metadata_dirty(cfg="cfail2")]
492     #[rustc_metadata_clean(cfg="cfail3")]
493     pub fn change_impl_self_type(&self) { }
494 }
495
496
497
498 // Add Lifetime Bound to Impl --------------------------------------------------
499 #[cfg(cfail1)]
500 impl<T> Bar<T> {
501     pub fn add_lifetime_bound_to_impl_parameter(&self) { }
502 }
503
504 #[cfg(not(cfail1))]
505 #[rustc_dirty(label="Hir", cfg="cfail2")]
506 #[rustc_clean(label="Hir", cfg="cfail3")]
507 #[rustc_metadata_dirty(cfg="cfail2")]
508 #[rustc_metadata_clean(cfg="cfail3")]
509 impl<T: 'static> Bar<T> {
510     #[rustc_dirty(label="Hir", cfg="cfail2")]
511     #[rustc_clean(label="Hir", cfg="cfail3")]
512     #[rustc_metadata_dirty(cfg="cfail2")]
513     #[rustc_metadata_clean(cfg="cfail3")]
514     pub fn add_lifetime_bound_to_impl_parameter(&self) { }
515 }
516
517
518
519 // Add Trait Bound to Impl Parameter -------------------------------------------
520 #[cfg(cfail1)]
521 impl<T> Bar<T> {
522     pub fn add_trait_bound_to_impl_parameter(&self) { }
523 }
524
525 #[cfg(not(cfail1))]
526 #[rustc_dirty(label="Hir", cfg="cfail2")]
527 #[rustc_clean(label="Hir", cfg="cfail3")]
528 #[rustc_metadata_dirty(cfg="cfail2")]
529 #[rustc_metadata_clean(cfg="cfail3")]
530 impl<T: Clone> Bar<T> {
531     #[rustc_dirty(label="Hir", cfg="cfail2")]
532     #[rustc_clean(label="Hir", cfg="cfail3")]
533     #[rustc_metadata_dirty(cfg="cfail2")]
534     #[rustc_metadata_clean(cfg="cfail3")]
535     pub fn add_trait_bound_to_impl_parameter(&self) { }
536 }