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.
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.
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for let expressions.
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.
19 // must-compile-successfully
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph
25 #![feature(rustc_attrs)]
26 #![feature(specialization)]
31 // Change Method Name -----------------------------------------------------------
34 pub trait ChangeMethodNameTrait {
39 impl ChangeMethodNameTrait for Foo {
44 #[rustc_dirty(label="Hir", cfg="cfail2")]
45 #[rustc_clean(label="Hir", cfg="cfail3")]
46 #[rustc_metadata_dirty(cfg="cfail2")]
47 #[rustc_metadata_clean(cfg="cfail3")]
48 pub trait ChangeMethodNameTrait {
49 #[rustc_clean(label="Hir", cfg="cfail3")]
50 #[rustc_metadata_clean(cfg="cfail3")]
55 #[rustc_dirty(label="Hir", cfg="cfail2")]
56 #[rustc_clean(label="Hir", cfg="cfail3")]
57 #[rustc_metadata_dirty(cfg="cfail2")]
58 #[rustc_metadata_clean(cfg="cfail3")]
59 impl ChangeMethodNameTrait for Foo {
60 #[rustc_clean(label="Hir", cfg="cfail3")]
61 #[rustc_metadata_clean(cfg="cfail3")]
65 // Change Method Body -----------------------------------------------------------
67 // This should affect the method itself, but not the impl.
69 pub trait ChangeMethodBodyTrait {
74 impl ChangeMethodBodyTrait for Foo {
79 #[rustc_clean(label="Hir", cfg="cfail2")]
80 #[rustc_clean(label="Hir", cfg="cfail3")]
81 #[rustc_metadata_clean(cfg="cfail2")]
82 #[rustc_metadata_clean(cfg="cfail3")]
83 impl ChangeMethodBodyTrait for Foo {
84 #[rustc_clean(label="Hir", cfg="cfail2")]
85 #[rustc_clean(label="Hir", cfg="cfail3")]
86 #[rustc_dirty(label="HirBody", cfg="cfail2")]
87 #[rustc_clean(label="HirBody", cfg="cfail3")]
88 #[rustc_metadata_clean(cfg="cfail2")]
89 #[rustc_metadata_clean(cfg="cfail3")]
95 // Change Method Body (inlined fn) ---------------------------------------------
97 // This should affect the method itself, but not the impl.
99 pub trait ChangeMethodBodyTraitInlined {
104 impl ChangeMethodBodyTraitInlined for Foo {
110 #[rustc_clean(label="Hir", cfg="cfail2")]
111 #[rustc_clean(label="Hir", cfg="cfail3")]
112 #[rustc_metadata_clean(cfg="cfail2")]
113 #[rustc_metadata_clean(cfg="cfail3")]
114 impl ChangeMethodBodyTraitInlined for Foo {
115 #[rustc_clean(label="Hir", cfg="cfail2")]
116 #[rustc_clean(label="Hir", cfg="cfail3")]
117 #[rustc_dirty(label="HirBody", cfg="cfail2")]
118 #[rustc_clean(label="HirBody", cfg="cfail3")]
119 #[rustc_metadata_dirty(cfg="cfail2")]
120 #[rustc_metadata_clean(cfg="cfail3")]
127 // Change Method Selfness ------------------------------------------------------
130 pub trait ChangeMethodSelfnessTrait {
135 impl ChangeMethodSelfnessTrait for Foo {
140 pub trait ChangeMethodSelfnessTrait {
141 fn method_name(&self);
145 #[rustc_dirty(label="Hir", cfg="cfail2")]
146 #[rustc_clean(label="Hir", cfg="cfail3")]
147 #[rustc_metadata_dirty(cfg="cfail2")]
148 #[rustc_metadata_clean(cfg="cfail3")]
149 impl ChangeMethodSelfnessTrait for Foo {
150 #[rustc_dirty(label="Hir", cfg="cfail2")]
151 #[rustc_clean(label="Hir", cfg="cfail3")]
152 #[rustc_metadata_dirty(cfg="cfail2")]
153 #[rustc_metadata_clean(cfg="cfail3")]
154 fn method_name(&self) {
159 // Change Method Selfness -----------------------------------------------------------
162 pub trait RemoveMethodSelfnessTrait {
163 fn method_name(&self);
167 impl RemoveMethodSelfnessTrait for Foo {
168 fn method_name(&self) { }
172 pub trait RemoveMethodSelfnessTrait {
177 #[rustc_dirty(label="Hir", cfg="cfail2")]
178 #[rustc_clean(label="Hir", cfg="cfail3")]
179 #[rustc_metadata_dirty(cfg="cfail2")]
180 #[rustc_metadata_clean(cfg="cfail3")]
181 impl RemoveMethodSelfnessTrait for Foo {
182 #[rustc_dirty(label="Hir", cfg="cfail2")]
183 #[rustc_clean(label="Hir", cfg="cfail3")]
184 #[rustc_metadata_dirty(cfg="cfail2")]
185 #[rustc_metadata_clean(cfg="cfail3")]
191 // Change Method Selfmutness -----------------------------------------------------------
194 pub trait ChangeMethodSelfmutnessTrait {
195 fn method_name(&self);
199 impl ChangeMethodSelfmutnessTrait for Foo {
200 fn method_name(&self) { }
204 pub trait ChangeMethodSelfmutnessTrait {
205 fn method_name(&mut self);
209 #[rustc_clean(label="Hir", cfg="cfail2")]
210 #[rustc_clean(label="Hir", cfg="cfail3")]
211 #[rustc_metadata_dirty(cfg="cfail2")]
212 #[rustc_metadata_clean(cfg="cfail3")]
213 impl ChangeMethodSelfmutnessTrait for Foo {
214 #[rustc_dirty(label="Hir", cfg="cfail2")]
215 #[rustc_clean(label="Hir", cfg="cfail3")]
216 #[rustc_metadata_dirty(cfg="cfail2")]
217 #[rustc_metadata_clean(cfg="cfail3")]
218 fn method_name(&mut self) {
223 // Change item kind -----------------------------------------------------------
226 pub trait ChangeItemKindTrait {
231 impl ChangeItemKindTrait for Foo {
236 pub trait ChangeItemKindTrait {
241 #[rustc_dirty(label="Hir", cfg="cfail2")]
242 #[rustc_clean(label="Hir", cfg="cfail3")]
243 #[rustc_metadata_dirty(cfg="cfail2")]
244 #[rustc_metadata_clean(cfg="cfail3")]
245 impl ChangeItemKindTrait for Foo {
249 // Remove item -----------------------------------------------------------
252 pub trait RemoveItemTrait {
258 impl RemoveItemTrait for Foo {
264 pub trait RemoveItemTrait {
269 #[rustc_dirty(label="Hir", cfg="cfail2")]
270 #[rustc_clean(label="Hir", cfg="cfail3")]
271 #[rustc_metadata_dirty(cfg="cfail2")]
272 #[rustc_metadata_clean(cfg="cfail3")]
273 impl RemoveItemTrait for Foo {
277 // Add item -----------------------------------------------------------
280 pub trait AddItemTrait {
285 impl AddItemTrait for Foo {
290 pub trait AddItemTrait {
296 #[rustc_dirty(label="Hir", cfg="cfail2")]
297 #[rustc_clean(label="Hir", cfg="cfail3")]
298 #[rustc_metadata_dirty(cfg="cfail2")]
299 #[rustc_metadata_clean(cfg="cfail3")]
300 impl AddItemTrait for Foo {
305 // Change has-value -----------------------------------------------------------
308 pub trait ChangeHasValueTrait {
313 impl ChangeHasValueTrait for 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 trait ChangeHasValueTrait {
327 #[rustc_clean(label="Hir", cfg="cfail2")]
328 #[rustc_clean(label="Hir", cfg="cfail3")]
329 #[rustc_metadata_dirty(cfg="cfail2")]
330 #[rustc_metadata_clean(cfg="cfail3")]
331 impl ChangeHasValueTrait for Foo {
337 pub trait AddDefaultTrait {
342 impl AddDefaultTrait for Foo {
347 #[rustc_dirty(label="Hir", cfg="cfail2")]
348 #[rustc_clean(label="Hir", cfg="cfail3")]
349 #[rustc_metadata_dirty(cfg="cfail2")]
350 #[rustc_metadata_clean(cfg="cfail3")]
351 impl AddDefaultTrait for Foo {
352 default fn method_name() { }
357 pub trait RemoveDefaultTrait {
362 impl RemoveDefaultTrait for Foo {
363 default fn method_name() { }
367 #[rustc_dirty(label="Hir", cfg="cfail2")]
368 #[rustc_clean(label="Hir", cfg="cfail3")]
369 #[rustc_metadata_dirty(cfg="cfail2")]
370 #[rustc_metadata_clean(cfg="cfail3")]
371 impl RemoveDefaultTrait for Foo {
378 pub trait AddArgumentTrait {
379 fn method_name(&self);
383 impl AddArgumentTrait for Foo {
384 fn method_name(&self) { }
388 pub trait AddArgumentTrait {
389 fn method_name(&self, x: u32);
393 #[rustc_clean(label="Hir", cfg="cfail2")]
394 #[rustc_clean(label="Hir", cfg="cfail3")]
395 #[rustc_metadata_dirty(cfg="cfail2")]
396 #[rustc_metadata_clean(cfg="cfail3")]
397 impl AddArgumentTrait for Foo {
398 #[rustc_dirty(label="Hir", cfg="cfail2")]
399 #[rustc_clean(label="Hir", cfg="cfail3")]
400 #[rustc_metadata_dirty(cfg="cfail2")]
401 #[rustc_metadata_clean(cfg="cfail3")]
402 fn method_name(&self, _x: u32) { }
405 // Change argument type
408 pub trait ChangeArgumentTypeTrait {
409 fn method_name(&self, x: u32);
413 impl ChangeArgumentTypeTrait for Foo {
414 fn method_name(&self, _x: u32) { }
418 pub trait ChangeArgumentTypeTrait {
419 fn method_name(&self, x: char);
423 #[rustc_clean(label="Hir", cfg="cfail2")]
424 #[rustc_clean(label="Hir", cfg="cfail3")]
425 #[rustc_metadata_dirty(cfg="cfail2")]
426 #[rustc_metadata_clean(cfg="cfail3")]
427 impl ChangeArgumentTypeTrait for Foo {
428 #[rustc_dirty(label="Hir", cfg="cfail2")]
429 #[rustc_clean(label="Hir", cfg="cfail3")]
430 #[rustc_metadata_dirty(cfg="cfail2")]
431 #[rustc_metadata_clean(cfg="cfail3")]
432 fn method_name(&self, _x: char) { }
439 // Add Type Parameter To Impl --------------------------------------------------
440 trait AddTypeParameterToImpl<T> {
445 impl AddTypeParameterToImpl<u32> for Bar<u32> {
446 fn id(t: u32) -> u32 { t }
450 #[rustc_dirty(label="Hir", cfg="cfail2")]
451 #[rustc_clean(label="Hir", cfg="cfail3")]
452 #[rustc_metadata_dirty(cfg="cfail2")]
453 #[rustc_metadata_clean(cfg="cfail3")]
454 impl<T> AddTypeParameterToImpl<T> for Bar<T> {
455 #[rustc_dirty(label="Hir", cfg="cfail2")]
456 #[rustc_clean(label="Hir", cfg="cfail3")]
457 #[rustc_metadata_dirty(cfg="cfail2")]
458 #[rustc_metadata_clean(cfg="cfail3")]
459 fn id(t: T) -> T { t }
464 // Change Self Type of Impl ----------------------------------------------------
465 trait ChangeSelfTypeOfImpl {
470 impl ChangeSelfTypeOfImpl for u32 {
471 fn id(self) -> Self { self }
475 #[rustc_dirty(label="Hir", cfg="cfail2")]
476 #[rustc_clean(label="Hir", cfg="cfail3")]
477 #[rustc_metadata_dirty(cfg="cfail2")]
478 #[rustc_metadata_clean(cfg="cfail3")]
479 impl ChangeSelfTypeOfImpl for u64 {
480 #[rustc_clean(label="Hir", cfg="cfail2")]
481 #[rustc_clean(label="Hir", cfg="cfail3")]
482 #[rustc_metadata_dirty(cfg="cfail2")]
483 #[rustc_metadata_clean(cfg="cfail3")]
484 fn id(self) -> Self { self }
489 // Add Lifetime Bound to Impl --------------------------------------------------
490 trait AddLifetimeBoundToImplParameter {
495 impl<T> AddLifetimeBoundToImplParameter for T {
496 fn id(self) -> Self { self }
500 #[rustc_dirty(label="Hir", cfg="cfail2")]
501 #[rustc_clean(label="Hir", cfg="cfail3")]
502 #[rustc_metadata_dirty(cfg="cfail2")]
503 #[rustc_metadata_clean(cfg="cfail3")]
504 impl<T: 'static> AddLifetimeBoundToImplParameter for T {
505 #[rustc_clean(label="Hir", cfg="cfail2")]
506 #[rustc_clean(label="Hir", cfg="cfail3")]
507 #[rustc_metadata_dirty(cfg="cfail2")]
508 #[rustc_metadata_clean(cfg="cfail3")]
509 fn id(self) -> Self { self }
514 // Add Trait Bound to Impl Parameter -------------------------------------------
515 trait AddTraitBoundToImplParameter {
520 impl<T> AddTraitBoundToImplParameter for T {
521 fn id(self) -> Self { self }
525 #[rustc_dirty(label="Hir", cfg="cfail2")]
526 #[rustc_clean(label="Hir", cfg="cfail3")]
527 #[rustc_metadata_dirty(cfg="cfail2")]
528 #[rustc_metadata_clean(cfg="cfail3")]
529 impl<T: Clone> AddTraitBoundToImplParameter for T {
530 #[rustc_clean(label="Hir", cfg="cfail2")]
531 #[rustc_clean(label="Hir", cfg="cfail3")]
532 #[rustc_metadata_dirty(cfg="cfail2")]
533 #[rustc_metadata_clean(cfg="cfail3")]
534 fn id(self) -> Self { self }
539 // Add #[no_mangle] to Method --------------------------------------------------
540 trait AddNoMangleToMethod {
541 fn add_no_mangle_to_method(&self) { }
545 impl AddNoMangleToMethod for Foo {
546 fn add_no_mangle_to_method(&self) { }
550 #[rustc_clean(label="Hir", cfg="cfail2")]
551 #[rustc_clean(label="Hir", cfg="cfail3")]
552 #[rustc_metadata_clean(cfg="cfail2")]
553 #[rustc_metadata_clean(cfg="cfail3")]
554 impl AddNoMangleToMethod for Foo {
555 #[rustc_dirty(label="Hir", cfg="cfail2")]
556 #[rustc_clean(label="Hir", cfg="cfail3")]
557 #[rustc_metadata_dirty(cfg="cfail2")]
558 #[rustc_metadata_clean(cfg="cfail3")]
560 fn add_no_mangle_to_method(&self) { }
564 // Make Method #[inline] -------------------------------------------------------
565 trait MakeMethodInline {
566 fn make_method_inline(&self) -> u8 { 0 }
570 impl MakeMethodInline for Foo {
571 fn make_method_inline(&self) -> u8 { 0 }
575 #[rustc_clean(label="Hir", cfg="cfail2")]
576 #[rustc_clean(label="Hir", cfg="cfail3")]
577 #[rustc_metadata_clean(cfg="cfail2")]
578 #[rustc_metadata_clean(cfg="cfail3")]
579 impl MakeMethodInline for Foo {
580 #[rustc_dirty(label="Hir", cfg="cfail2")]
581 #[rustc_clean(label="Hir", cfg="cfail3")]
582 #[rustc_metadata_dirty(cfg="cfail2")]
583 #[rustc_metadata_clean(cfg="cfail3")]
585 fn make_method_inline(&self) -> u8 { 0 }