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
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,associated_item_def_ids", cfg="cfail2")]
39 #[rustc_clean(cfg="cfail3")]
40 #[rustc_clean(except="hir_owner,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,associated_item_def_ids", cfg="cfail2")]
50 #[rustc_clean(cfg="cfail3")]
51 #[rustc_clean(except="hir_owner,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", cfg="cfail2")]
148 #[rustc_clean(cfg="cfail3")]
149 #[rustc_clean(except="hir_owner", 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", cfg="cfail2")]
186 #[rustc_clean(cfg="cfail3")]
187 #[rustc_clean(except="hir_owner", 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,associated_item_def_ids", cfg="cfail2")]
256 #[rustc_clean(cfg="cfail3")]
257 #[rustc_clean(except="hir_owner,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,associated_item_def_ids", cfg="cfail2")]
284 #[rustc_clean(cfg="cfail3")]
285 #[rustc_clean(except="hir_owner,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,associated_item_def_ids", cfg="cfail2")]
311 #[rustc_clean(cfg="cfail3")]
312 #[rustc_clean(except="hir_owner,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
{
326 #[cfg(any(cfail1,cfail4))]
327 impl ChangeHasValueTrait
for Foo
{
331 #[cfg(not(any(cfail1,cfail4)))]
332 #[rustc_clean(except="hir_owner", cfg="cfail2")]
333 #[rustc_clean(cfg="cfail3")]
334 #[rustc_clean(except="hir_owner", cfg="cfail5")]
335 #[rustc_clean(cfg="cfail6")]
336 pub trait ChangeHasValueTrait
{
337 #[rustc_clean(except="hir_owner,associated_item", cfg="cfail2")]
338 #[rustc_clean(cfg="cfail3")]
339 #[rustc_clean(except="hir_owner,associated_item", cfg="cfail5")]
340 #[rustc_clean(cfg="cfail6")]
344 #[cfg(not(any(cfail1,cfail4)))]
345 #[rustc_clean(cfg="cfail2")]
346 #[rustc_clean(cfg="cfail3")]
347 #[rustc_clean(cfg="cfail5")]
348 #[rustc_clean(cfg="cfail6")]
349 impl ChangeHasValueTrait
for Foo
{
355 pub trait AddDefaultTrait
{
359 #[cfg(any(cfail1,cfail4))]
360 impl AddDefaultTrait
for Foo
{
361 // -------------------------------------------------------------------------------------------
362 // -------------------------
366 #[cfg(not(any(cfail1,cfail4)))]
367 #[rustc_clean(except="hir_owner", cfg="cfail2")]
368 #[rustc_clean(cfg="cfail3")]
369 #[rustc_clean(except="hir_owner", cfg="cfail5")]
370 #[rustc_clean(cfg="cfail6")]
371 impl AddDefaultTrait
for Foo
{
372 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item", cfg="cfail2")]
373 #[rustc_clean(cfg="cfail3")]
374 #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item,optimized_mir", cfg="cfail5")]
375 #[rustc_clean(cfg="cfail6")]
376 default fn method_name() { }
381 #[cfg(any(cfail1,cfail4))]
382 pub trait AddArgumentTrait
{
383 fn method_name(&self);
386 #[cfg(any(cfail1,cfail4))]
387 impl AddArgumentTrait
for Foo
{
388 // -----------------------------------------------------------------------------------------
389 // -------------------------
390 // -----------------------------------------------------------------------------------------
391 // -------------------------
392 fn method_name(&self ) { }
395 #[cfg(not(any(cfail1,cfail4)))]
396 pub trait AddArgumentTrait
{
397 fn method_name(&self, x
: u32);
400 #[cfg(not(any(cfail1,cfail4)))]
401 #[rustc_clean(cfg="cfail2")]
402 #[rustc_clean(cfg="cfail3")]
403 #[rustc_clean(cfg="cfail5")]
404 #[rustc_clean(cfg="cfail6")]
405 impl AddArgumentTrait
for Foo
{
406 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")]
407 #[rustc_clean(cfg="cfail3")]
408 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail5")]
409 #[rustc_clean(cfg="cfail6")]
410 fn method_name(&self, _x
: u32) { }
413 // Change argument type
415 #[cfg(any(cfail1,cfail4))]
416 pub trait ChangeArgumentTypeTrait
{
417 fn method_name(&self, x
: u32);
420 #[cfg(any(cfail1,cfail4))]
421 impl ChangeArgumentTypeTrait
for Foo
{
422 // -----------------------------------------------------------------------------------------
423 // -------------------------
424 // -----------------------------------------------------------------------------------------
425 // -------------------------
426 fn method_name(&self, _x
: u32 ) { }
429 #[cfg(not(any(cfail1,cfail4)))]
430 pub trait ChangeArgumentTypeTrait
{
431 fn method_name(&self, x
: char);
434 #[cfg(not(any(cfail1,cfail4)))]
435 #[rustc_clean(cfg="cfail2")]
436 #[rustc_clean(cfg="cfail3")]
437 #[rustc_clean(cfg="cfail5")]
438 #[rustc_clean(cfg="cfail6")]
439 impl ChangeArgumentTypeTrait
for Foo
{
440 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")]
441 #[rustc_clean(cfg="cfail3")]
442 #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail5")]
443 #[rustc_clean(cfg="cfail6")]
444 fn method_name(&self, _x
: char) { }
451 // Add Type Parameter To Impl --------------------------------------------------
452 trait AddTypeParameterToImpl
<T
> {
456 #[cfg(any(cfail1,cfail4))]
457 impl AddTypeParameterToImpl
<u32> for Bar
<u32> {
458 fn id(t
: u32) -> u32 { t }
461 #[cfg(not(any(cfail1,cfail4)))]
462 #[rustc_clean(except="hir_owner,generics_of,impl_trait_ref", cfg="cfail2")]
463 #[rustc_clean(cfg="cfail3")]
464 #[rustc_clean(except="hir_owner,generics_of,impl_trait_ref", cfg="cfail5")]
465 #[rustc_clean(cfg="cfail6")]
466 impl<TTT
> AddTypeParameterToImpl
<TTT
> for Bar
<TTT
> {
468 except
="hir_owner,hir_owner_nodes,generics_of,fn_sig,type_of,typeck,optimized_mir",
471 #[rustc_clean(cfg="cfail3")]
473 except
="hir_owner,hir_owner_nodes,generics_of,fn_sig,type_of,typeck,optimized_mir",
476 #[rustc_clean(cfg="cfail6")]
477 fn id(t
: TTT
) -> TTT { t }
482 // Change Self Type of Impl ----------------------------------------------------
483 trait ChangeSelfTypeOfImpl
{
487 #[cfg(any(cfail1,cfail4))]
488 impl ChangeSelfTypeOfImpl
for u32 {
489 fn id(self) -> Self { self }
492 #[cfg(not(any(cfail1,cfail4)))]
493 #[rustc_clean(except="hir_owner,impl_trait_ref", cfg="cfail2")]
494 #[rustc_clean(cfg="cfail3")]
495 #[rustc_clean(except="hir_owner,impl_trait_ref", cfg="cfail5")]
496 #[rustc_clean(cfg="cfail6")]
497 impl ChangeSelfTypeOfImpl
for u64 {
498 #[rustc_clean(except="fn_sig,typeck,optimized_mir", cfg="cfail2")]
499 #[rustc_clean(cfg="cfail3")]
500 #[rustc_clean(except="fn_sig,typeck,optimized_mir", cfg="cfail5")]
501 #[rustc_clean(cfg="cfail6")]
502 fn id(self) -> Self { self }
507 // Add Lifetime Bound to Impl --------------------------------------------------
508 trait AddLifetimeBoundToImplParameter
{
512 #[cfg(any(cfail1,cfail4))]
513 impl<T
> AddLifetimeBoundToImplParameter
for T
{
514 fn id(self) -> Self { self }
517 #[cfg(not(any(cfail1,cfail4)))]
518 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
519 #[rustc_clean(cfg="cfail3")]
520 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
521 #[rustc_clean(cfg="cfail6")]
522 impl<T
: '
static> AddLifetimeBoundToImplParameter
for T
{
523 #[rustc_clean(cfg="cfail2")]
524 #[rustc_clean(cfg="cfail3")]
525 #[rustc_clean(cfg="cfail5")]
526 #[rustc_clean(cfg="cfail6")]
527 fn id(self) -> Self { self }
532 // Add Trait Bound to Impl Parameter -------------------------------------------
533 trait AddTraitBoundToImplParameter
{
537 #[cfg(any(cfail1,cfail4))]
538 impl<T
> AddTraitBoundToImplParameter
for T
{
539 fn id(self) -> Self { self }
542 #[cfg(not(any(cfail1,cfail4)))]
543 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")]
544 #[rustc_clean(cfg="cfail3")]
545 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
546 #[rustc_clean(cfg="cfail6")]
547 impl<T
: Clone
> AddTraitBoundToImplParameter
for T
{
548 #[rustc_clean(cfg="cfail2")]
549 #[rustc_clean(cfg="cfail3")]
550 #[rustc_clean(cfg="cfail5")]
551 #[rustc_clean(cfg="cfail6")]
552 fn id(self) -> Self { self }
557 // Add #[no_mangle] to Method --------------------------------------------------
558 trait AddNoMangleToMethod
{
559 fn add_no_mangle_to_method(&self) { }
562 #[cfg(any(cfail1,cfail4))]
563 impl AddNoMangleToMethod
for Foo
{
564 // -------------------------
565 // -------------------------
566 // -------------------------
567 // -------------------------
569 fn add_no_mangle_to_method(&self) { }
572 #[cfg(not(any(cfail1,cfail4)))]
573 #[rustc_clean(cfg="cfail2")]
574 #[rustc_clean(cfg="cfail3")]
575 #[rustc_clean(cfg="cfail5")]
576 #[rustc_clean(cfg="cfail6")]
577 impl AddNoMangleToMethod
for Foo
{
578 #[rustc_clean(cfg="cfail2")]
579 #[rustc_clean(cfg="cfail3")]
580 #[rustc_clean(cfg="cfail5")]
581 #[rustc_clean(cfg="cfail6")]
583 fn add_no_mangle_to_method(&self) { }
587 // Make Method #[inline] -------------------------------------------------------
588 trait MakeMethodInline
{
589 fn make_method_inline(&self) -> u8 { 0 }
592 #[cfg(any(cfail1,cfail4))]
593 impl MakeMethodInline
for Foo
{
594 // -------------------------
595 // -------------------------
596 // -------------------------
597 // -------------------------
599 fn make_method_inline(&self) -> u8 { 0 }
602 #[cfg(not(any(cfail1,cfail4)))]
603 #[rustc_clean(cfg="cfail2")]
604 #[rustc_clean(cfg="cfail3")]
605 #[rustc_clean(cfg="cfail5")]
606 #[rustc_clean(cfg="cfail6")]
607 impl MakeMethodInline
for Foo
{
608 #[rustc_clean(cfg="cfail2")]
609 #[rustc_clean(cfg="cfail3")]
610 #[rustc_clean(cfg="cfail5")]
611 #[rustc_clean(cfg="cfail6")]
613 fn make_method_inline(&self) -> u8 { 0 }