1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for let expressions.
4 // The general pattern followed here is: Change one thing between rev1 and rev2
5 // and make sure that the hash has changed, then change nothing between rev2 and
6 // rev3 and make sure that the hash has not changed.
9 // revisions: cfail1 cfail2 cfail3
10 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
14 #![feature(rustc_attrs)]
15 #![feature(specialization)]
20 // Change Method Name -----------------------------------------------------------
23 pub trait ChangeMethodNameTrait {
28 impl ChangeMethodNameTrait for Foo {
33 #[rustc_dirty(label="Hir", cfg="cfail2")]
34 #[rustc_clean(label="Hir", cfg="cfail3")]
35 pub trait ChangeMethodNameTrait {
36 #[rustc_clean(label="Hir", cfg="cfail3")]
41 #[rustc_dirty(label="Hir", cfg="cfail2")]
42 #[rustc_clean(label="Hir", cfg="cfail3")]
43 impl ChangeMethodNameTrait for Foo {
44 #[rustc_clean(label="Hir", cfg="cfail3")]
48 // Change Method Body -----------------------------------------------------------
50 // This should affect the method itself, but not the impl.
52 pub trait ChangeMethodBodyTrait {
57 impl ChangeMethodBodyTrait for Foo {
62 #[rustc_clean(label="Hir", cfg="cfail2")]
63 #[rustc_clean(label="Hir", cfg="cfail3")]
64 impl ChangeMethodBodyTrait for Foo {
65 #[rustc_clean(label="Hir", cfg="cfail2")]
66 #[rustc_clean(label="Hir", cfg="cfail3")]
67 #[rustc_dirty(label="HirBody", cfg="cfail2")]
68 #[rustc_clean(label="HirBody", cfg="cfail3")]
74 // Change Method Body (inlined fn) ---------------------------------------------
76 // This should affect the method itself, but not the impl.
78 pub trait ChangeMethodBodyTraitInlined {
83 impl ChangeMethodBodyTraitInlined for Foo {
89 #[rustc_clean(label="Hir", cfg="cfail2")]
90 #[rustc_clean(label="Hir", cfg="cfail3")]
91 impl ChangeMethodBodyTraitInlined for Foo {
92 #[rustc_clean(label="Hir", cfg="cfail2")]
93 #[rustc_clean(label="Hir", cfg="cfail3")]
94 #[rustc_dirty(label="HirBody", cfg="cfail2")]
95 #[rustc_clean(label="HirBody", cfg="cfail3")]
102 // Change Method Selfness ------------------------------------------------------
105 pub trait ChangeMethodSelfnessTrait {
110 impl ChangeMethodSelfnessTrait for Foo {
115 pub trait ChangeMethodSelfnessTrait {
116 fn method_name(&self);
120 #[rustc_dirty(label="Hir", cfg="cfail2")]
121 #[rustc_clean(label="Hir", cfg="cfail3")]
122 impl ChangeMethodSelfnessTrait for Foo {
123 #[rustc_dirty(label="Hir", cfg="cfail2")]
124 #[rustc_clean(label="Hir", cfg="cfail3")]
125 fn method_name(&self) {
130 // Change Method Selfness -----------------------------------------------------------
133 pub trait RemoveMethodSelfnessTrait {
134 fn method_name(&self);
138 impl RemoveMethodSelfnessTrait for Foo {
139 fn method_name(&self) { }
143 pub trait RemoveMethodSelfnessTrait {
148 #[rustc_dirty(label="Hir", cfg="cfail2")]
149 #[rustc_clean(label="Hir", cfg="cfail3")]
150 impl RemoveMethodSelfnessTrait for Foo {
151 #[rustc_dirty(label="Hir", cfg="cfail2")]
152 #[rustc_clean(label="Hir", cfg="cfail3")]
156 // Change Method Selfmutness -----------------------------------------------------------
159 pub trait ChangeMethodSelfmutnessTrait {
160 fn method_name(&self);
164 impl ChangeMethodSelfmutnessTrait for Foo {
165 fn method_name(&self) { }
169 pub trait ChangeMethodSelfmutnessTrait {
170 fn method_name(&mut self);
174 #[rustc_clean(label="Hir", cfg="cfail2")]
175 #[rustc_clean(label="Hir", cfg="cfail3")]
176 impl ChangeMethodSelfmutnessTrait for Foo {
177 #[rustc_dirty(label="Hir", cfg="cfail2")]
178 #[rustc_clean(label="Hir", cfg="cfail3")]
179 fn method_name(&mut self) {}
182 // Change item kind -----------------------------------------------------------
185 pub trait ChangeItemKindTrait {
190 impl ChangeItemKindTrait for Foo {
195 pub trait ChangeItemKindTrait {
200 #[rustc_dirty(label="Hir", cfg="cfail2")]
201 #[rustc_clean(label="Hir", cfg="cfail3")]
202 impl ChangeItemKindTrait for Foo {
206 // Remove item -----------------------------------------------------------
209 pub trait RemoveItemTrait {
215 impl RemoveItemTrait for Foo {
221 pub trait RemoveItemTrait {
226 #[rustc_dirty(label="Hir", cfg="cfail2")]
227 #[rustc_clean(label="Hir", cfg="cfail3")]
228 impl RemoveItemTrait for Foo {
232 // Add item -----------------------------------------------------------
235 pub trait AddItemTrait {
240 impl AddItemTrait for Foo {
245 pub trait AddItemTrait {
251 #[rustc_dirty(label="Hir", cfg="cfail2")]
252 #[rustc_clean(label="Hir", cfg="cfail3")]
253 impl AddItemTrait for Foo {
258 // Change has-value -----------------------------------------------------------
261 pub trait ChangeHasValueTrait {
266 impl ChangeHasValueTrait for Foo {
271 #[rustc_dirty(label="Hir", cfg="cfail2")]
272 #[rustc_clean(label="Hir", cfg="cfail3")]
273 pub trait ChangeHasValueTrait {
274 #[rustc_dirty(label="Hir", cfg="cfail2")]
275 #[rustc_clean(label="Hir", cfg="cfail3")]
280 #[rustc_clean(label="Hir", cfg="cfail2")]
281 #[rustc_clean(label="Hir", cfg="cfail3")]
282 impl ChangeHasValueTrait for Foo {
288 pub trait AddDefaultTrait {
293 impl AddDefaultTrait for Foo {
298 #[rustc_dirty(label="Hir", cfg="cfail2")]
299 #[rustc_clean(label="Hir", cfg="cfail3")]
300 impl AddDefaultTrait for Foo {
301 #[rustc_dirty(label="Hir", cfg="cfail2")]
302 #[rustc_clean(label="Hir", cfg="cfail3")]
303 default fn method_name() { }
309 pub trait AddArgumentTrait {
310 fn method_name(&self);
314 impl AddArgumentTrait for Foo {
315 fn method_name(&self) { }
319 pub trait AddArgumentTrait {
320 fn method_name(&self, x: u32);
324 #[rustc_clean(label="Hir", cfg="cfail2")]
325 #[rustc_clean(label="Hir", cfg="cfail3")]
326 impl AddArgumentTrait for Foo {
327 #[rustc_dirty(label="Hir", cfg="cfail2")]
328 #[rustc_clean(label="Hir", cfg="cfail3")]
329 fn method_name(&self, _x: u32) { }
332 // Change argument type
335 pub trait ChangeArgumentTypeTrait {
336 fn method_name(&self, x: u32);
340 impl ChangeArgumentTypeTrait for Foo {
341 fn method_name(&self, _x: u32) { }
345 pub trait ChangeArgumentTypeTrait {
346 fn method_name(&self, x: char);
350 #[rustc_clean(label="Hir", cfg="cfail2")]
351 #[rustc_clean(label="Hir", cfg="cfail3")]
352 impl ChangeArgumentTypeTrait for Foo {
353 #[rustc_dirty(label="Hir", cfg="cfail2")]
354 #[rustc_clean(label="Hir", cfg="cfail3")]
355 fn method_name(&self, _x: char) { }
362 // Add Type Parameter To Impl --------------------------------------------------
363 trait AddTypeParameterToImpl<T> {
368 impl AddTypeParameterToImpl<u32> for Bar<u32> {
369 fn id(t: u32) -> u32 { t }
373 #[rustc_dirty(label="Hir", cfg="cfail2")]
374 #[rustc_clean(label="Hir", cfg="cfail3")]
375 impl<T> AddTypeParameterToImpl<T> for Bar<T> {
376 #[rustc_dirty(label="Hir", cfg="cfail2")]
377 #[rustc_clean(label="Hir", cfg="cfail3")]
378 fn id(t: T) -> T { t }
383 // Change Self Type of Impl ----------------------------------------------------
384 trait ChangeSelfTypeOfImpl {
389 impl ChangeSelfTypeOfImpl for u32 {
390 fn id(self) -> Self { self }
394 #[rustc_dirty(label="Hir", cfg="cfail2")]
395 #[rustc_clean(label="Hir", cfg="cfail3")]
396 impl ChangeSelfTypeOfImpl for u64 {
397 #[rustc_clean(label="Hir", cfg="cfail2")]
398 #[rustc_clean(label="Hir", cfg="cfail3")]
399 fn id(self) -> Self { self }
404 // Add Lifetime Bound to Impl --------------------------------------------------
405 trait AddLifetimeBoundToImplParameter {
410 impl<T> AddLifetimeBoundToImplParameter for T {
411 fn id(self) -> Self { self }
415 #[rustc_dirty(label="Hir", cfg="cfail2")]
416 #[rustc_clean(label="Hir", cfg="cfail3")]
417 impl<T: 'static> AddLifetimeBoundToImplParameter for T {
418 #[rustc_clean(label="Hir", cfg="cfail2")]
419 #[rustc_clean(label="Hir", cfg="cfail3")]
420 fn id(self) -> Self { self }
425 // Add Trait Bound to Impl Parameter -------------------------------------------
426 trait AddTraitBoundToImplParameter {
431 impl<T> AddTraitBoundToImplParameter for T {
432 fn id(self) -> Self { self }
436 #[rustc_dirty(label="Hir", cfg="cfail2")]
437 #[rustc_clean(label="Hir", cfg="cfail3")]
438 impl<T: Clone> AddTraitBoundToImplParameter for T {
439 #[rustc_clean(label="Hir", cfg="cfail2")]
440 #[rustc_clean(label="Hir", cfg="cfail3")]
441 fn id(self) -> Self { self }
446 // Add #[no_mangle] to Method --------------------------------------------------
447 trait AddNoMangleToMethod {
448 fn add_no_mangle_to_method(&self) { }
452 impl AddNoMangleToMethod for Foo {
453 fn add_no_mangle_to_method(&self) { }
457 #[rustc_clean(label="Hir", cfg="cfail2")]
458 #[rustc_clean(label="Hir", cfg="cfail3")]
459 impl AddNoMangleToMethod for Foo {
460 #[rustc_dirty(label="Hir", cfg="cfail2")]
461 #[rustc_clean(label="Hir", cfg="cfail3")]
463 fn add_no_mangle_to_method(&self) { }
467 // Make Method #[inline] -------------------------------------------------------
468 trait MakeMethodInline {
469 fn make_method_inline(&self) -> u8 { 0 }
473 impl MakeMethodInline for Foo {
474 fn make_method_inline(&self) -> u8 { 0 }
478 #[rustc_clean(label="Hir", cfg="cfail2")]
479 #[rustc_clean(label="Hir", cfg="cfail3")]
480 impl MakeMethodInline for Foo {
481 #[rustc_dirty(label="Hir", cfg="cfail2")]
482 #[rustc_clean(label="Hir", cfg="cfail3")]
484 fn make_method_inline(&self) -> u8 { 0 }