]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/inherent_impls.rs
Rollup merge of #41249 - GuillaumeGomez:rustdoc-render, r=steveklabnik,frewsxcv
[rust.git] / src / test / incremental / hashes / inherent_impls.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for let expressions.
14
15 // The general pattern followed here is: Change one thing between rev1 and rev2
16 // and make sure that the hash has changed, then change nothing between rev2 and
17 // rev3 and make sure that the hash has not changed.
18
19 // must-compile-successfully
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph
22
23
24 #![allow(warnings)]
25 #![feature(rustc_attrs)]
26 #![crate_type="rlib"]
27
28 struct Foo;
29
30 // Change Method Name -----------------------------------------------------------
31 #[cfg(cfail1)]
32 impl Foo {
33     pub fn method_name() { }
34 }
35
36 #[cfg(not(cfail1))]
37 #[rustc_dirty(label="Hir", cfg="cfail2")]
38 #[rustc_clean(label="Hir", cfg="cfail3")]
39 #[rustc_metadata_dirty(cfg="cfail2")]
40 #[rustc_metadata_clean(cfg="cfail3")]
41 impl Foo {
42     #[rustc_clean(label="Hir", cfg="cfail3")]
43     #[rustc_metadata_clean(cfg="cfail3")]
44     pub fn method_name2() { }
45 }
46
47 // Change Method Body -----------------------------------------------------------
48 //
49 // This should affect the method itself, but not the impl.
50 #[cfg(cfail1)]
51 impl Foo {
52     pub fn method_body() { }
53 }
54
55 #[cfg(not(cfail1))]
56 #[rustc_clean(label="Hir", cfg="cfail2")]
57 #[rustc_clean(label="Hir", cfg="cfail3")]
58 #[rustc_metadata_clean(cfg="cfail2")]
59 #[rustc_metadata_clean(cfg="cfail3")]
60 impl Foo {
61     #[rustc_clean(label="Hir", cfg="cfail2")]
62     #[rustc_clean(label="Hir", cfg="cfail3")]
63     #[rustc_dirty(label="HirBody", cfg="cfail2")]
64     #[rustc_clean(label="HirBody", cfg="cfail3")]
65     #[rustc_metadata_clean(cfg="cfail2")]
66     #[rustc_metadata_clean(cfg="cfail3")]
67     pub fn method_body() {
68         println!("Hello, world!");
69     }
70 }
71
72
73 // Change Method Body (inlined) ------------------------------------------------
74 //
75 // This should affect the method itself, but not the impl.
76 #[cfg(cfail1)]
77 impl Foo {
78     #[inline]
79     pub fn method_body_inlined() { }
80 }
81
82 #[cfg(not(cfail1))]
83 #[rustc_clean(label="Hir", cfg="cfail2")]
84 #[rustc_clean(label="Hir", cfg="cfail3")]
85 #[rustc_metadata_clean(cfg="cfail2")]
86 #[rustc_metadata_clean(cfg="cfail3")]
87 impl Foo {
88     #[rustc_clean(label="Hir", cfg="cfail2")]
89     #[rustc_clean(label="Hir", cfg="cfail3")]
90     #[rustc_dirty(label="HirBody", cfg="cfail2")]
91     #[rustc_clean(label="HirBody", cfg="cfail3")]
92     #[rustc_metadata_dirty(cfg="cfail2")]
93     #[rustc_metadata_clean(cfg="cfail3")]
94     #[inline]
95     pub fn method_body_inlined() {
96         println!("Hello, world!");
97     }
98 }
99
100
101 // Change Method Privacy -------------------------------------------------------
102 #[cfg(cfail1)]
103 impl Foo {
104     pub fn method_privacy() { }
105 }
106
107 #[cfg(not(cfail1))]
108 #[rustc_dirty(label="Hir", cfg="cfail2")]
109 #[rustc_clean(label="Hir", cfg="cfail3")]
110 #[rustc_metadata_clean(cfg="cfail2")]
111 #[rustc_metadata_clean(cfg="cfail3")]
112 impl Foo {
113     #[rustc_dirty(label="Hir", cfg="cfail2")]
114     #[rustc_clean(label="Hir", cfg="cfail3")]
115     #[rustc_metadata_dirty(cfg="cfail2")]
116     #[rustc_metadata_clean(cfg="cfail3")]
117     fn method_privacy() { }
118 }
119
120 // Change Method Selfness -----------------------------------------------------------
121 #[cfg(cfail1)]
122 impl Foo {
123     pub fn method_selfness() { }
124 }
125
126 #[cfg(not(cfail1))]
127 #[rustc_dirty(label="Hir", cfg="cfail2")]
128 #[rustc_clean(label="Hir", cfg="cfail3")]
129 #[rustc_metadata_clean(cfg="cfail2")]
130 #[rustc_metadata_clean(cfg="cfail3")]
131 impl Foo {
132     #[rustc_dirty(label="Hir", cfg="cfail2")]
133     #[rustc_clean(label="Hir", cfg="cfail3")]
134     #[rustc_metadata_dirty(cfg="cfail2")]
135     #[rustc_metadata_clean(cfg="cfail3")]
136     pub fn method_selfness(&self) { }
137 }
138
139 // Change Method Selfmutness ---------------------------------------------------
140 #[cfg(cfail1)]
141 impl Foo {
142     pub fn method_selfmutness(&self) { }
143 }
144
145 #[cfg(not(cfail1))]
146 #[rustc_clean(label="Hir", cfg="cfail2")]
147 #[rustc_clean(label="Hir", cfg="cfail3")]
148 #[rustc_metadata_clean(cfg="cfail2")]
149 #[rustc_metadata_clean(cfg="cfail3")]
150 impl Foo {
151     #[rustc_dirty(label="Hir", cfg="cfail2")]
152     #[rustc_clean(label="Hir", cfg="cfail3")]
153     #[rustc_metadata_dirty(cfg="cfail2")]
154     #[rustc_metadata_clean(cfg="cfail3")]
155     pub fn method_selfmutness(&mut self) { }
156 }
157
158
159
160 // Add Method To Impl ----------------------------------------------------------
161 #[cfg(cfail1)]
162 impl Foo {
163     pub fn add_method_to_impl1(&self) { }
164 }
165
166 #[cfg(not(cfail1))]
167 #[rustc_dirty(label="Hir", cfg="cfail2")]
168 #[rustc_clean(label="Hir", cfg="cfail3")]
169 #[rustc_metadata_dirty(cfg="cfail2")]
170 #[rustc_metadata_clean(cfg="cfail3")]
171 impl Foo {
172     #[rustc_clean(label="Hir", cfg="cfail2")]
173     #[rustc_clean(label="Hir", cfg="cfail3")]
174     #[rustc_metadata_clean(cfg="cfail2")]
175     #[rustc_metadata_clean(cfg="cfail3")]
176     pub fn add_method_to_impl1(&self) { }
177
178     #[rustc_clean(label="Hir", cfg="cfail3")]
179     #[rustc_metadata_clean(cfg="cfail3")]
180     pub fn add_method_to_impl2(&self) { }
181 }
182
183
184
185 // Add Method Parameter --------------------------------------------------------
186 #[cfg(cfail1)]
187 impl Foo {
188     pub fn add_method_parameter(&self) { }
189 }
190
191 #[cfg(not(cfail1))]
192 #[rustc_clean(label="Hir", cfg="cfail2")]
193 #[rustc_clean(label="Hir", cfg="cfail3")]
194 #[rustc_metadata_clean(cfg="cfail2")]
195 #[rustc_metadata_clean(cfg="cfail3")]
196 impl Foo {
197     #[rustc_dirty(label="Hir", cfg="cfail2")]
198     #[rustc_clean(label="Hir", cfg="cfail3")]
199     #[rustc_metadata_dirty(cfg="cfail2")]
200     #[rustc_metadata_clean(cfg="cfail3")]
201     pub fn add_method_parameter(&self, _: i32) { }
202 }
203
204
205
206 // Change Method Parameter Name ------------------------------------------------
207 #[cfg(cfail1)]
208 impl Foo {
209     pub fn change_method_parameter_name(&self, a: i64) { }
210 }
211
212 #[cfg(not(cfail1))]
213 #[rustc_clean(label="Hir", cfg="cfail2")]
214 #[rustc_clean(label="Hir", cfg="cfail3")]
215 #[rustc_metadata_clean(cfg="cfail2")]
216 #[rustc_metadata_clean(cfg="cfail3")]
217 impl Foo {
218     #[rustc_clean(label="Hir", cfg="cfail2")]
219     #[rustc_clean(label="Hir", cfg="cfail3")]
220     #[rustc_dirty(label="HirBody", cfg="cfail2")]
221     #[rustc_clean(label="HirBody", cfg="cfail3")]
222     #[rustc_metadata_dirty(cfg="cfail2")]
223     #[rustc_metadata_clean(cfg="cfail3")]
224     pub fn change_method_parameter_name(&self, b: i64) { }
225 }
226
227
228
229 // Change Method Return Type ---------------------------------------------------
230 #[cfg(cfail1)]
231 impl Foo {
232     pub fn change_method_return_type(&self) -> u16 { 0 }
233 }
234
235 #[cfg(not(cfail1))]
236 #[rustc_clean(label="Hir", cfg="cfail2")]
237 #[rustc_clean(label="Hir", cfg="cfail3")]
238 #[rustc_metadata_clean(cfg="cfail2")]
239 #[rustc_metadata_clean(cfg="cfail3")]
240 impl Foo {
241     #[rustc_dirty(label="Hir", cfg="cfail2")]
242     #[rustc_clean(label="Hir", cfg="cfail3")]
243     #[rustc_metadata_dirty(cfg="cfail2")]
244     #[rustc_metadata_clean(cfg="cfail3")]
245     pub fn change_method_return_type(&self) -> u8 { 0 }
246 }
247
248
249
250 // Make Method #[inline] -------------------------------------------------------
251 #[cfg(cfail1)]
252 impl Foo {
253     pub fn make_method_inline(&self) -> u8 { 0 }
254 }
255
256 #[cfg(not(cfail1))]
257 #[rustc_clean(label="Hir", cfg="cfail2")]
258 #[rustc_clean(label="Hir", cfg="cfail3")]
259 #[rustc_metadata_clean(cfg="cfail2")]
260 #[rustc_metadata_clean(cfg="cfail3")]
261 impl Foo {
262     #[rustc_dirty(label="Hir", cfg="cfail2")]
263     #[rustc_clean(label="Hir", cfg="cfail3")]
264     #[rustc_metadata_dirty(cfg="cfail2")]
265     #[rustc_metadata_clean(cfg="cfail3")]
266     #[inline]
267     pub fn make_method_inline(&self) -> u8 { 0 }
268 }
269
270
271
272 //  Change order of parameters -------------------------------------------------
273 #[cfg(cfail1)]
274 impl Foo {
275     pub fn change_method_parameter_order(&self, a: i64, b: i64) { }
276 }
277
278 #[cfg(not(cfail1))]
279 #[rustc_clean(label="Hir", cfg="cfail2")]
280 #[rustc_clean(label="Hir", cfg="cfail3")]
281 #[rustc_metadata_clean(cfg="cfail2")]
282 #[rustc_metadata_clean(cfg="cfail3")]
283 impl Foo {
284     #[rustc_clean(label="Hir", cfg="cfail2")]
285     #[rustc_clean(label="Hir", cfg="cfail3")]
286     #[rustc_dirty(label="HirBody", cfg="cfail2")]
287     #[rustc_clean(label="HirBody", cfg="cfail3")]
288     #[rustc_metadata_dirty(cfg="cfail2")]
289     #[rustc_metadata_clean(cfg="cfail3")]
290     pub fn change_method_parameter_order(&self, b: i64, a: i64) { }
291 }
292
293
294
295 // Make method unsafe ----------------------------------------------------------
296 #[cfg(cfail1)]
297 impl Foo {
298     pub fn make_method_unsafe(&self) { }
299 }
300
301 #[cfg(not(cfail1))]
302 #[rustc_clean(label="Hir", cfg="cfail2")]
303 #[rustc_clean(label="Hir", cfg="cfail3")]
304 #[rustc_metadata_clean(cfg="cfail2")]
305 #[rustc_metadata_clean(cfg="cfail3")]
306 impl Foo {
307     #[rustc_dirty(label="Hir", cfg="cfail2")]
308     #[rustc_clean(label="Hir", cfg="cfail3")]
309     #[rustc_metadata_dirty(cfg="cfail2")]
310     #[rustc_metadata_clean(cfg="cfail3")]
311     pub unsafe fn make_method_unsafe(&self) { }
312 }
313
314
315
316 // Make method extern ----------------------------------------------------------
317 #[cfg(cfail1)]
318 impl Foo {
319     pub fn make_method_extern(&self) { }
320 }
321
322 #[cfg(not(cfail1))]
323 #[rustc_clean(label="Hir", cfg="cfail2")]
324 #[rustc_clean(label="Hir", cfg="cfail3")]
325 #[rustc_metadata_clean(cfg="cfail2")]
326 #[rustc_metadata_clean(cfg="cfail3")]
327 impl Foo {
328     #[rustc_dirty(label="Hir", cfg="cfail2")]
329     #[rustc_clean(label="Hir", cfg="cfail3")]
330     #[rustc_metadata_dirty(cfg="cfail2")]
331     #[rustc_metadata_clean(cfg="cfail3")]
332     pub extern fn make_method_extern(&self) { }
333 }
334
335
336
337 // Change method calling convention --------------------------------------------
338 #[cfg(cfail1)]
339 impl Foo {
340     pub extern "C" fn change_method_calling_convention(&self) { }
341 }
342
343 #[cfg(not(cfail1))]
344 #[rustc_clean(label="Hir", cfg="cfail2")]
345 #[rustc_clean(label="Hir", cfg="cfail3")]
346 #[rustc_metadata_clean(cfg="cfail2")]
347 #[rustc_metadata_clean(cfg="cfail3")]
348 impl Foo {
349     #[rustc_dirty(label="Hir", cfg="cfail2")]
350     #[rustc_clean(label="Hir", cfg="cfail3")]
351     #[rustc_metadata_dirty(cfg="cfail2")]
352     #[rustc_metadata_clean(cfg="cfail3")]
353     pub extern "system" fn change_method_calling_convention(&self) { }
354 }
355
356
357
358 // Add Lifetime Parameter to Method --------------------------------------------
359 #[cfg(cfail1)]
360 impl Foo {
361     pub fn add_lifetime_parameter_to_method(&self) { }
362 }
363
364 #[cfg(not(cfail1))]
365 #[rustc_clean(label="Hir", cfg="cfail2")]
366 #[rustc_clean(label="Hir", cfg="cfail3")]
367 #[rustc_metadata_clean(cfg="cfail2")]
368 #[rustc_metadata_clean(cfg="cfail3")]
369 impl Foo {
370     #[rustc_dirty(label="Hir", cfg="cfail2")]
371     #[rustc_clean(label="Hir", cfg="cfail3")]
372     #[rustc_metadata_clean(cfg="cfail2")] // Apparently unused lifetimes don't show up in the type.
373     #[rustc_metadata_clean(cfg="cfail3")]
374     pub fn add_lifetime_parameter_to_method<'a>(&self) { }
375 }
376
377
378
379 // Add Type Parameter To Method ------------------------------------------------
380 #[cfg(cfail1)]
381 impl Foo {
382     pub fn add_type_parameter_to_method(&self) { }
383 }
384
385 #[cfg(not(cfail1))]
386 #[rustc_clean(label="Hir", cfg="cfail2")]
387 #[rustc_clean(label="Hir", cfg="cfail3")]
388 #[rustc_metadata_clean(cfg="cfail2")]
389 #[rustc_metadata_clean(cfg="cfail3")]
390 impl Foo {
391     #[rustc_dirty(label="Hir", cfg="cfail2")]
392     #[rustc_clean(label="Hir", cfg="cfail3")]
393     #[rustc_metadata_dirty(cfg="cfail2")]
394     #[rustc_metadata_clean(cfg="cfail3")]
395     pub fn add_type_parameter_to_method<T>(&self) { }
396 }
397
398
399
400 // Add Lifetime Bound to Lifetime Parameter of Method --------------------------
401 #[cfg(cfail1)]
402 impl Foo {
403     pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b>(&self) { }
404 }
405
406 #[cfg(not(cfail1))]
407 #[rustc_clean(label="Hir", cfg="cfail2")]
408 #[rustc_clean(label="Hir", cfg="cfail3")]
409 #[rustc_metadata_clean(cfg="cfail2")]
410 #[rustc_metadata_clean(cfg="cfail3")]
411 impl Foo {
412     #[rustc_dirty(label="Hir", cfg="cfail2")]
413     #[rustc_clean(label="Hir", cfg="cfail3")]
414     #[rustc_metadata_dirty(cfg="cfail2")]
415     #[rustc_metadata_clean(cfg="cfail3")]
416     pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b: 'a>(&self) { }
417 }
418
419
420
421 // Add Lifetime Bound to Type Parameter of Method ------------------------------
422 #[cfg(cfail1)]
423 impl Foo {
424     pub fn add_lifetime_bound_to_type_param_of_method<'a, T>(&self) { }
425 }
426
427 #[cfg(not(cfail1))]
428 #[rustc_clean(label="Hir", cfg="cfail2")]
429 #[rustc_clean(label="Hir", cfg="cfail3")]
430 #[rustc_metadata_clean(cfg="cfail2")]
431 #[rustc_metadata_clean(cfg="cfail3")]
432 impl Foo {
433     #[rustc_dirty(label="Hir", cfg="cfail2")]
434     #[rustc_clean(label="Hir", cfg="cfail3")]
435     #[rustc_metadata_dirty(cfg="cfail2")]
436     #[rustc_metadata_clean(cfg="cfail3")]
437     pub fn add_lifetime_bound_to_type_param_of_method<'a, T: 'a>(&self) { }
438 }
439
440
441
442 // Add Trait Bound to Type Parameter of Method ------------------------------
443 #[cfg(cfail1)]
444 impl Foo {
445     pub fn add_trait_bound_to_type_param_of_method<T>(&self) { }
446 }
447
448 #[cfg(not(cfail1))]
449 #[rustc_clean(label="Hir", cfg="cfail2")]
450 #[rustc_clean(label="Hir", cfg="cfail3")]
451 #[rustc_metadata_clean(cfg="cfail2")]
452 #[rustc_metadata_clean(cfg="cfail3")]
453 impl Foo {
454     #[rustc_dirty(label="Hir", cfg="cfail2")]
455     #[rustc_clean(label="Hir", cfg="cfail3")]
456     #[rustc_metadata_dirty(cfg="cfail2")]
457     #[rustc_metadata_clean(cfg="cfail3")]
458     pub fn add_trait_bound_to_type_param_of_method<T: Clone>(&self) { }
459 }
460
461
462
463 // Add #[no_mangle] to Method --------------------------------------------------
464 #[cfg(cfail1)]
465 impl Foo {
466     pub fn add_no_mangle_to_method(&self) { }
467 }
468
469 #[cfg(not(cfail1))]
470 #[rustc_clean(label="Hir", cfg="cfail2")]
471 #[rustc_clean(label="Hir", cfg="cfail3")]
472 #[rustc_metadata_clean(cfg="cfail2")]
473 #[rustc_metadata_clean(cfg="cfail3")]
474 impl Foo {
475     #[rustc_dirty(label="Hir", cfg="cfail2")]
476     #[rustc_clean(label="Hir", cfg="cfail3")]
477     #[rustc_metadata_dirty(cfg="cfail2")]
478     #[rustc_metadata_clean(cfg="cfail3")]
479     #[no_mangle]
480     pub fn add_no_mangle_to_method(&self) { }
481 }
482
483
484
485 struct Bar<T>(T);
486
487 // Add Type Parameter To Impl --------------------------------------------------
488 #[cfg(cfail1)]
489 impl Bar<u32> {
490     pub fn add_type_parameter_to_impl(&self) { }
491 }
492
493 #[cfg(not(cfail1))]
494 #[rustc_dirty(label="Hir", cfg="cfail2")]
495 #[rustc_clean(label="Hir", cfg="cfail3")]
496 #[rustc_metadata_dirty(cfg="cfail2")]
497 #[rustc_metadata_clean(cfg="cfail3")]
498 impl<T> Bar<T> {
499     #[rustc_clean(label="Hir", cfg="cfail2")]
500     #[rustc_clean(label="Hir", cfg="cfail3")]
501     #[rustc_metadata_dirty(cfg="cfail2")]
502     #[rustc_metadata_clean(cfg="cfail3")]
503     pub fn add_type_parameter_to_impl(&self) { }
504 }
505
506
507
508 // Change Self Type of Impl ----------------------------------------------------
509 #[cfg(cfail1)]
510 impl Bar<u32> {
511     pub fn change_impl_self_type(&self) { }
512 }
513
514 #[cfg(not(cfail1))]
515 #[rustc_dirty(label="Hir", cfg="cfail2")]
516 #[rustc_clean(label="Hir", cfg="cfail3")]
517 #[rustc_metadata_dirty(cfg="cfail2")]
518 #[rustc_metadata_clean(cfg="cfail3")]
519 impl Bar<u64> {
520     #[rustc_clean(label="Hir", cfg="cfail2")]
521     #[rustc_clean(label="Hir", cfg="cfail3")]
522     #[rustc_metadata_dirty(cfg="cfail2")]
523     #[rustc_metadata_clean(cfg="cfail3")]
524     pub fn change_impl_self_type(&self) { }
525 }
526
527
528
529 // Add Lifetime Bound to Impl --------------------------------------------------
530 #[cfg(cfail1)]
531 impl<T> Bar<T> {
532     pub fn add_lifetime_bound_to_impl_parameter(&self) { }
533 }
534
535 #[cfg(not(cfail1))]
536 #[rustc_dirty(label="Hir", cfg="cfail2")]
537 #[rustc_clean(label="Hir", cfg="cfail3")]
538 #[rustc_metadata_dirty(cfg="cfail2")]
539 #[rustc_metadata_clean(cfg="cfail3")]
540 impl<T: 'static> Bar<T> {
541     #[rustc_clean(label="Hir", cfg="cfail2")]
542     #[rustc_clean(label="Hir", cfg="cfail3")]
543     #[rustc_metadata_clean(cfg="cfail2")]
544     #[rustc_metadata_clean(cfg="cfail3")]
545     pub fn add_lifetime_bound_to_impl_parameter(&self) { }
546 }
547
548
549
550 // Add Trait Bound to Impl Parameter -------------------------------------------
551 #[cfg(cfail1)]
552 impl<T> Bar<T> {
553     pub fn add_trait_bound_to_impl_parameter(&self) { }
554 }
555
556 #[cfg(not(cfail1))]
557 #[rustc_dirty(label="Hir", cfg="cfail2")]
558 #[rustc_clean(label="Hir", cfg="cfail3")]
559 #[rustc_metadata_dirty(cfg="cfail2")]
560 #[rustc_metadata_clean(cfg="cfail3")]
561 impl<T: Clone> Bar<T> {
562     #[rustc_clean(label="Hir", cfg="cfail2")]
563     #[rustc_clean(label="Hir", cfg="cfail3")]
564     #[rustc_metadata_clean(cfg="cfail2")]
565     #[rustc_metadata_clean(cfg="cfail3")]
566     pub fn add_trait_bound_to_impl_parameter(&self) { }
567 }