]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/trait_defs.rs
Fix feature gate checking of static-nobundle and native_link_modifiers
[rust.git] / src / test / incremental / hashes / trait_defs.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for trait definitions.
3
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.
7
8 // We also test the ICH for trait definitions exported in metadata. Same as
9 // above, we want to make sure that the change between rev1 and rev2 also
10 // results in a change of the ICH for the trait's metadata, and that it stays
11 // the same between rev2 and rev3.
12
13 // build-pass (FIXME(62277): could be check-pass?)
14 // revisions: cfail1 cfail2 cfail3
15 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
16
17 #![allow(warnings)]
18 #![feature(rustc_attrs)]
19 #![crate_type="rlib"]
20 #![feature(associated_type_defaults)]
21
22
23 // Change trait visibility
24 #[cfg(cfail1)]
25 trait TraitVisibility { }
26
27 #[cfg(not(cfail1))]
28 #[rustc_clean(except="hir_owner", cfg="cfail2")]
29 #[rustc_clean(cfg="cfail3")]
30 pub trait TraitVisibility { }
31
32
33
34 // Change trait unsafety
35 #[cfg(cfail1)]
36 trait TraitUnsafety { }
37
38 #[cfg(not(cfail1))]
39 #[rustc_clean(except="hir_owner", cfg="cfail2")]
40 #[rustc_clean(cfg="cfail3")]
41 unsafe trait TraitUnsafety { }
42
43
44
45 // Add method
46 #[cfg(cfail1)]
47 trait TraitAddMethod {
48 }
49
50 #[cfg(not(cfail1))]
51 #[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")]
52 #[rustc_clean(cfg="cfail3")]
53 pub trait TraitAddMethod {
54     fn method();
55 }
56
57
58
59 // Change name of method
60 #[cfg(cfail1)]
61 trait TraitChangeMethodName {
62     fn method();
63 }
64
65 #[cfg(not(cfail1))]
66 #[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")]
67 #[rustc_clean(cfg="cfail3")]
68 trait TraitChangeMethodName {
69     fn methodChanged();
70 }
71
72
73
74 // Add return type to method
75 #[cfg(cfail1)]
76 trait TraitAddReturnType {
77     fn method();
78 }
79
80 #[cfg(not(cfail1))]
81 #[rustc_clean(cfg="cfail2")]
82 #[rustc_clean(cfg="cfail3")]
83 trait TraitAddReturnType {
84     #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")]
85     #[rustc_clean(cfg="cfail3")]
86     fn method() -> u32;
87 }
88
89
90
91 // Change return type of method
92 #[cfg(cfail1)]
93 trait TraitChangeReturnType {
94     fn method() -> u32;
95 }
96
97 #[cfg(not(cfail1))]
98 #[rustc_clean(cfg="cfail2")]
99 #[rustc_clean(cfg="cfail3")]
100 trait TraitChangeReturnType {
101     #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig", cfg="cfail2")]
102     #[rustc_clean(cfg="cfail3")]
103     fn method() -> u64;
104 }
105
106
107
108 // Add parameter to method
109 #[cfg(cfail1)]
110 trait TraitAddParameterToMethod {
111     fn method();
112 }
113
114 #[cfg(not(cfail1))]
115 #[rustc_clean(cfg="cfail2")]
116 #[rustc_clean(cfg="cfail3")]
117 trait TraitAddParameterToMethod {
118     #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")]
119     #[rustc_clean(cfg="cfail3")]
120     fn method(a: u32);
121 }
122
123
124
125 // Change name of method parameter
126 #[cfg(cfail1)]
127 trait TraitChangeMethodParameterName {
128     fn method(a: u32);
129     fn with_default(x: i32) {}
130 }
131
132 #[cfg(not(cfail1))]
133 #[rustc_clean(cfg="cfail2")]
134 #[rustc_clean(cfg="cfail3")]
135 trait TraitChangeMethodParameterName {
136     // FIXME(#38501) This should preferably always be clean.
137     #[rustc_clean(except="hir_owner", cfg="cfail2")]
138     #[rustc_clean(cfg="cfail3")]
139     fn method(b: u32);
140
141     #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")]
142     #[rustc_clean(cfg="cfail3")]
143     fn with_default(y: i32) {}
144 }
145
146
147
148 // Change type of method parameter (i32 => i64)
149 #[cfg(cfail1)]
150 trait TraitChangeMethodParameterType {
151     fn method(a: i32);
152 }
153
154 #[cfg(not(cfail1))]
155 #[rustc_clean(cfg="cfail2")]
156 #[rustc_clean(cfg="cfail3")]
157 trait TraitChangeMethodParameterType {
158     #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")]
159     #[rustc_clean(cfg="cfail3")]
160     fn method(a: i64);
161 }
162
163
164
165 // Change type of method parameter (&i32 => &mut i32)
166 #[cfg(cfail1)]
167 trait TraitChangeMethodParameterTypeRef {
168     fn method(a: &i32);
169 }
170
171 #[cfg(not(cfail1))]
172 #[rustc_clean(cfg="cfail2")]
173 #[rustc_clean(cfg="cfail3")]
174 trait TraitChangeMethodParameterTypeRef {
175     #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")]
176     #[rustc_clean(cfg="cfail3")]
177     fn method(a: &mut i32);
178 }
179
180
181
182 // Change order of method parameters
183 #[cfg(cfail1)]
184 trait TraitChangeMethodParametersOrder {
185     fn method(a: i32, b: i64);
186 }
187
188 #[cfg(not(cfail1))]
189 #[rustc_clean(cfg="cfail2")]
190 #[rustc_clean(cfg="cfail3")]
191 trait TraitChangeMethodParametersOrder {
192     #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")]
193     #[rustc_clean(cfg="cfail3")]
194     fn method(b: i64, a: i32);
195 }
196
197
198
199 // Add default implementation to method
200 #[cfg(cfail1)]
201 trait TraitAddMethodAutoImplementation {
202     fn method();
203 }
204
205 #[cfg(not(cfail1))]
206 #[rustc_clean(except="hir_owner", cfg="cfail2")]
207 #[rustc_clean(cfg="cfail3")]
208 trait TraitAddMethodAutoImplementation {
209     #[rustc_clean(except="hir_owner,associated_item", cfg="cfail2")]
210     #[rustc_clean(cfg="cfail3")]
211     fn method() { }
212 }
213
214
215
216 // Change order of methods
217 #[cfg(cfail1)]
218 trait TraitChangeOrderOfMethods {
219     fn method0();
220     fn method1();
221 }
222
223 #[cfg(not(cfail1))]
224 #[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")]
225 #[rustc_clean(cfg="cfail3")]
226 trait TraitChangeOrderOfMethods {
227     fn method1();
228     fn method0();
229 }
230
231
232
233 // Change mode of self parameter
234 #[cfg(cfail1)]
235 trait TraitChangeModeSelfRefToMut {
236     fn method(&self);
237 }
238
239 #[cfg(not(cfail1))]
240 #[rustc_clean(cfg="cfail2")]
241 #[rustc_clean(cfg="cfail3")]
242 trait TraitChangeModeSelfRefToMut {
243     #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")]
244     #[rustc_clean(cfg="cfail3")]
245     fn method(&mut self);
246 }
247
248
249
250 #[cfg(cfail1)]
251 trait TraitChangeModeSelfOwnToMut: Sized {
252     fn method(self) {}
253 }
254
255 #[cfg(not(cfail1))]
256 #[rustc_clean(cfg="cfail2")]
257 #[rustc_clean(cfg="cfail3")]
258 trait TraitChangeModeSelfOwnToMut: Sized {
259     #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck,optimized_mir", cfg="cfail2")]
260     #[rustc_clean(cfg="cfail3")]
261     fn method(mut self) {}
262 }
263
264
265
266 #[cfg(cfail1)]
267 trait TraitChangeModeSelfOwnToRef {
268     fn method(self);
269 }
270
271 #[cfg(not(cfail1))]
272 #[rustc_clean(cfg="cfail2")]
273 #[rustc_clean(cfg="cfail3")]
274 trait TraitChangeModeSelfOwnToRef {
275     #[rustc_clean(except="hir_owner,fn_sig,generics_of", cfg="cfail2")]
276     #[rustc_clean(cfg="cfail3")]
277     fn method(&self);
278 }
279
280
281
282 // Add unsafe modifier to method
283 #[cfg(cfail1)]
284 trait TraitAddUnsafeModifier {
285     fn method();
286 }
287
288 #[cfg(not(cfail1))]
289 #[rustc_clean(cfg="cfail2")]
290 #[rustc_clean(cfg="cfail3")]
291 trait TraitAddUnsafeModifier {
292     #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")]
293     #[rustc_clean(cfg="cfail3")]
294     unsafe fn method();
295 }
296
297
298
299 // Add extern modifier to method
300 #[cfg(cfail1)]
301 trait TraitAddExternModifier {
302     fn method();
303 }
304
305 #[cfg(not(cfail1))]
306 #[rustc_clean(cfg="cfail2")]
307 #[rustc_clean(cfg="cfail3")]
308 trait TraitAddExternModifier {
309     #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")]
310     #[rustc_clean(cfg="cfail3")]
311     extern "C" fn method();
312 }
313
314
315
316 // Change extern "C" to extern "stdcall"
317 #[cfg(cfail1)]
318 trait TraitChangeExternCToRustIntrinsic {
319     extern "C" fn method();
320 }
321
322 #[cfg(not(cfail1))]
323 #[rustc_clean(cfg="cfail2")]
324 #[rustc_clean(cfg="cfail3")]
325 trait TraitChangeExternCToRustIntrinsic {
326     #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")]
327     #[rustc_clean(cfg="cfail3")]
328     extern "stdcall" fn method();
329 }
330
331
332
333 // Add type parameter to method
334 #[cfg(cfail1)]
335 trait TraitAddTypeParameterToMethod {
336     fn method();
337 }
338
339 #[cfg(not(cfail1))]
340 #[rustc_clean(cfg="cfail2")]
341 #[rustc_clean(cfg="cfail3")]
342 trait TraitAddTypeParameterToMethod {
343     #[rustc_clean(except="hir_owner,generics_of,predicates_of,type_of", cfg="cfail2")]
344     #[rustc_clean(cfg="cfail3")]
345     fn method<T>();
346 }
347
348
349
350 // Add lifetime parameter to method
351 #[cfg(cfail1)]
352 trait TraitAddLifetimeParameterToMethod {
353     fn method();
354 }
355
356 #[cfg(not(cfail1))]
357 #[rustc_clean(cfg="cfail2")]
358 #[rustc_clean(cfg="cfail3")]
359 trait TraitAddLifetimeParameterToMethod {
360     #[rustc_clean(except="hir_owner,fn_sig,generics_of", cfg="cfail2")]
361     #[rustc_clean(cfg="cfail3")]
362     fn method<'a>();
363 }
364
365
366
367 // dummy trait for bound
368 trait ReferencedTrait0 { }
369 trait ReferencedTrait1 { }
370
371 // Add trait bound to method type parameter
372 #[cfg(cfail1)]
373 trait TraitAddTraitBoundToMethodTypeParameter {
374     fn method<T>();
375 }
376
377 #[cfg(not(cfail1))]
378 #[rustc_clean(cfg="cfail2")]
379 #[rustc_clean(cfg="cfail3")]
380 trait TraitAddTraitBoundToMethodTypeParameter {
381     #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
382     #[rustc_clean(cfg="cfail3")]
383     fn method<T: ReferencedTrait0>();
384 }
385
386
387
388 // Add builtin bound to method type parameter
389 #[cfg(cfail1)]
390 trait TraitAddBuiltinBoundToMethodTypeParameter {
391     fn method<T>();
392 }
393
394 #[cfg(not(cfail1))]
395 #[rustc_clean(cfg="cfail2")]
396 #[rustc_clean(cfg="cfail3")]
397 trait TraitAddBuiltinBoundToMethodTypeParameter {
398     #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
399     #[rustc_clean(cfg="cfail3")]
400     fn method<T: Sized>();
401 }
402
403
404
405 // Add lifetime bound to method lifetime parameter
406 #[cfg(cfail1)]
407 trait TraitAddLifetimeBoundToMethodLifetimeParameter {
408     fn method<'a, 'b>(a: &'a u32, b: &'b u32);
409 }
410
411 #[cfg(not(cfail1))]
412 #[rustc_clean(cfg="cfail2")]
413 #[rustc_clean(cfg="cfail3")]
414 trait TraitAddLifetimeBoundToMethodLifetimeParameter {
415     #[rustc_clean(
416         except="hir_owner,hir_owner_nodes,generics_of,predicates_of,fn_sig,type_of",
417         cfg="cfail2",
418     )]
419     #[rustc_clean(cfg="cfail3")]
420     fn method<'a, 'b: 'a>(a: &'a u32, b: &'b u32);
421 }
422
423
424
425 // Add second trait bound to method type parameter
426 #[cfg(cfail1)]
427 trait TraitAddSecondTraitBoundToMethodTypeParameter {
428     fn method<T: ReferencedTrait0>();
429 }
430
431 #[cfg(not(cfail1))]
432 #[rustc_clean(cfg="cfail2")]
433 #[rustc_clean(cfg="cfail3")]
434 trait TraitAddSecondTraitBoundToMethodTypeParameter {
435     #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
436     #[rustc_clean(cfg="cfail3")]
437     fn method<T: ReferencedTrait0 + ReferencedTrait1>();
438 }
439
440
441
442 // Add second builtin bound to method type parameter
443 #[cfg(cfail1)]
444 trait TraitAddSecondBuiltinBoundToMethodTypeParameter {
445     fn method<T: Sized>();
446 }
447
448 #[cfg(not(cfail1))]
449 #[rustc_clean(cfg="cfail2")]
450 #[rustc_clean(cfg="cfail3")]
451 trait TraitAddSecondBuiltinBoundToMethodTypeParameter {
452     #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
453     #[rustc_clean(cfg="cfail3")]
454     fn method<T: Sized + Sync>();
455 }
456
457
458
459 // Add second lifetime bound to method lifetime parameter
460 #[cfg(cfail1)]
461 trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter {
462     fn method<'a, 'b, 'c: 'a>(a: &'a u32, b: &'b u32, c: &'c u32);
463 }
464
465 #[cfg(not(cfail1))]
466 #[rustc_clean(cfg="cfail2")]
467 #[rustc_clean(cfg="cfail3")]
468 trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter {
469     #[rustc_clean(
470         except="hir_owner,hir_owner_nodes,generics_of,predicates_of,fn_sig,type_of",
471         cfg="cfail2",
472     )]
473     #[rustc_clean(cfg="cfail3")]
474     fn method<'a, 'b, 'c: 'a + 'b>(a: &'a u32, b: &'b u32, c: &'c u32);
475 }
476
477
478
479 // Add associated type
480 #[cfg(cfail1)]
481 trait TraitAddAssociatedType {
482
483     #[rustc_clean(except="hir_owner", cfg="cfail2")]
484     #[rustc_clean(cfg="cfail3")]
485     fn method();
486 }
487
488 #[cfg(not(cfail1))]
489 #[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")]
490 #[rustc_clean(cfg="cfail3")]
491 trait TraitAddAssociatedType {
492     type Associated;
493
494     fn method();
495 }
496
497
498
499 // Add trait bound to associated type
500 #[cfg(cfail1)]
501 trait TraitAddTraitBoundToAssociatedType {
502     type Associated;
503
504     fn method();
505 }
506
507
508 // Apparently the type bound contributes to the predicates of the trait, but
509 // does not change the associated item itself.
510 #[cfg(not(cfail1))]
511 #[rustc_clean(cfg="cfail2")]
512 #[rustc_clean(cfg="cfail3")]
513 trait TraitAddTraitBoundToAssociatedType {
514     #[rustc_clean(except="hir_owner", cfg="cfail2")]
515     #[rustc_clean(cfg="cfail3")]
516     type Associated: ReferencedTrait0;
517
518     fn method();
519 }
520
521
522
523 // Add lifetime bound to associated type
524 #[cfg(cfail1)]
525 trait TraitAddLifetimeBoundToAssociatedType<'a> {
526     type Associated;
527
528     fn method();
529 }
530
531 #[cfg(not(cfail1))]
532 #[rustc_clean(cfg="cfail2")]
533 #[rustc_clean(cfg="cfail3")]
534 trait TraitAddLifetimeBoundToAssociatedType<'a> {
535     #[rustc_clean(except="hir_owner", cfg="cfail2")]
536     #[rustc_clean(cfg="cfail3")]
537     type Associated: 'a;
538
539     fn method();
540 }
541
542
543
544 // Add default to associated type
545 #[cfg(cfail1)]
546 trait TraitAddDefaultToAssociatedType {
547     type Associated;
548
549     fn method();
550 }
551
552 #[cfg(not(cfail1))]
553 #[rustc_clean(except="hir_owner", cfg="cfail2")]
554 #[rustc_clean(cfg="cfail3")]
555 trait TraitAddDefaultToAssociatedType {
556     #[rustc_clean(except="hir_owner,associated_item", cfg="cfail2")]
557     #[rustc_clean(cfg="cfail3")]
558     type Associated = ReferenceType0;
559
560     fn method();
561 }
562
563
564
565 // Add associated constant
566 #[cfg(cfail1)]
567 trait TraitAddAssociatedConstant {
568     fn method();
569 }
570
571 #[cfg(not(cfail1))]
572 #[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")]
573 #[rustc_clean(cfg="cfail3")]
574 trait TraitAddAssociatedConstant {
575     const Value: u32;
576
577     fn method();
578 }
579
580
581
582 // Add initializer to associated constant
583 #[cfg(cfail1)]
584 trait TraitAddInitializerToAssociatedConstant {
585     const Value: u32;
586
587     fn method();
588 }
589
590 #[cfg(not(cfail1))]
591 #[rustc_clean(except="hir_owner", cfg="cfail2")]
592 #[rustc_clean(cfg="cfail3")]
593 trait TraitAddInitializerToAssociatedConstant {
594     #[rustc_clean(except="hir_owner,associated_item", cfg="cfail2")]
595     #[rustc_clean(cfg="cfail3")]
596     const Value: u32 = 1;
597
598     #[rustc_clean(cfg="cfail2")]
599     #[rustc_clean(cfg="cfail3")]
600     fn method();
601 }
602
603
604
605 // Change type of associated constant
606 #[cfg(cfail1)]
607 trait TraitChangeTypeOfAssociatedConstant {
608     const Value: u32;
609
610     fn method();
611 }
612
613 #[cfg(not(cfail1))]
614 #[rustc_clean(cfg="cfail2")]
615 #[rustc_clean(cfg="cfail3")]
616 trait TraitChangeTypeOfAssociatedConstant {
617     #[rustc_clean(except="hir_owner,type_of", cfg="cfail2")]
618     #[rustc_clean(cfg="cfail3")]
619     const Value: f64;
620
621     #[rustc_clean(cfg="cfail2")]
622     #[rustc_clean(cfg="cfail3")]
623     fn method();
624 }
625
626
627
628 // Add super trait
629 #[cfg(cfail1)]
630 trait TraitAddSuperTrait { }
631
632 #[cfg(not(cfail1))]
633 #[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")]
634 #[rustc_clean(cfg="cfail3")]
635 trait TraitAddSuperTrait : ReferencedTrait0 { }
636
637
638
639 // Add builtin bound (Send or Copy)
640 #[cfg(cfail1)]
641 trait TraitAddBuiltiBound { }
642
643 #[cfg(not(cfail1))]
644 #[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")]
645 #[rustc_clean(cfg="cfail3")]
646 trait TraitAddBuiltiBound : Send { }
647
648
649
650 // Add 'static lifetime bound to trait
651 #[cfg(cfail1)]
652 trait TraitAddStaticLifetimeBound { }
653
654 #[cfg(not(cfail1))]
655 #[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")]
656 #[rustc_clean(cfg="cfail3")]
657 trait TraitAddStaticLifetimeBound : 'static { }
658
659
660
661 // Add super trait as second bound
662 #[cfg(cfail1)]
663 trait TraitAddTraitAsSecondBound : ReferencedTrait0 { }
664
665 #[cfg(not(cfail1))]
666 #[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")]
667 #[rustc_clean(cfg="cfail3")]
668 trait TraitAddTraitAsSecondBound : ReferencedTrait0 + ReferencedTrait1 { }
669
670 #[cfg(cfail1)]
671 trait TraitAddTraitAsSecondBoundFromBuiltin : Send { }
672
673 #[cfg(not(cfail1))]
674 #[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")]
675 #[rustc_clean(cfg="cfail3")]
676 trait TraitAddTraitAsSecondBoundFromBuiltin : Send + ReferencedTrait0 { }
677
678
679
680 // Add builtin bound as second bound
681 #[cfg(cfail1)]
682 trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 { }
683
684 #[cfg(not(cfail1))]
685 #[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")]
686 #[rustc_clean(cfg="cfail3")]
687 trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 + Send { }
688
689 #[cfg(cfail1)]
690 trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin : Send { }
691
692 #[cfg(not(cfail1))]
693 #[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")]
694 #[rustc_clean(cfg="cfail3")]
695 trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin: Send + Copy { }
696
697
698
699 // Add 'static bounds as second bound
700 #[cfg(cfail1)]
701 trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 { }
702
703 #[cfg(not(cfail1))]
704 #[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")]
705 #[rustc_clean(cfg="cfail3")]
706 trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 + 'static { }
707
708 #[cfg(cfail1)]
709 trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send { }
710
711 #[cfg(not(cfail1))]
712 #[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")]
713 #[rustc_clean(cfg="cfail3")]
714 trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send + 'static { }
715
716
717
718 // Add type parameter to trait
719 #[cfg(cfail1)]
720 trait TraitAddTypeParameterToTrait { }
721
722 #[cfg(not(cfail1))]
723 #[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="cfail2")]
724 #[rustc_clean(cfg="cfail3")]
725 trait TraitAddTypeParameterToTrait<T> { }
726
727
728
729 // Add lifetime parameter to trait
730 #[cfg(cfail1)]
731 trait TraitAddLifetimeParameterToTrait { }
732
733 #[cfg(not(cfail1))]
734 #[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="cfail2")]
735 #[rustc_clean(cfg="cfail3")]
736 trait TraitAddLifetimeParameterToTrait<'a> { }
737
738
739
740 // Add trait bound to type parameter of trait
741 #[cfg(cfail1)]
742 trait TraitAddTraitBoundToTypeParameterOfTrait<T> { }
743
744 #[cfg(not(cfail1))]
745 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
746 #[rustc_clean(cfg="cfail3")]
747 trait TraitAddTraitBoundToTypeParameterOfTrait<T: ReferencedTrait0> { }
748
749
750
751 // Add lifetime bound to type parameter of trait
752 #[cfg(cfail1)]
753 trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T> { }
754
755 #[cfg(not(cfail1))]
756 #[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")]
757 #[rustc_clean(cfg="cfail3")]
758 trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T: 'a> { }
759
760
761
762 // Add lifetime bound to lifetime parameter of trait
763 #[cfg(cfail1)]
764 trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a, 'b> { }
765
766 #[cfg(not(cfail1))]
767 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
768 #[rustc_clean(cfg="cfail3")]
769 trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b> { }
770
771
772
773 // Add builtin bound to type parameter of trait
774 #[cfg(cfail1)]
775 trait TraitAddBuiltinBoundToTypeParameterOfTrait<T> { }
776
777 #[cfg(not(cfail1))]
778 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
779 #[rustc_clean(cfg="cfail3")]
780 trait TraitAddBuiltinBoundToTypeParameterOfTrait<T: Send> { }
781
782
783
784 // Add second type parameter to trait
785 #[cfg(cfail1)]
786 trait TraitAddSecondTypeParameterToTrait<T> { }
787
788 #[cfg(not(cfail1))]
789 #[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")]
790 #[rustc_clean(cfg="cfail3")]
791 trait TraitAddSecondTypeParameterToTrait<T, S> { }
792
793
794
795 // Add second lifetime parameter to trait
796 #[cfg(cfail1)]
797 trait TraitAddSecondLifetimeParameterToTrait<'a> { }
798
799 #[cfg(not(cfail1))]
800 #[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")]
801 #[rustc_clean(cfg="cfail3")]
802 trait TraitAddSecondLifetimeParameterToTrait<'a, 'b> { }
803
804
805
806 // Add second trait bound to type parameter of trait
807 #[cfg(cfail1)]
808 trait TraitAddSecondTraitBoundToTypeParameterOfTrait<T: ReferencedTrait0> { }
809
810 #[cfg(not(cfail1))]
811 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
812 #[rustc_clean(cfg="cfail3")]
813 trait TraitAddSecondTraitBoundToTypeParameterOfTrait<T: ReferencedTrait0 + ReferencedTrait1> { }
814
815
816
817 // Add second lifetime bound to type parameter of trait
818 #[cfg(cfail1)]
819 trait TraitAddSecondLifetimeBoundToTypeParameterOfTrait<'a, 'b, T: 'a> { }
820
821 #[cfg(not(cfail1))]
822 #[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")]
823 #[rustc_clean(cfg="cfail3")]
824 trait TraitAddSecondLifetimeBoundToTypeParameterOfTrait<'a, 'b, T: 'a + 'b> { }
825
826
827
828 // Add second lifetime bound to lifetime parameter of trait
829 #[cfg(cfail1)]
830 trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b, 'c> { }
831
832 #[cfg(not(cfail1))]
833 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
834 #[rustc_clean(cfg="cfail3")]
835 trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b + 'c, 'b, 'c> { }
836
837
838
839 // Add second builtin bound to type parameter of trait
840 #[cfg(cfail1)]
841 trait TraitAddSecondBuiltinBoundToTypeParameterOfTrait<T: Send> { }
842
843 #[cfg(not(cfail1))]
844 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
845 #[rustc_clean(cfg="cfail3")]
846 trait TraitAddSecondBuiltinBoundToTypeParameterOfTrait<T: Send + Sync> { }
847
848
849
850 struct ReferenceType0 {}
851 struct ReferenceType1 {}
852
853
854
855 // Add trait bound to type parameter of trait in where clause
856 #[cfg(cfail1)]
857 trait TraitAddTraitBoundToTypeParameterOfTraitWhere<T> { }
858
859 #[cfg(not(cfail1))]
860 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
861 #[rustc_clean(cfg="cfail3")]
862 trait TraitAddTraitBoundToTypeParameterOfTraitWhere<T> where T: ReferencedTrait0 { }
863
864
865
866 // Add lifetime bound to type parameter of trait in where clause
867 #[cfg(cfail1)]
868 trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> { }
869
870 #[cfg(not(cfail1))]
871 #[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")]
872 #[rustc_clean(cfg="cfail3")]
873 trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> where T: 'a { }
874
875
876
877 // Add lifetime bound to lifetime parameter of trait in where clause
878 #[cfg(cfail1)]
879 trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> { }
880
881 #[cfg(not(cfail1))]
882 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
883 #[rustc_clean(cfg="cfail3")]
884 trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> where 'a: 'b { }
885
886
887
888 // Add builtin bound to type parameter of trait in where clause
889 #[cfg(cfail1)]
890 trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere<T> { }
891
892 #[cfg(not(cfail1))]
893 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
894 #[rustc_clean(cfg="cfail3")]
895 trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere<T> where T: Send { }
896
897
898
899 // Add second trait bound to type parameter of trait in where clause
900 #[cfg(cfail1)]
901 trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere<T> where T: ReferencedTrait0 { }
902
903 #[cfg(not(cfail1))]
904 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
905 #[rustc_clean(cfg="cfail3")]
906 trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere<T>
907     where T: ReferencedTrait0 + ReferencedTrait1 { }
908
909
910
911 // Add second lifetime bound to type parameter of trait in where clause
912 #[cfg(cfail1)]
913 trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: 'a { }
914
915 #[cfg(not(cfail1))]
916 #[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")]
917 #[rustc_clean(cfg="cfail3")]
918 trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: 'a + 'b { }
919
920
921
922 // Add second lifetime bound to lifetime parameter of trait in where clause
923 #[cfg(cfail1)]
924 trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> where 'a: 'b { }
925
926 #[cfg(not(cfail1))]
927 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
928 #[rustc_clean(cfg="cfail3")]
929 trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> where 'a: 'b + 'c { }
930
931
932
933 // Add second builtin bound to type parameter of trait in where clause
934 #[cfg(cfail1)]
935 trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere<T> where T: Send { }
936
937 #[cfg(not(cfail1))]
938 #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
939 #[rustc_clean(cfg="cfail3")]
940 trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere<T> where T: Send + Sync { }
941
942
943 // Change return type of method indirectly by modifying a use statement
944 mod change_return_type_of_method_indirectly_use {
945     #[cfg(cfail1)]
946     use super::ReferenceType0 as ReturnType;
947     #[cfg(not(cfail1))]
948     use super::ReferenceType1 as ReturnType;
949
950     #[rustc_clean(cfg="cfail2")]
951     #[rustc_clean(cfg="cfail3")]
952     trait TraitChangeReturnType {
953         #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig", cfg="cfail2")]
954         #[rustc_clean(cfg="cfail3")]
955         fn method() -> ReturnType;
956     }
957 }
958
959
960
961 // Change type of method parameter indirectly by modifying a use statement
962 mod change_method_parameter_type_indirectly_by_use {
963     #[cfg(cfail1)]
964     use super::ReferenceType0 as ArgType;
965     #[cfg(not(cfail1))]
966     use super::ReferenceType1 as ArgType;
967
968     #[rustc_clean(cfg="cfail2")]
969     #[rustc_clean(cfg="cfail3")]
970     trait TraitChangeArgType {
971         #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")]
972         #[rustc_clean(cfg="cfail3")]
973         fn method(a: ArgType);
974     }
975 }
976
977
978
979 // Change trait bound of method type parameter indirectly by modifying a use statement
980 mod change_method_parameter_type_bound_indirectly_by_use {
981     #[cfg(cfail1)]
982     use super::ReferencedTrait0 as Bound;
983     #[cfg(not(cfail1))]
984     use super::ReferencedTrait1 as Bound;
985
986     #[rustc_clean(cfg="cfail2")]
987     #[rustc_clean(cfg="cfail3")]
988     trait TraitChangeBoundOfMethodTypeParameter {
989         #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
990         #[rustc_clean(cfg="cfail3")]
991         fn method<T: Bound>(a: T);
992     }
993 }
994
995
996
997 // Change trait bound of method type parameter in where clause indirectly
998 // by modifying a use statement
999 mod change_method_parameter_type_bound_indirectly_by_use_where {
1000     #[cfg(cfail1)]
1001     use super::ReferencedTrait0 as Bound;
1002     #[cfg(not(cfail1))]
1003     use super::ReferencedTrait1 as Bound;
1004
1005     #[rustc_clean(cfg="cfail2")]
1006     #[rustc_clean(cfg="cfail3")]
1007     trait TraitChangeBoundOfMethodTypeParameterWhere {
1008         #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
1009         #[rustc_clean(cfg="cfail3")]
1010         fn method<T>(a: T) where T: Bound;
1011     }
1012 }
1013
1014
1015
1016 // Change trait bound of trait type parameter indirectly by modifying a use statement
1017 mod change_method_type_parameter_bound_indirectly {
1018     #[cfg(cfail1)]
1019     use super::ReferencedTrait0 as Bound;
1020     #[cfg(not(cfail1))]
1021     use super::ReferencedTrait1 as Bound;
1022
1023     #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
1024     #[rustc_clean(cfg="cfail3")]
1025     trait TraitChangeTraitBound<T: Bound> {
1026         fn method(a: T);
1027     }
1028 }
1029
1030
1031
1032 // Change trait bound of trait type parameter in where clause indirectly
1033 // by modifying a use statement
1034 mod change_method_type_parameter_bound_indirectly_where {
1035     #[cfg(cfail1)]
1036     use super::ReferencedTrait0 as Bound;
1037     #[cfg(not(cfail1))]
1038     use super::ReferencedTrait1 as Bound;
1039
1040     #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")]
1041     #[rustc_clean(cfg="cfail3")]
1042     trait TraitChangeTraitBoundWhere<T> where T: Bound {
1043         fn method(a: T);
1044     }
1045 }