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