]> git.proxmox.com Git - rustc.git/blame - src/test/incremental/hashes/inherent_impls.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / test / incremental / hashes / inherent_impls.rs
CommitLineData
476ff2be
SL
1// This test case tests the incremental compilation hash (ICH) implementation
2// for let expressions.
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
416331ca 8// build-pass (FIXME(62277): could be check-pass?)
476ff2be 9// revisions: cfail1 cfail2 cfail3
ff7c6d11 10// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
476ff2be
SL
11
12
13#![allow(warnings)]
14#![feature(rustc_attrs)]
15#![crate_type="rlib"]
16
abe05a73 17pub struct Foo;
476ff2be
SL
18
19// Change Method Name -----------------------------------------------------------
20#[cfg(cfail1)]
21impl Foo {
22 pub fn method_name() { }
23}
24
25#[cfg(not(cfail1))]
ba9703b0 26#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,associated_item_def_ids")]
abe05a73 27#[rustc_clean(cfg="cfail3")]
476ff2be 28impl Foo {
abe05a73 29 #[rustc_clean(cfg="cfail3")]
476ff2be
SL
30 pub fn method_name2() { }
31}
32
33// Change Method Body -----------------------------------------------------------
34//
35// This should affect the method itself, but not the impl.
36#[cfg(cfail1)]
37impl Foo {
38 pub fn method_body() { }
39}
40
41#[cfg(not(cfail1))]
abe05a73
XL
42#[rustc_clean(cfg="cfail2")]
43#[rustc_clean(cfg="cfail3")]
476ff2be 44impl Foo {
e1599b0c
XL
45 #[rustc_clean(
46 cfg="cfail2",
3dfed10e 47 except="hir_owner_nodes,optimized_mir,promoted_mir,typeck"
e1599b0c 48 )]
abe05a73 49 #[rustc_clean(cfg="cfail3")]
476ff2be
SL
50 pub fn method_body() {
51 println!("Hello, world!");
52 }
53}
54
8bb4bdeb
XL
55
56// Change Method Body (inlined) ------------------------------------------------
57//
58// This should affect the method itself, but not the impl.
59#[cfg(cfail1)]
60impl Foo {
61 #[inline]
62 pub fn method_body_inlined() { }
63}
64
65#[cfg(not(cfail1))]
abe05a73
XL
66#[rustc_clean(cfg="cfail2")]
67#[rustc_clean(cfg="cfail3")]
8bb4bdeb 68impl Foo {
e1599b0c
XL
69 #[rustc_clean(
70 cfg="cfail2",
3dfed10e 71 except="hir_owner_nodes,optimized_mir,promoted_mir,typeck"
e1599b0c 72 )]
abe05a73 73 #[rustc_clean(cfg="cfail3")]
8bb4bdeb
XL
74 #[inline]
75 pub fn method_body_inlined() {
76 println!("Hello, world!");
77 }
78}
79
80
81// Change Method Privacy -------------------------------------------------------
476ff2be
SL
82#[cfg(cfail1)]
83impl Foo {
84 pub fn method_privacy() { }
85}
86
87#[cfg(not(cfail1))]
ba9703b0 88#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
abe05a73 89#[rustc_clean(cfg="cfail3")]
476ff2be 90impl Foo {
ba9703b0 91 #[rustc_clean(cfg="cfail2", except="associated_item,hir_owner,hir_owner_nodes")]
abe05a73 92 #[rustc_clean(cfg="cfail3")]
476ff2be
SL
93 fn method_privacy() { }
94}
95
96// Change Method Selfness -----------------------------------------------------------
97#[cfg(cfail1)]
98impl Foo {
99 pub fn method_selfness() { }
100}
101
102#[cfg(not(cfail1))]
ba9703b0 103#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
abe05a73 104#[rustc_clean(cfg="cfail3")]
476ff2be 105impl Foo {
e1599b0c 106 #[rustc_dirty(cfg="cfail2", except="type_of,predicates_of,promoted_mir")]
abe05a73 107 #[rustc_clean(cfg="cfail3")]
476ff2be
SL
108 pub fn method_selfness(&self) { }
109}
110
32a655c1 111// Change Method Selfmutness ---------------------------------------------------
476ff2be
SL
112#[cfg(cfail1)]
113impl Foo {
114 pub fn method_selfmutness(&self) { }
115}
116
117#[cfg(not(cfail1))]
abe05a73
XL
118#[rustc_clean(cfg="cfail2")]
119#[rustc_clean(cfg="cfail3")]
476ff2be 120impl Foo {
abe05a73
XL
121 #[rustc_clean(
122 cfg="cfail2",
3dfed10e 123 except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir"
abe05a73
XL
124 )]
125 #[rustc_clean(cfg="cfail3")]
476ff2be
SL
126 pub fn method_selfmutness(&mut self) { }
127}
128
32a655c1
SL
129
130
131// Add Method To Impl ----------------------------------------------------------
132#[cfg(cfail1)]
133impl Foo {
134 pub fn add_method_to_impl1(&self) { }
135}
136
137#[cfg(not(cfail1))]
ba9703b0 138#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,associated_item_def_ids")]
abe05a73 139#[rustc_clean(cfg="cfail3")]
32a655c1 140impl Foo {
abe05a73
XL
141 #[rustc_clean(cfg="cfail2")]
142 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
143 pub fn add_method_to_impl1(&self) { }
144
abe05a73 145 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
146 pub fn add_method_to_impl2(&self) { }
147}
148
149
150
151// Add Method Parameter --------------------------------------------------------
152#[cfg(cfail1)]
153impl Foo {
154 pub fn add_method_parameter(&self) { }
155}
156
157#[cfg(not(cfail1))]
abe05a73
XL
158#[rustc_clean(cfg="cfail2")]
159#[rustc_clean(cfg="cfail3")]
32a655c1 160impl Foo {
abe05a73
XL
161 #[rustc_clean(
162 cfg="cfail2",
3dfed10e 163 except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir"
abe05a73
XL
164 )]
165 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
166 pub fn add_method_parameter(&self, _: i32) { }
167}
168
169
170
171// Change Method Parameter Name ------------------------------------------------
172#[cfg(cfail1)]
173impl Foo {
174 pub fn change_method_parameter_name(&self, a: i64) { }
175}
176
177#[cfg(not(cfail1))]
abe05a73
XL
178#[rustc_clean(cfg="cfail2")]
179#[rustc_clean(cfg="cfail3")]
32a655c1 180impl Foo {
3dfed10e 181 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
abe05a73 182 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
183 pub fn change_method_parameter_name(&self, b: i64) { }
184}
185
186
187
188// Change Method Return Type ---------------------------------------------------
189#[cfg(cfail1)]
190impl Foo {
191 pub fn change_method_return_type(&self) -> u16 { 0 }
192}
193
194#[cfg(not(cfail1))]
abe05a73
XL
195#[rustc_clean(cfg="cfail2")]
196#[rustc_clean(cfg="cfail3")]
32a655c1 197impl Foo {
abe05a73
XL
198 #[rustc_clean(
199 cfg="cfail2",
3dfed10e 200 except="hir_owner,hir_owner_nodes,fn_sig,optimized_mir,typeck")]
abe05a73 201 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
202 pub fn change_method_return_type(&self) -> u8 { 0 }
203}
204
205
206
207// Make Method #[inline] -------------------------------------------------------
208#[cfg(cfail1)]
209impl Foo {
210 pub fn make_method_inline(&self) -> u8 { 0 }
211}
212
213#[cfg(not(cfail1))]
abe05a73
XL
214#[rustc_clean(cfg="cfail2")]
215#[rustc_clean(cfg="cfail3")]
32a655c1 216impl Foo {
6a06907d 217 #[rustc_clean(cfg="cfail2")]
abe05a73 218 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
219 #[inline]
220 pub fn make_method_inline(&self) -> u8 { 0 }
221}
222
223
224
225// Change order of parameters -------------------------------------------------
226#[cfg(cfail1)]
227impl Foo {
228 pub fn change_method_parameter_order(&self, a: i64, b: i64) { }
229}
230
231#[cfg(not(cfail1))]
abe05a73
XL
232#[rustc_clean(cfg="cfail2")]
233#[rustc_clean(cfg="cfail3")]
32a655c1 234impl Foo {
3dfed10e 235 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
abe05a73 236 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
237 pub fn change_method_parameter_order(&self, b: i64, a: i64) { }
238}
239
240
241
242// Make method unsafe ----------------------------------------------------------
243#[cfg(cfail1)]
244impl Foo {
245 pub fn make_method_unsafe(&self) { }
246}
247
248#[cfg(not(cfail1))]
abe05a73
XL
249#[rustc_clean(cfg="cfail2")]
250#[rustc_clean(cfg="cfail3")]
32a655c1 251impl Foo {
abe05a73
XL
252 #[rustc_clean(
253 cfg="cfail2",
3dfed10e 254 except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir"
abe05a73
XL
255 )]
256 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
257 pub unsafe fn make_method_unsafe(&self) { }
258}
259
260
261
262// Make method extern ----------------------------------------------------------
263#[cfg(cfail1)]
264impl Foo {
265 pub fn make_method_extern(&self) { }
266}
267
268#[cfg(not(cfail1))]
abe05a73
XL
269#[rustc_clean(cfg="cfail2")]
270#[rustc_clean(cfg="cfail3")]
32a655c1 271impl Foo {
3dfed10e 272 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
abe05a73 273 #[rustc_clean(cfg="cfail3")]
5869c6ff 274 pub extern "C" fn make_method_extern(&self) { }
32a655c1
SL
275}
276
277
278
279// Change method calling convention --------------------------------------------
280#[cfg(cfail1)]
281impl Foo {
282 pub extern "C" fn change_method_calling_convention(&self) { }
283}
284
285#[cfg(not(cfail1))]
abe05a73
XL
286#[rustc_clean(cfg="cfail2")]
287#[rustc_clean(cfg="cfail3")]
32a655c1 288impl Foo {
3dfed10e 289 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
abe05a73 290 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
291 pub extern "system" fn change_method_calling_convention(&self) { }
292}
293
294
295
296// Add Lifetime Parameter to Method --------------------------------------------
297#[cfg(cfail1)]
298impl Foo {
299 pub fn add_lifetime_parameter_to_method(&self) { }
300}
301
302#[cfg(not(cfail1))]
abe05a73
XL
303#[rustc_clean(cfg="cfail2")]
304#[rustc_clean(cfg="cfail3")]
32a655c1 305impl Foo {
3dfed10e 306 // Warning: Note that `typeck` are coming up clean here.
ff7c6d11
XL
307 // The addition or removal of lifetime parameters that don't
308 // appear in the arguments or fn body in any way does not, in
3dfed10e 309 // fact, affect the `typeck` in any semantic way (at least
ff7c6d11 310 // as of this writing). **However,** altering the order of
3dfed10e 311 // lowering **can** cause it appear to affect the `typeck`:
ff7c6d11
XL
312 // if we lower generics before the body, then the `HirId` for
313 // things in the body will be affected. So if you start to see
3dfed10e 314 // `typeck` appear dirty, that might be the cause. -nmatsakis
ba9703b0 315 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
abe05a73 316 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
317 pub fn add_lifetime_parameter_to_method<'a>(&self) { }
318}
319
320
321
322// Add Type Parameter To Method ------------------------------------------------
323#[cfg(cfail1)]
324impl Foo {
325 pub fn add_type_parameter_to_method(&self) { }
326}
327
328#[cfg(not(cfail1))]
abe05a73
XL
329#[rustc_clean(cfg="cfail2")]
330#[rustc_clean(cfg="cfail3")]
32a655c1 331impl Foo {
3dfed10e 332 // Warning: Note that `typeck` are coming up clean here.
ff7c6d11
XL
333 // The addition or removal of type parameters that don't appear in
334 // the arguments or fn body in any way does not, in fact, affect
3dfed10e 335 // the `typeck` in any semantic way (at least as of this
ff7c6d11 336 // writing). **However,** altering the order of lowering **can**
3dfed10e 337 // cause it appear to affect the `typeck`: if we lower
ff7c6d11 338 // generics before the body, then the `HirId` for things in the
3dfed10e 339 // body will be affected. So if you start to see `typeck`
ff7c6d11 340 // appear dirty, that might be the cause. -nmatsakis
abe05a73
XL
341 #[rustc_clean(
342 cfg="cfail2",
ba9703b0 343 except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of",
abe05a73
XL
344 )]
345 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
346 pub fn add_type_parameter_to_method<T>(&self) { }
347}
348
349
350
351// Add Lifetime Bound to Lifetime Parameter of Method --------------------------
352#[cfg(cfail1)]
353impl Foo {
354 pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b>(&self) { }
355}
356
357#[cfg(not(cfail1))]
abe05a73
XL
358#[rustc_clean(cfg="cfail2")]
359#[rustc_clean(cfg="cfail3")]
32a655c1 360impl Foo {
abe05a73
XL
361 #[rustc_clean(
362 cfg="cfail2",
ba9703b0 363 except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of"
abe05a73
XL
364 )]
365 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
366 pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b: 'a>(&self) { }
367}
368
369
370
371// Add Lifetime Bound to Type Parameter of Method ------------------------------
372#[cfg(cfail1)]
373impl Foo {
374 pub fn add_lifetime_bound_to_type_param_of_method<'a, T>(&self) { }
375}
376
377#[cfg(not(cfail1))]
abe05a73
XL
378#[rustc_clean(cfg="cfail2")]
379#[rustc_clean(cfg="cfail3")]
32a655c1 380impl Foo {
3dfed10e 381 // Warning: Note that `typeck` are coming up clean here.
ff7c6d11
XL
382 // The addition or removal of bounds that don't appear in the
383 // arguments or fn body in any way does not, in fact, affect the
3dfed10e 384 // `typeck` in any semantic way (at least as of this
ff7c6d11 385 // writing). **However,** altering the order of lowering **can**
3dfed10e 386 // cause it appear to affect the `typeck`: if we lower
ff7c6d11 387 // generics before the body, then the `HirId` for things in the
3dfed10e 388 // body will be affected. So if you start to see `typeck`
ff7c6d11 389 // appear dirty, that might be the cause. -nmatsakis
ba9703b0 390 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,\
532ac7d7 391 type_of")]
abe05a73 392 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
393 pub fn add_lifetime_bound_to_type_param_of_method<'a, T: 'a>(&self) { }
394}
395
396
397
398// Add Trait Bound to Type Parameter of Method ------------------------------
399#[cfg(cfail1)]
400impl Foo {
401 pub fn add_trait_bound_to_type_param_of_method<T>(&self) { }
402}
403
404#[cfg(not(cfail1))]
abe05a73
XL
405#[rustc_clean(cfg="cfail2")]
406#[rustc_clean(cfg="cfail3")]
32a655c1 407impl Foo {
3dfed10e 408 // Warning: Note that `typeck` are coming up clean here.
ff7c6d11
XL
409 // The addition or removal of bounds that don't appear in the
410 // arguments or fn body in any way does not, in fact, affect the
3dfed10e 411 // `typeck` in any semantic way (at least as of this
ff7c6d11 412 // writing). **However,** altering the order of lowering **can**
3dfed10e 413 // cause it appear to affect the `typeck`: if we lower
ff7c6d11 414 // generics before the body, then the `HirId` for things in the
3dfed10e 415 // body will be affected. So if you start to see `typeck`
ff7c6d11 416 // appear dirty, that might be the cause. -nmatsakis
ba9703b0 417 #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
abe05a73 418 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
419 pub fn add_trait_bound_to_type_param_of_method<T: Clone>(&self) { }
420}
421
422
423
424// Add #[no_mangle] to Method --------------------------------------------------
425#[cfg(cfail1)]
426impl Foo {
427 pub fn add_no_mangle_to_method(&self) { }
428}
429
430#[cfg(not(cfail1))]
abe05a73
XL
431#[rustc_clean(cfg="cfail2")]
432#[rustc_clean(cfg="cfail3")]
32a655c1 433impl Foo {
6a06907d 434 #[rustc_clean(cfg="cfail2")]
abe05a73 435 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
436 #[no_mangle]
437 pub fn add_no_mangle_to_method(&self) { }
438}
439
440
441
442struct Bar<T>(T);
443
444// Add Type Parameter To Impl --------------------------------------------------
445#[cfg(cfail1)]
446impl Bar<u32> {
447 pub fn add_type_parameter_to_impl(&self) { }
448}
449
450#[cfg(not(cfail1))]
ba9703b0 451#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of")]
abe05a73 452#[rustc_clean(cfg="cfail3")]
32a655c1 453impl<T> Bar<T> {
abe05a73
XL
454 #[rustc_clean(
455 cfg="cfail2",
3dfed10e 456 except="generics_of,fn_sig,typeck,type_of,optimized_mir"
abe05a73
XL
457 )]
458 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
459 pub fn add_type_parameter_to_impl(&self) { }
460}
461
462
463
464// Change Self Type of Impl ----------------------------------------------------
465#[cfg(cfail1)]
466impl Bar<u32> {
467 pub fn change_impl_self_type(&self) { }
468}
469
470#[cfg(not(cfail1))]
ba9703b0 471#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
abe05a73 472#[rustc_clean(cfg="cfail3")]
32a655c1 473impl Bar<u64> {
3dfed10e 474 #[rustc_clean(cfg="cfail2", except="fn_sig,optimized_mir,typeck")]
abe05a73 475 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
476 pub fn change_impl_self_type(&self) { }
477}
478
479
480
481// Add Lifetime Bound to Impl --------------------------------------------------
482#[cfg(cfail1)]
483impl<T> Bar<T> {
484 pub fn add_lifetime_bound_to_impl_parameter(&self) { }
485}
486
487#[cfg(not(cfail1))]
ba9703b0 488#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
abe05a73 489#[rustc_clean(cfg="cfail3")]
32a655c1 490impl<T: 'static> Bar<T> {
abe05a73
XL
491 #[rustc_clean(cfg="cfail2")]
492 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
493 pub fn add_lifetime_bound_to_impl_parameter(&self) { }
494}
495
496
497
498// Add Trait Bound to Impl Parameter -------------------------------------------
499#[cfg(cfail1)]
500impl<T> Bar<T> {
501 pub fn add_trait_bound_to_impl_parameter(&self) { }
502}
503
504#[cfg(not(cfail1))]
ba9703b0 505#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
abe05a73 506#[rustc_clean(cfg="cfail3")]
32a655c1 507impl<T: Clone> Bar<T> {
abe05a73
XL
508 #[rustc_clean(cfg="cfail2")]
509 #[rustc_clean(cfg="cfail3")]
32a655c1
SL
510 pub fn add_trait_bound_to_impl_parameter(&self) { }
511}
abe05a73
XL
512
513
514// Force instantiation of some fns so we can check their hash.
515pub fn instantiation_root() {
516 Foo::method_privacy();
517
518 #[cfg(cfail1)]
519 {
520 Bar(0u32).change_impl_self_type();
521 }
522
523 #[cfg(not(cfail1))]
524 {
525 Bar(0u64).change_impl_self_type();
526 }
527}