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_clean(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_clean(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")]
189 // Change Method Selfmutness -----------------------------------------------------------
192 pub trait ChangeMethodSelfmutnessTrait {
193 fn method_name(&self);
197 impl ChangeMethodSelfmutnessTrait for Foo {
198 fn method_name(&self) { }
202 pub trait ChangeMethodSelfmutnessTrait {
203 fn method_name(&mut self);
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 ChangeMethodSelfmutnessTrait for 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 fn method_name(&mut self) {}
219 // Change item kind -----------------------------------------------------------
222 pub trait ChangeItemKindTrait {
227 impl ChangeItemKindTrait for Foo {
232 pub trait ChangeItemKindTrait {
237 #[rustc_dirty(label="Hir", cfg="cfail2")]
238 #[rustc_clean(label="Hir", cfg="cfail3")]
239 #[rustc_metadata_dirty(cfg="cfail2")]
240 #[rustc_metadata_clean(cfg="cfail3")]
241 impl ChangeItemKindTrait for Foo {
245 // Remove item -----------------------------------------------------------
248 pub trait RemoveItemTrait {
254 impl RemoveItemTrait for Foo {
260 pub trait RemoveItemTrait {
265 #[rustc_dirty(label="Hir", cfg="cfail2")]
266 #[rustc_clean(label="Hir", cfg="cfail3")]
267 #[rustc_metadata_dirty(cfg="cfail2")]
268 #[rustc_metadata_clean(cfg="cfail3")]
269 impl RemoveItemTrait for Foo {
273 // Add item -----------------------------------------------------------
276 pub trait AddItemTrait {
281 impl AddItemTrait for Foo {
286 pub trait AddItemTrait {
292 #[rustc_dirty(label="Hir", cfg="cfail2")]
293 #[rustc_clean(label="Hir", cfg="cfail3")]
294 #[rustc_metadata_dirty(cfg="cfail2")]
295 #[rustc_metadata_clean(cfg="cfail3")]
296 impl AddItemTrait for Foo {
301 // Change has-value -----------------------------------------------------------
304 pub trait ChangeHasValueTrait {
309 impl ChangeHasValueTrait for Foo {
314 #[rustc_dirty(label="Hir", cfg="cfail2")]
315 #[rustc_clean(label="Hir", cfg="cfail3")]
316 #[rustc_metadata_clean(cfg="cfail2")]
317 #[rustc_metadata_clean(cfg="cfail3")]
318 pub trait ChangeHasValueTrait {
319 #[rustc_dirty(label="Hir", cfg="cfail2")]
320 #[rustc_clean(label="Hir", cfg="cfail3")]
321 #[rustc_metadata_dirty(cfg="cfail2")]
322 #[rustc_metadata_clean(cfg="cfail3")]
327 #[rustc_clean(label="Hir", cfg="cfail2")]
328 #[rustc_clean(label="Hir", cfg="cfail3")]
329 #[rustc_metadata_clean(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_clean(cfg="cfail2")]
350 #[rustc_metadata_clean(cfg="cfail3")]
351 impl AddDefaultTrait for Foo {
352 #[rustc_dirty(label="Hir", cfg="cfail2")]
353 #[rustc_clean(label="Hir", cfg="cfail3")]
354 #[rustc_metadata_dirty(cfg="cfail2")]
355 #[rustc_metadata_clean(cfg="cfail3")]
356 default fn method_name() { }
362 pub trait AddArgumentTrait {
363 fn method_name(&self);
367 impl AddArgumentTrait for Foo {
368 fn method_name(&self) { }
372 pub trait AddArgumentTrait {
373 fn method_name(&self, x: u32);
377 #[rustc_clean(label="Hir", cfg="cfail2")]
378 #[rustc_clean(label="Hir", cfg="cfail3")]
379 #[rustc_metadata_clean(cfg="cfail2")]
380 #[rustc_metadata_clean(cfg="cfail3")]
381 impl AddArgumentTrait for Foo {
382 #[rustc_dirty(label="Hir", cfg="cfail2")]
383 #[rustc_clean(label="Hir", cfg="cfail3")]
384 #[rustc_metadata_dirty(cfg="cfail2")]
385 #[rustc_metadata_clean(cfg="cfail3")]
386 fn method_name(&self, _x: u32) { }
389 // Change argument type
392 pub trait ChangeArgumentTypeTrait {
393 fn method_name(&self, x: u32);
397 impl ChangeArgumentTypeTrait for Foo {
398 fn method_name(&self, _x: u32) { }
402 pub trait ChangeArgumentTypeTrait {
403 fn method_name(&self, x: char);
407 #[rustc_clean(label="Hir", cfg="cfail2")]
408 #[rustc_clean(label="Hir", cfg="cfail3")]
409 #[rustc_metadata_clean(cfg="cfail2")]
410 #[rustc_metadata_clean(cfg="cfail3")]
411 impl ChangeArgumentTypeTrait for Foo {
412 #[rustc_dirty(label="Hir", cfg="cfail2")]
413 #[rustc_clean(label="Hir", cfg="cfail3")]
414 #[rustc_metadata_dirty(cfg="cfail2")]
415 #[rustc_metadata_clean(cfg="cfail3")]
416 fn method_name(&self, _x: char) { }
423 // Add Type Parameter To Impl --------------------------------------------------
424 trait AddTypeParameterToImpl<T> {
429 impl AddTypeParameterToImpl<u32> for Bar<u32> {
430 fn id(t: u32) -> u32 { t }
434 #[rustc_dirty(label="Hir", cfg="cfail2")]
435 #[rustc_clean(label="Hir", cfg="cfail3")]
436 #[rustc_metadata_dirty(cfg="cfail2")]
437 #[rustc_metadata_clean(cfg="cfail3")]
438 impl<T> AddTypeParameterToImpl<T> for Bar<T> {
439 #[rustc_dirty(label="Hir", cfg="cfail2")]
440 #[rustc_clean(label="Hir", cfg="cfail3")]
441 #[rustc_metadata_dirty(cfg="cfail2")]
442 #[rustc_metadata_clean(cfg="cfail3")]
443 fn id(t: T) -> T { t }
448 // Change Self Type of Impl ----------------------------------------------------
449 trait ChangeSelfTypeOfImpl {
454 impl ChangeSelfTypeOfImpl for u32 {
455 fn id(self) -> Self { self }
459 #[rustc_dirty(label="Hir", cfg="cfail2")]
460 #[rustc_clean(label="Hir", cfg="cfail3")]
461 #[rustc_metadata_dirty(cfg="cfail2")]
462 #[rustc_metadata_clean(cfg="cfail3")]
463 impl ChangeSelfTypeOfImpl for u64 {
464 #[rustc_clean(label="Hir", cfg="cfail2")]
465 #[rustc_clean(label="Hir", cfg="cfail3")]
466 #[rustc_metadata_dirty(cfg="cfail2")]
467 #[rustc_metadata_clean(cfg="cfail3")]
468 fn id(self) -> Self { self }
473 // Add Lifetime Bound to Impl --------------------------------------------------
474 trait AddLifetimeBoundToImplParameter {
479 impl<T> AddLifetimeBoundToImplParameter for T {
480 fn id(self) -> Self { self }
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<T: 'static> AddLifetimeBoundToImplParameter for T {
489 #[rustc_clean(label="Hir", cfg="cfail2")]
490 #[rustc_clean(label="Hir", cfg="cfail3")]
491 #[rustc_metadata_clean(cfg="cfail2")]
492 #[rustc_metadata_clean(cfg="cfail3")]
493 fn id(self) -> Self { self }
498 // Add Trait Bound to Impl Parameter -------------------------------------------
499 trait AddTraitBoundToImplParameter {
504 impl<T> AddTraitBoundToImplParameter for T {
505 fn id(self) -> Self { self }
509 #[rustc_dirty(label="Hir", cfg="cfail2")]
510 #[rustc_clean(label="Hir", cfg="cfail3")]
511 #[rustc_metadata_dirty(cfg="cfail2")]
512 #[rustc_metadata_clean(cfg="cfail3")]
513 impl<T: Clone> AddTraitBoundToImplParameter for T {
514 #[rustc_clean(label="Hir", cfg="cfail2")]
515 #[rustc_clean(label="Hir", cfg="cfail3")]
516 #[rustc_metadata_clean(cfg="cfail2")]
517 #[rustc_metadata_clean(cfg="cfail3")]
518 fn id(self) -> Self { self }
523 // Add #[no_mangle] to Method --------------------------------------------------
524 trait AddNoMangleToMethod {
525 fn add_no_mangle_to_method(&self) { }
529 impl AddNoMangleToMethod for Foo {
530 fn add_no_mangle_to_method(&self) { }
534 #[rustc_clean(label="Hir", cfg="cfail2")]
535 #[rustc_clean(label="Hir", cfg="cfail3")]
536 #[rustc_metadata_clean(cfg="cfail2")]
537 #[rustc_metadata_clean(cfg="cfail3")]
538 impl AddNoMangleToMethod for Foo {
539 #[rustc_dirty(label="Hir", cfg="cfail2")]
540 #[rustc_clean(label="Hir", cfg="cfail3")]
541 #[rustc_metadata_dirty(cfg="cfail2")]
542 #[rustc_metadata_clean(cfg="cfail3")]
544 fn add_no_mangle_to_method(&self) { }
548 // Make Method #[inline] -------------------------------------------------------
549 trait MakeMethodInline {
550 fn make_method_inline(&self) -> u8 { 0 }
554 impl MakeMethodInline for Foo {
555 fn make_method_inline(&self) -> u8 { 0 }
559 #[rustc_clean(label="Hir", cfg="cfail2")]
560 #[rustc_clean(label="Hir", cfg="cfail3")]
561 #[rustc_metadata_clean(cfg="cfail2")]
562 #[rustc_metadata_clean(cfg="cfail3")]
563 impl MakeMethodInline for Foo {
564 #[rustc_dirty(label="Hir", cfg="cfail2")]
565 #[rustc_clean(label="Hir", cfg="cfail3")]
566 #[rustc_metadata_dirty(cfg="cfail2")]
567 #[rustc_metadata_clean(cfg="cfail3")]
569 fn make_method_inline(&self) -> u8 { 0 }