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