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.
8 // build-pass (FIXME(62277): could be check-pass?)
9 // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
10 // compile-flags: -Z query-dep-graph -O
11 // [cfail1]compile-flags: -Zincremental-ignore-spans
12 // [cfail2]compile-flags: -Zincremental-ignore-spans
13 // [cfail3]compile-flags: -Zincremental-ignore-spans
14 // [cfail4]compile-flags: -Zincremental-relative-spans
15 // [cfail5]compile-flags: -Zincremental-relative-spans
16 // [cfail6]compile-flags: -Zincremental-relative-spans
19 #![feature(rustc_attrs)]
20 #![feature(specialization)]
25 // Change Method Name -----------------------------------------------------------
27 #[cfg(any(cfail1,cfail4))]
28 pub trait ChangeMethodNameTrait {
32 #[cfg(any(cfail1,cfail4))]
33 impl ChangeMethodNameTrait for Foo {
37 #[cfg(not(any(cfail1,cfail4)))]
38 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")]
39 #[rustc_clean(cfg="cfail3")]
40 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")]
41 #[rustc_clean(cfg="cfail6")]
42 pub trait ChangeMethodNameTrait {
43 #[rustc_clean(cfg="cfail3")]
44 #[rustc_clean(cfg="cfail6")]
48 #[cfg(not(any(cfail1,cfail4)))]
49 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")]
50 #[rustc_clean(cfg="cfail3")]
51 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")]
52 #[rustc_clean(cfg="cfail6")]
53 impl ChangeMethodNameTrait for Foo {
54 #[rustc_clean(cfg="cfail3")]
55 #[rustc_clean(cfg="cfail6")]
59 // Change Method Body -----------------------------------------------------------
61 // This should affect the method itself, but not the impl.
63 pub trait ChangeMethodBodyTrait {
67 #[cfg(any(cfail1,cfail4))]
68 impl ChangeMethodBodyTrait for Foo {
69 // ----------------------------------------------------------
70 // -------------------------
71 // ----------------------------------------------------------
72 // -------------------------
78 #[cfg(not(any(cfail1,cfail4)))]
79 #[rustc_clean(cfg="cfail2")]
80 #[rustc_clean(cfg="cfail3")]
81 #[rustc_clean(cfg="cfail5")]
82 #[rustc_clean(cfg="cfail6")]
83 impl ChangeMethodBodyTrait for Foo {
84 #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")]
85 #[rustc_clean(cfg="cfail3")]
86 #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail5")]
87 #[rustc_clean(cfg="cfail6")]
93 // Change Method Body (inlined fn) ---------------------------------------------
95 // This should affect the method itself, but not the impl.
97 pub trait ChangeMethodBodyTraitInlined {
101 #[cfg(any(cfail1,cfail4))]
102 impl ChangeMethodBodyTraitInlined for Foo {
103 // ------------------------------------------------------------------------
104 // -------------------------
105 // ------------------------------------------------------------------------
106 // -------------------------
113 #[cfg(not(any(cfail1,cfail4)))]
114 #[rustc_clean(cfg="cfail2")]
115 #[rustc_clean(cfg="cfail3")]
116 #[rustc_clean(cfg="cfail5")]
117 #[rustc_clean(cfg="cfail6")]
118 impl ChangeMethodBodyTraitInlined for Foo {
119 #[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir", cfg="cfail2")]
120 #[rustc_clean(cfg="cfail3")]
121 #[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir", cfg="cfail5")]
122 #[rustc_clean(cfg="cfail6")]
129 // Change Method Selfness ------------------------------------------------------
131 #[cfg(any(cfail1,cfail4))]
132 pub trait ChangeMethodSelfnessTrait {
136 #[cfg(any(cfail1,cfail4))]
137 impl ChangeMethodSelfnessTrait for Foo {
141 #[cfg(not(any(cfail1,cfail4)))]
142 pub trait ChangeMethodSelfnessTrait {
143 fn method_name(&self);
146 #[cfg(not(any(cfail1,cfail4)))]
147 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
148 #[rustc_clean(cfg="cfail3")]
149 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
150 #[rustc_clean(cfg="cfail6")]
151 impl ChangeMethodSelfnessTrait for Foo {
153 except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir",
156 #[rustc_clean(cfg="cfail3")]
158 except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir",
161 #[rustc_clean(cfg="cfail6")]
162 fn method_name(&self) {
167 // Change Method Selfness -----------------------------------------------------------
169 #[cfg(any(cfail1,cfail4))]
170 pub trait RemoveMethodSelfnessTrait {
171 fn method_name(&self);
174 #[cfg(any(cfail1,cfail4))]
175 impl RemoveMethodSelfnessTrait for Foo {
176 fn method_name(&self) { }
179 #[cfg(not(any(cfail1,cfail4)))]
180 pub trait RemoveMethodSelfnessTrait {
184 #[cfg(not(any(cfail1,cfail4)))]
185 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
186 #[rustc_clean(cfg="cfail3")]
187 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
188 #[rustc_clean(cfg="cfail6")]
189 impl RemoveMethodSelfnessTrait for Foo {
191 except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir",
194 #[rustc_clean(cfg="cfail3")]
196 except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir",
199 #[rustc_clean(cfg="cfail6")]
203 // Change Method Selfmutness -----------------------------------------------------------
205 #[cfg(any(cfail1,cfail4))]
206 pub trait ChangeMethodSelfmutnessTrait {
207 fn method_name(&self);
210 #[cfg(any(cfail1,cfail4))]
211 impl ChangeMethodSelfmutnessTrait for Foo {
212 // -----------------------------------------------------------------------------------------
213 // -------------------------
214 // -----------------------------------------------------------------------------------------
215 // -------------------------
216 fn method_name(& self) {}
219 #[cfg(not(any(cfail1,cfail4)))]
220 pub trait ChangeMethodSelfmutnessTrait {
221 fn method_name(&mut self);
224 #[cfg(not(any(cfail1,cfail4)))]
225 #[rustc_clean(cfg="cfail2")]
226 #[rustc_clean(cfg="cfail3")]
227 #[rustc_clean(cfg="cfail5")]
228 #[rustc_clean(cfg="cfail6")]
229 impl ChangeMethodSelfmutnessTrait for Foo {
230 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")]
231 #[rustc_clean(cfg="cfail3")]
232 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail5")]
233 #[rustc_clean(cfg="cfail6")]
234 fn method_name(&mut self) {}
237 // Change item kind -----------------------------------------------------------
239 #[cfg(any(cfail1,cfail4))]
240 pub trait ChangeItemKindTrait {
244 #[cfg(any(cfail1,cfail4))]
245 impl ChangeItemKindTrait for Foo {
249 #[cfg(not(any(cfail1,cfail4)))]
250 pub trait ChangeItemKindTrait {
254 #[cfg(not(any(cfail1,cfail4)))]
255 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")]
256 #[rustc_clean(cfg="cfail3")]
257 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")]
258 #[rustc_clean(cfg="cfail6")]
259 impl ChangeItemKindTrait for Foo {
263 // Remove item -----------------------------------------------------------
265 #[cfg(any(cfail1,cfail4))]
266 pub trait RemoveItemTrait {
271 #[cfg(any(cfail1,cfail4))]
272 impl RemoveItemTrait for Foo {
277 #[cfg(not(any(cfail1,cfail4)))]
278 pub trait RemoveItemTrait {
282 #[cfg(not(any(cfail1,cfail4)))]
283 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")]
284 #[rustc_clean(cfg="cfail3")]
285 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")]
286 #[rustc_clean(cfg="cfail6")]
287 impl RemoveItemTrait for Foo {
291 // Add item -----------------------------------------------------------
293 #[cfg(any(cfail1,cfail4))]
294 pub trait AddItemTrait {
298 #[cfg(any(cfail1,cfail4))]
299 impl AddItemTrait for Foo {
303 #[cfg(not(any(cfail1,cfail4)))]
304 pub trait AddItemTrait {
309 #[cfg(not(any(cfail1,cfail4)))]
310 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")]
311 #[rustc_clean(cfg="cfail3")]
312 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")]
313 #[rustc_clean(cfg="cfail6")]
314 impl AddItemTrait for Foo {
319 // Change has-value -----------------------------------------------------------
321 #[cfg(any(cfail1,cfail4))]
322 pub trait ChangeHasValueTrait {
323 //--------------------------------------------------------------
324 //--------------------------
325 //--------------------------------------------------------------
326 //--------------------------
330 #[cfg(any(cfail1,cfail4))]
331 impl ChangeHasValueTrait for Foo {
335 #[cfg(not(any(cfail1,cfail4)))]
336 #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")]
337 #[rustc_clean(cfg="cfail3")]
338 #[rustc_clean(except="hir_owner_nodes", cfg="cfail5")]
339 #[rustc_clean(cfg="cfail6")]
340 pub trait ChangeHasValueTrait {
341 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
342 #[rustc_clean(cfg="cfail3")]
343 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
344 #[rustc_clean(cfg="cfail6")]
348 #[cfg(not(any(cfail1,cfail4)))]
349 #[rustc_clean(cfg="cfail2")]
350 #[rustc_clean(cfg="cfail3")]
351 #[rustc_clean(cfg="cfail5")]
352 #[rustc_clean(cfg="cfail6")]
353 impl ChangeHasValueTrait for Foo {
359 pub trait AddDefaultTrait {
363 #[cfg(any(cfail1,cfail4))]
364 impl AddDefaultTrait for Foo {
365 // -------------------------------------------------------------
366 // -------------------------
367 // -------------------------------------------------------------
368 // -------------------------
372 #[cfg(not(any(cfail1,cfail4)))]
373 #[rustc_clean(cfg="cfail2")]
374 #[rustc_clean(cfg="cfail3")]
375 #[rustc_clean(cfg="cfail5")]
376 #[rustc_clean(cfg="cfail6")]
377 impl AddDefaultTrait for Foo {
378 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
379 #[rustc_clean(cfg="cfail3")]
380 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
381 #[rustc_clean(cfg="cfail6")]
382 default fn method_name() { }
387 #[cfg(any(cfail1,cfail4))]
388 pub trait AddArgumentTrait {
389 fn method_name(&self);
392 #[cfg(any(cfail1,cfail4))]
393 impl AddArgumentTrait for Foo {
394 // -----------------------------------------------------------------------------------------
395 // -------------------------
396 // -----------------------------------------------------------------------------------------
397 // -------------------------
398 fn method_name(&self ) { }
401 #[cfg(not(any(cfail1,cfail4)))]
402 pub trait AddArgumentTrait {
403 fn method_name(&self, x: u32);
406 #[cfg(not(any(cfail1,cfail4)))]
407 #[rustc_clean(cfg="cfail2")]
408 #[rustc_clean(cfg="cfail3")]
409 #[rustc_clean(cfg="cfail5")]
410 #[rustc_clean(cfg="cfail6")]
411 impl AddArgumentTrait for Foo {
412 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")]
413 #[rustc_clean(cfg="cfail3")]
414 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail5")]
415 #[rustc_clean(cfg="cfail6")]
416 fn method_name(&self, _x: u32) { }
419 // Change argument type
421 #[cfg(any(cfail1,cfail4))]
422 pub trait ChangeArgumentTypeTrait {
423 fn method_name(&self, x: u32);
426 #[cfg(any(cfail1,cfail4))]
427 impl ChangeArgumentTypeTrait for Foo {
428 // -----------------------------------------------------------------------------------------
429 // -------------------------
430 // -----------------------------------------------------------------------------------------
431 // -------------------------
432 fn method_name(&self, _x: u32 ) { }
435 #[cfg(not(any(cfail1,cfail4)))]
436 pub trait ChangeArgumentTypeTrait {
437 fn method_name(&self, x: char);
440 #[cfg(not(any(cfail1,cfail4)))]
441 #[rustc_clean(cfg="cfail2")]
442 #[rustc_clean(cfg="cfail3")]
443 #[rustc_clean(cfg="cfail5")]
444 #[rustc_clean(cfg="cfail6")]
445 impl ChangeArgumentTypeTrait for Foo {
446 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")]
447 #[rustc_clean(cfg="cfail3")]
448 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail5")]
449 #[rustc_clean(cfg="cfail6")]
450 fn method_name(&self, _x: char) { }
457 // Add Type Parameter To Impl --------------------------------------------------
458 trait AddTypeParameterToImpl<T> {
462 #[cfg(any(cfail1,cfail4))]
463 impl AddTypeParameterToImpl<u32> for Bar<u32> {
464 fn id(t: u32) -> u32 { t }
467 #[cfg(not(any(cfail1,cfail4)))]
468 #[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,impl_trait_ref", cfg="cfail2")]
469 #[rustc_clean(cfg="cfail3")]
470 #[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,impl_trait_ref", cfg="cfail5")]
471 #[rustc_clean(cfg="cfail6")]
472 impl<TTT> AddTypeParameterToImpl<TTT> for Bar<TTT> {
474 except="hir_owner,hir_owner_nodes,generics_of,fn_sig,type_of,typeck,optimized_mir",
477 #[rustc_clean(cfg="cfail3")]
479 except="hir_owner,hir_owner_nodes,generics_of,fn_sig,type_of,typeck,optimized_mir",
482 #[rustc_clean(cfg="cfail6")]
483 fn id(t: TTT) -> TTT { t }
488 // Change Self Type of Impl ----------------------------------------------------
489 trait ChangeSelfTypeOfImpl {
493 #[cfg(any(cfail1,cfail4))]
494 impl ChangeSelfTypeOfImpl for u32 {
495 fn id(self) -> Self { self }
498 #[cfg(not(any(cfail1,cfail4)))]
499 #[rustc_clean(except="hir_owner,hir_owner_nodes,impl_trait_ref", cfg="cfail2")]
500 #[rustc_clean(cfg="cfail3")]
501 #[rustc_clean(except="hir_owner,hir_owner_nodes,impl_trait_ref", cfg="cfail5")]
502 #[rustc_clean(cfg="cfail6")]
503 impl ChangeSelfTypeOfImpl for u64 {
504 #[rustc_clean(except="fn_sig,typeck,optimized_mir", cfg="cfail2")]
505 #[rustc_clean(cfg="cfail3")]
506 #[rustc_clean(except="fn_sig,typeck,optimized_mir", cfg="cfail5")]
507 #[rustc_clean(cfg="cfail6")]
508 fn id(self) -> Self { self }
513 // Add Lifetime Bound to Impl --------------------------------------------------
514 trait AddLifetimeBoundToImplParameter {
518 #[cfg(any(cfail1,cfail4))]
519 impl<T> AddLifetimeBoundToImplParameter for T {
520 fn id(self) -> Self { self }
523 #[cfg(not(any(cfail1,cfail4)))]
524 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
525 #[rustc_clean(cfg="cfail3")]
526 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
527 #[rustc_clean(cfg="cfail6")]
528 impl<T: 'static> AddLifetimeBoundToImplParameter for T {
529 #[rustc_clean(cfg="cfail2")]
530 #[rustc_clean(cfg="cfail3")]
531 #[rustc_clean(cfg="cfail5")]
532 #[rustc_clean(cfg="cfail6")]
533 fn id(self) -> Self { self }
538 // Add Trait Bound to Impl Parameter -------------------------------------------
539 trait AddTraitBoundToImplParameter {
543 #[cfg(any(cfail1,cfail4))]
544 impl<T> AddTraitBoundToImplParameter for T {
545 fn id(self) -> Self { self }
548 #[cfg(not(any(cfail1,cfail4)))]
549 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
550 #[rustc_clean(cfg="cfail3")]
551 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
552 #[rustc_clean(cfg="cfail6")]
553 impl<T: Clone> AddTraitBoundToImplParameter for T {
554 #[rustc_clean(cfg="cfail2")]
555 #[rustc_clean(cfg="cfail3")]
556 #[rustc_clean(cfg="cfail5")]
557 #[rustc_clean(cfg="cfail6")]
558 fn id(self) -> Self { self }
563 // Add #[no_mangle] to Method --------------------------------------------------
564 trait AddNoMangleToMethod {
565 fn add_no_mangle_to_method(&self) { }
568 #[cfg(any(cfail1,cfail4))]
569 impl AddNoMangleToMethod for Foo {
570 // -------------------------
571 // -------------------------
572 // -------------------------
573 // -------------------------
575 fn add_no_mangle_to_method(&self) { }
578 #[cfg(not(any(cfail1,cfail4)))]
579 #[rustc_clean(cfg="cfail2")]
580 #[rustc_clean(cfg="cfail3")]
581 #[rustc_clean(cfg="cfail5")]
582 #[rustc_clean(cfg="cfail6")]
583 impl AddNoMangleToMethod for Foo {
584 #[rustc_clean(cfg="cfail2")]
585 #[rustc_clean(cfg="cfail3")]
586 #[rustc_clean(cfg="cfail5")]
587 #[rustc_clean(cfg="cfail6")]
589 fn add_no_mangle_to_method(&self) { }
593 // Make Method #[inline] -------------------------------------------------------
594 trait MakeMethodInline {
595 fn make_method_inline(&self) -> u8 { 0 }
598 #[cfg(any(cfail1,cfail4))]
599 impl MakeMethodInline for Foo {
600 // -------------------------
601 // -------------------------
602 // -------------------------
603 // -------------------------
605 fn make_method_inline(&self) -> u8 { 0 }
608 #[cfg(not(any(cfail1,cfail4)))]
609 #[rustc_clean(cfg="cfail2")]
610 #[rustc_clean(cfg="cfail3")]
611 #[rustc_clean(cfg="cfail5")]
612 #[rustc_clean(cfg="cfail6")]
613 impl MakeMethodInline for Foo {
614 #[rustc_clean(cfg="cfail2")]
615 #[rustc_clean(cfg="cfail3")]
616 #[rustc_clean(cfg="cfail5")]
617 #[rustc_clean(cfg="cfail6")]
619 fn make_method_inline(&self) -> u8 { 0 }