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
16 #![feature(rustc_attrs)]
17 #![feature(specialization)]
22 // Change Method Name -----------------------------------------------------------
24 #[cfg(any(cfail1,cfail4))]
25 pub trait ChangeMethodNameTrait {
29 #[cfg(any(cfail1,cfail4))]
30 impl ChangeMethodNameTrait for Foo {
34 #[cfg(not(any(cfail1,cfail4)))]
35 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")]
36 #[rustc_clean(cfg="cfail3")]
37 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")]
38 #[rustc_clean(cfg="cfail6")]
39 pub trait ChangeMethodNameTrait {
40 #[rustc_clean(cfg="cfail3")]
41 #[rustc_clean(cfg="cfail6")]
45 #[cfg(not(any(cfail1,cfail4)))]
46 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")]
47 #[rustc_clean(cfg="cfail3")]
48 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")]
49 #[rustc_clean(cfg="cfail6")]
50 impl ChangeMethodNameTrait for Foo {
51 #[rustc_clean(cfg="cfail3")]
52 #[rustc_clean(cfg="cfail6")]
56 // Change Method Body -----------------------------------------------------------
58 // This should affect the method itself, but not the impl.
60 pub trait ChangeMethodBodyTrait {
64 #[cfg(any(cfail1,cfail4))]
65 impl ChangeMethodBodyTrait for Foo {
66 // ----------------------------------------------------------
67 // -------------------------
68 // ----------------------------------------------------------
69 // -------------------------
75 #[cfg(not(any(cfail1,cfail4)))]
76 #[rustc_clean(cfg="cfail2")]
77 #[rustc_clean(cfg="cfail3")]
78 #[rustc_clean(cfg="cfail5")]
79 #[rustc_clean(cfg="cfail6")]
80 impl ChangeMethodBodyTrait for Foo {
81 #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")]
82 #[rustc_clean(cfg="cfail3")]
83 #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail5")]
84 #[rustc_clean(cfg="cfail6")]
90 // Change Method Body (inlined fn) ---------------------------------------------
92 // This should affect the method itself, but not the impl.
94 pub trait ChangeMethodBodyTraitInlined {
98 #[cfg(any(cfail1,cfail4))]
99 impl ChangeMethodBodyTraitInlined for Foo {
100 // ------------------------------------------------------------------------
101 // -------------------------
102 // ------------------------------------------------------------------------
103 // -------------------------
110 #[cfg(not(any(cfail1,cfail4)))]
111 #[rustc_clean(cfg="cfail2")]
112 #[rustc_clean(cfg="cfail3")]
113 #[rustc_clean(cfg="cfail5")]
114 #[rustc_clean(cfg="cfail6")]
115 impl ChangeMethodBodyTraitInlined for Foo {
116 #[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir", cfg="cfail2")]
117 #[rustc_clean(cfg="cfail3")]
118 #[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir", cfg="cfail5")]
119 #[rustc_clean(cfg="cfail6")]
126 // Change Method Selfness ------------------------------------------------------
128 #[cfg(any(cfail1,cfail4))]
129 pub trait ChangeMethodSelfnessTrait {
133 #[cfg(any(cfail1,cfail4))]
134 impl ChangeMethodSelfnessTrait for Foo {
138 #[cfg(not(any(cfail1,cfail4)))]
139 pub trait ChangeMethodSelfnessTrait {
140 fn method_name(&self);
143 #[cfg(not(any(cfail1,cfail4)))]
144 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
145 #[rustc_clean(cfg="cfail3")]
146 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
147 #[rustc_clean(cfg="cfail6")]
148 impl ChangeMethodSelfnessTrait for Foo {
150 except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir",
153 #[rustc_clean(cfg="cfail3")]
155 except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir",
158 #[rustc_clean(cfg="cfail6")]
159 fn method_name(&self) {
164 // Change Method Selfness -----------------------------------------------------------
166 #[cfg(any(cfail1,cfail4))]
167 pub trait RemoveMethodSelfnessTrait {
168 fn method_name(&self);
171 #[cfg(any(cfail1,cfail4))]
172 impl RemoveMethodSelfnessTrait for Foo {
173 fn method_name(&self) { }
176 #[cfg(not(any(cfail1,cfail4)))]
177 pub trait RemoveMethodSelfnessTrait {
181 #[cfg(not(any(cfail1,cfail4)))]
182 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
183 #[rustc_clean(cfg="cfail3")]
184 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
185 #[rustc_clean(cfg="cfail6")]
186 impl RemoveMethodSelfnessTrait for Foo {
188 except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir",
191 #[rustc_clean(cfg="cfail3")]
193 except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir",
196 #[rustc_clean(cfg="cfail6")]
200 // Change Method Selfmutness -----------------------------------------------------------
202 #[cfg(any(cfail1,cfail4))]
203 pub trait ChangeMethodSelfmutnessTrait {
204 fn method_name(&self);
207 #[cfg(any(cfail1,cfail4))]
208 impl ChangeMethodSelfmutnessTrait for Foo {
209 // -----------------------------------------------------------------------------------------
210 // -------------------------
211 // -----------------------------------------------------------------------------------------
212 // -------------------------
213 fn method_name(& self) {}
216 #[cfg(not(any(cfail1,cfail4)))]
217 pub trait ChangeMethodSelfmutnessTrait {
218 fn method_name(&mut self);
221 #[cfg(not(any(cfail1,cfail4)))]
222 #[rustc_clean(cfg="cfail2")]
223 #[rustc_clean(cfg="cfail3")]
224 #[rustc_clean(cfg="cfail5")]
225 #[rustc_clean(cfg="cfail6")]
226 impl ChangeMethodSelfmutnessTrait for Foo {
227 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")]
228 #[rustc_clean(cfg="cfail3")]
229 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail5")]
230 #[rustc_clean(cfg="cfail6")]
231 fn method_name(&mut self) {}
234 // Change item kind -----------------------------------------------------------
236 #[cfg(any(cfail1,cfail4))]
237 pub trait ChangeItemKindTrait {
241 #[cfg(any(cfail1,cfail4))]
242 impl ChangeItemKindTrait for Foo {
246 #[cfg(not(any(cfail1,cfail4)))]
247 pub trait ChangeItemKindTrait {
251 #[cfg(not(any(cfail1,cfail4)))]
252 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")]
253 #[rustc_clean(cfg="cfail3")]
254 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")]
255 #[rustc_clean(cfg="cfail6")]
256 impl ChangeItemKindTrait for Foo {
260 // Remove item -----------------------------------------------------------
262 #[cfg(any(cfail1,cfail4))]
263 pub trait RemoveItemTrait {
268 #[cfg(any(cfail1,cfail4))]
269 impl RemoveItemTrait for Foo {
274 #[cfg(not(any(cfail1,cfail4)))]
275 pub trait RemoveItemTrait {
279 #[cfg(not(any(cfail1,cfail4)))]
280 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")]
281 #[rustc_clean(cfg="cfail3")]
282 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")]
283 #[rustc_clean(cfg="cfail6")]
284 impl RemoveItemTrait for Foo {
288 // Add item -----------------------------------------------------------
290 #[cfg(any(cfail1,cfail4))]
291 pub trait AddItemTrait {
295 #[cfg(any(cfail1,cfail4))]
296 impl AddItemTrait for Foo {
300 #[cfg(not(any(cfail1,cfail4)))]
301 pub trait AddItemTrait {
306 #[cfg(not(any(cfail1,cfail4)))]
307 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")]
308 #[rustc_clean(cfg="cfail3")]
309 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")]
310 #[rustc_clean(cfg="cfail6")]
311 impl AddItemTrait for Foo {
316 // Change has-value -----------------------------------------------------------
318 #[cfg(any(cfail1,cfail4))]
319 pub trait ChangeHasValueTrait {
320 //--------------------------------------------------------------
321 //--------------------------
322 //--------------------------------------------------------------
323 //--------------------------
327 #[cfg(any(cfail1,cfail4))]
328 impl ChangeHasValueTrait for Foo {
332 #[cfg(not(any(cfail1,cfail4)))]
333 #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")]
334 #[rustc_clean(cfg="cfail3")]
335 #[rustc_clean(except="hir_owner_nodes", cfg="cfail5")]
336 #[rustc_clean(cfg="cfail6")]
337 pub trait ChangeHasValueTrait {
338 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
339 #[rustc_clean(cfg="cfail3")]
340 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
341 #[rustc_clean(cfg="cfail6")]
345 #[cfg(not(any(cfail1,cfail4)))]
346 #[rustc_clean(cfg="cfail2")]
347 #[rustc_clean(cfg="cfail3")]
348 #[rustc_clean(cfg="cfail5")]
349 #[rustc_clean(cfg="cfail6")]
350 impl ChangeHasValueTrait for Foo {
356 pub trait AddDefaultTrait {
360 #[cfg(any(cfail1,cfail4))]
361 impl AddDefaultTrait for Foo {
362 // -------------------------------------------------------------
363 // -------------------------
364 // -------------------------------------------------------------
365 // -------------------------
369 #[cfg(not(any(cfail1,cfail4)))]
370 #[rustc_clean(cfg="cfail2")]
371 #[rustc_clean(cfg="cfail3")]
372 #[rustc_clean(cfg="cfail5")]
373 #[rustc_clean(cfg="cfail6")]
374 impl AddDefaultTrait for Foo {
375 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
376 #[rustc_clean(cfg="cfail3")]
377 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
378 #[rustc_clean(cfg="cfail6")]
379 default fn method_name() { }
384 #[cfg(any(cfail1,cfail4))]
385 pub trait AddArgumentTrait {
386 fn method_name(&self);
389 #[cfg(any(cfail1,cfail4))]
390 impl AddArgumentTrait for Foo {
391 // -----------------------------------------------------------------------------------------
392 // -------------------------
393 // -----------------------------------------------------------------------------------------
394 // -------------------------
395 fn method_name(&self ) { }
398 #[cfg(not(any(cfail1,cfail4)))]
399 pub trait AddArgumentTrait {
400 fn method_name(&self, x: u32);
403 #[cfg(not(any(cfail1,cfail4)))]
404 #[rustc_clean(cfg="cfail2")]
405 #[rustc_clean(cfg="cfail3")]
406 #[rustc_clean(cfg="cfail5")]
407 #[rustc_clean(cfg="cfail6")]
408 impl AddArgumentTrait for Foo {
409 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")]
410 #[rustc_clean(cfg="cfail3")]
411 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail5")]
412 #[rustc_clean(cfg="cfail6")]
413 fn method_name(&self, _x: u32) { }
416 // Change argument type
418 #[cfg(any(cfail1,cfail4))]
419 pub trait ChangeArgumentTypeTrait {
420 fn method_name(&self, x: u32);
423 #[cfg(any(cfail1,cfail4))]
424 impl ChangeArgumentTypeTrait for Foo {
425 // -----------------------------------------------------------------------------------------
426 // -------------------------
427 // -----------------------------------------------------------------------------------------
428 // -------------------------
429 fn method_name(&self, _x: u32 ) { }
432 #[cfg(not(any(cfail1,cfail4)))]
433 pub trait ChangeArgumentTypeTrait {
434 fn method_name(&self, x: char);
437 #[cfg(not(any(cfail1,cfail4)))]
438 #[rustc_clean(cfg="cfail2")]
439 #[rustc_clean(cfg="cfail3")]
440 #[rustc_clean(cfg="cfail5")]
441 #[rustc_clean(cfg="cfail6")]
442 impl ChangeArgumentTypeTrait for Foo {
443 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")]
444 #[rustc_clean(cfg="cfail3")]
445 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail5")]
446 #[rustc_clean(cfg="cfail6")]
447 fn method_name(&self, _x: char) { }
454 // Add Type Parameter To Impl --------------------------------------------------
455 trait AddTypeParameterToImpl<T> {
459 #[cfg(any(cfail1,cfail4))]
460 impl AddTypeParameterToImpl<u32> for Bar<u32> {
461 fn id(t: u32) -> u32 { t }
464 #[cfg(not(any(cfail1,cfail4)))]
465 #[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,impl_trait_ref", cfg="cfail2")]
466 #[rustc_clean(cfg="cfail3")]
467 #[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,impl_trait_ref", cfg="cfail5")]
468 #[rustc_clean(cfg="cfail6")]
469 impl<TTT> AddTypeParameterToImpl<TTT> for Bar<TTT> {
471 except="hir_owner,hir_owner_nodes,generics_of,fn_sig,type_of,typeck,optimized_mir",
474 #[rustc_clean(cfg="cfail3")]
476 except="hir_owner,hir_owner_nodes,generics_of,fn_sig,type_of,typeck,optimized_mir",
479 #[rustc_clean(cfg="cfail6")]
480 fn id(t: TTT) -> TTT { t }
485 // Change Self Type of Impl ----------------------------------------------------
486 trait ChangeSelfTypeOfImpl {
490 #[cfg(any(cfail1,cfail4))]
491 impl ChangeSelfTypeOfImpl for u32 {
492 fn id(self) -> Self { self }
495 #[cfg(not(any(cfail1,cfail4)))]
496 #[rustc_clean(except="hir_owner,hir_owner_nodes,impl_trait_ref", cfg="cfail2")]
497 #[rustc_clean(cfg="cfail3")]
498 #[rustc_clean(except="hir_owner,hir_owner_nodes,impl_trait_ref", cfg="cfail5")]
499 #[rustc_clean(cfg="cfail6")]
500 impl ChangeSelfTypeOfImpl for u64 {
501 #[rustc_clean(except="fn_sig,typeck,optimized_mir", cfg="cfail2")]
502 #[rustc_clean(cfg="cfail3")]
503 #[rustc_clean(except="fn_sig,typeck,optimized_mir", cfg="cfail5")]
504 #[rustc_clean(cfg="cfail6")]
505 fn id(self) -> Self { self }
510 // Add Lifetime Bound to Impl --------------------------------------------------
511 trait AddLifetimeBoundToImplParameter {
515 #[cfg(any(cfail1,cfail4))]
516 impl<T> AddLifetimeBoundToImplParameter for T {
517 fn id(self) -> Self { self }
520 #[cfg(not(any(cfail1,cfail4)))]
521 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
522 #[rustc_clean(cfg="cfail3")]
523 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
524 #[rustc_clean(cfg="cfail6")]
525 impl<T: 'static> AddLifetimeBoundToImplParameter for T {
526 #[rustc_clean(cfg="cfail2")]
527 #[rustc_clean(cfg="cfail3")]
528 #[rustc_clean(cfg="cfail5")]
529 #[rustc_clean(cfg="cfail6")]
530 fn id(self) -> Self { self }
535 // Add Trait Bound to Impl Parameter -------------------------------------------
536 trait AddTraitBoundToImplParameter {
540 #[cfg(any(cfail1,cfail4))]
541 impl<T> AddTraitBoundToImplParameter for T {
542 fn id(self) -> Self { self }
545 #[cfg(not(any(cfail1,cfail4)))]
546 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
547 #[rustc_clean(cfg="cfail3")]
548 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
549 #[rustc_clean(cfg="cfail6")]
550 impl<T: Clone> AddTraitBoundToImplParameter for T {
551 #[rustc_clean(cfg="cfail2")]
552 #[rustc_clean(cfg="cfail3")]
553 #[rustc_clean(cfg="cfail5")]
554 #[rustc_clean(cfg="cfail6")]
555 fn id(self) -> Self { self }
560 // Add #[no_mangle] to Method --------------------------------------------------
561 trait AddNoMangleToMethod {
562 fn add_no_mangle_to_method(&self) { }
565 #[cfg(any(cfail1,cfail4))]
566 impl AddNoMangleToMethod for Foo {
567 // -------------------------
568 // -------------------------
569 // -------------------------
570 // -------------------------
572 fn add_no_mangle_to_method(&self) { }
575 #[cfg(not(any(cfail1,cfail4)))]
576 #[rustc_clean(cfg="cfail2")]
577 #[rustc_clean(cfg="cfail3")]
578 #[rustc_clean(cfg="cfail5")]
579 #[rustc_clean(cfg="cfail6")]
580 impl AddNoMangleToMethod for Foo {
581 #[rustc_clean(cfg="cfail2")]
582 #[rustc_clean(cfg="cfail3")]
583 #[rustc_clean(cfg="cfail5")]
584 #[rustc_clean(cfg="cfail6")]
586 fn add_no_mangle_to_method(&self) { }
590 // Make Method #[inline] -------------------------------------------------------
591 trait MakeMethodInline {
592 fn make_method_inline(&self) -> u8 { 0 }
595 #[cfg(any(cfail1,cfail4))]
596 impl MakeMethodInline for Foo {
597 // -------------------------
598 // -------------------------
599 // -------------------------
600 // -------------------------
602 fn make_method_inline(&self) -> u8 { 0 }
605 #[cfg(not(any(cfail1,cfail4)))]
606 #[rustc_clean(cfg="cfail2")]
607 #[rustc_clean(cfg="cfail3")]
608 #[rustc_clean(cfg="cfail5")]
609 #[rustc_clean(cfg="cfail6")]
610 impl MakeMethodInline for Foo {
611 #[rustc_clean(cfg="cfail2")]
612 #[rustc_clean(cfg="cfail3")]
613 #[rustc_clean(cfg="cfail5")]
614 #[rustc_clean(cfg="cfail6")]
616 fn make_method_inline(&self) -> u8 { 0 }