]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/inherent_impls.rs
Fix invalid associated type rendering in rustdoc
[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_dirty(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_dirty(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_dirty(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     // At the moment we explicitly ignore argument names in metadata, since they
223     // are not used in downstream crates (except in rustdoc)
224     #[rustc_metadata_clean(cfg="cfail2")]
225     #[rustc_metadata_clean(cfg="cfail3")]
226     pub fn change_method_parameter_name(&self, b: i64) { }
227 }
228
229
230
231 // Change Method Return Type ---------------------------------------------------
232 #[cfg(cfail1)]
233 impl Foo {
234     pub fn change_method_return_type(&self) -> u16 { 0 }
235 }
236
237 #[cfg(not(cfail1))]
238 #[rustc_clean(label="Hir", cfg="cfail2")]
239 #[rustc_clean(label="Hir", cfg="cfail3")]
240 #[rustc_metadata_clean(cfg="cfail2")]
241 #[rustc_metadata_clean(cfg="cfail3")]
242 impl Foo {
243     #[rustc_dirty(label="Hir", cfg="cfail2")]
244     #[rustc_clean(label="Hir", cfg="cfail3")]
245     #[rustc_metadata_dirty(cfg="cfail2")]
246     #[rustc_metadata_clean(cfg="cfail3")]
247     pub fn change_method_return_type(&self) -> u8 { 0 }
248 }
249
250
251
252 // Make Method #[inline] -------------------------------------------------------
253 #[cfg(cfail1)]
254 impl Foo {
255     pub fn make_method_inline(&self) -> u8 { 0 }
256 }
257
258 #[cfg(not(cfail1))]
259 #[rustc_clean(label="Hir", cfg="cfail2")]
260 #[rustc_clean(label="Hir", cfg="cfail3")]
261 #[rustc_metadata_clean(cfg="cfail2")]
262 #[rustc_metadata_clean(cfg="cfail3")]
263 impl Foo {
264     #[rustc_dirty(label="Hir", cfg="cfail2")]
265     #[rustc_clean(label="Hir", cfg="cfail3")]
266     #[rustc_metadata_dirty(cfg="cfail2")]
267     #[rustc_metadata_clean(cfg="cfail3")]
268     #[inline]
269     pub fn make_method_inline(&self) -> u8 { 0 }
270 }
271
272
273
274 //  Change order of parameters -------------------------------------------------
275 #[cfg(cfail1)]
276 impl Foo {
277     pub fn change_method_parameter_order(&self, a: i64, b: i64) { }
278 }
279
280 #[cfg(not(cfail1))]
281 #[rustc_clean(label="Hir", cfg="cfail2")]
282 #[rustc_clean(label="Hir", cfg="cfail3")]
283 #[rustc_metadata_clean(cfg="cfail2")]
284 #[rustc_metadata_clean(cfg="cfail3")]
285 impl Foo {
286     #[rustc_clean(label="Hir", cfg="cfail2")]
287     #[rustc_clean(label="Hir", cfg="cfail3")]
288     #[rustc_dirty(label="HirBody", cfg="cfail2")]
289     #[rustc_clean(label="HirBody", cfg="cfail3")]
290     // At the moment we explicitly ignore argument names in metadata, since they
291     // are not used in downstream crates (except in rustdoc)
292     #[rustc_metadata_clean(cfg="cfail2")]
293     #[rustc_metadata_clean(cfg="cfail3")]
294     pub fn change_method_parameter_order(&self, b: i64, a: i64) { }
295 }
296
297
298
299 // Make method unsafe ----------------------------------------------------------
300 #[cfg(cfail1)]
301 impl Foo {
302     pub fn make_method_unsafe(&self) { }
303 }
304
305 #[cfg(not(cfail1))]
306 #[rustc_clean(label="Hir", cfg="cfail2")]
307 #[rustc_clean(label="Hir", cfg="cfail3")]
308 #[rustc_metadata_clean(cfg="cfail2")]
309 #[rustc_metadata_clean(cfg="cfail3")]
310 impl Foo {
311     #[rustc_dirty(label="Hir", cfg="cfail2")]
312     #[rustc_clean(label="Hir", cfg="cfail3")]
313     #[rustc_metadata_dirty(cfg="cfail2")]
314     #[rustc_metadata_clean(cfg="cfail3")]
315     pub unsafe fn make_method_unsafe(&self) { }
316 }
317
318
319
320 // Make method extern ----------------------------------------------------------
321 #[cfg(cfail1)]
322 impl Foo {
323     pub fn make_method_extern(&self) { }
324 }
325
326 #[cfg(not(cfail1))]
327 #[rustc_clean(label="Hir", cfg="cfail2")]
328 #[rustc_clean(label="Hir", cfg="cfail3")]
329 #[rustc_metadata_clean(cfg="cfail2")]
330 #[rustc_metadata_clean(cfg="cfail3")]
331 impl Foo {
332     #[rustc_dirty(label="Hir", cfg="cfail2")]
333     #[rustc_clean(label="Hir", cfg="cfail3")]
334     #[rustc_metadata_dirty(cfg="cfail2")]
335     #[rustc_metadata_clean(cfg="cfail3")]
336     pub extern fn make_method_extern(&self) { }
337 }
338
339
340
341 // Change method calling convention --------------------------------------------
342 #[cfg(cfail1)]
343 impl Foo {
344     pub extern "C" fn change_method_calling_convention(&self) { }
345 }
346
347 #[cfg(not(cfail1))]
348 #[rustc_clean(label="Hir", cfg="cfail2")]
349 #[rustc_clean(label="Hir", cfg="cfail3")]
350 #[rustc_metadata_clean(cfg="cfail2")]
351 #[rustc_metadata_clean(cfg="cfail3")]
352 impl Foo {
353     #[rustc_dirty(label="Hir", cfg="cfail2")]
354     #[rustc_clean(label="Hir", cfg="cfail3")]
355     #[rustc_metadata_dirty(cfg="cfail2")]
356     #[rustc_metadata_clean(cfg="cfail3")]
357     pub extern "system" fn change_method_calling_convention(&self) { }
358 }
359
360
361
362 // Add Lifetime Parameter to Method --------------------------------------------
363 #[cfg(cfail1)]
364 impl Foo {
365     pub fn add_lifetime_parameter_to_method(&self) { }
366 }
367
368 #[cfg(not(cfail1))]
369 #[rustc_clean(label="Hir", cfg="cfail2")]
370 #[rustc_clean(label="Hir", cfg="cfail3")]
371 #[rustc_metadata_clean(cfg="cfail2")]
372 #[rustc_metadata_clean(cfg="cfail3")]
373 impl Foo {
374     #[rustc_dirty(label="Hir", cfg="cfail2")]
375     #[rustc_clean(label="Hir", cfg="cfail3")]
376     #[rustc_metadata_dirty(cfg="cfail2")]
377     #[rustc_metadata_clean(cfg="cfail3")]
378     pub fn add_lifetime_parameter_to_method<'a>(&self) { }
379 }
380
381
382
383 // Add Type Parameter To Method ------------------------------------------------
384 #[cfg(cfail1)]
385 impl Foo {
386     pub fn add_type_parameter_to_method(&self) { }
387 }
388
389 #[cfg(not(cfail1))]
390 #[rustc_clean(label="Hir", cfg="cfail2")]
391 #[rustc_clean(label="Hir", cfg="cfail3")]
392 #[rustc_metadata_clean(cfg="cfail2")]
393 #[rustc_metadata_clean(cfg="cfail3")]
394 impl Foo {
395     #[rustc_dirty(label="Hir", cfg="cfail2")]
396     #[rustc_clean(label="Hir", cfg="cfail3")]
397     #[rustc_metadata_dirty(cfg="cfail2")]
398     #[rustc_metadata_clean(cfg="cfail3")]
399     pub fn add_type_parameter_to_method<T>(&self) { }
400 }
401
402
403
404 // Add Lifetime Bound to Lifetime Parameter of Method --------------------------
405 #[cfg(cfail1)]
406 impl Foo {
407     pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b>(&self) { }
408 }
409
410 #[cfg(not(cfail1))]
411 #[rustc_clean(label="Hir", cfg="cfail2")]
412 #[rustc_clean(label="Hir", cfg="cfail3")]
413 #[rustc_metadata_clean(cfg="cfail2")]
414 #[rustc_metadata_clean(cfg="cfail3")]
415 impl Foo {
416     #[rustc_dirty(label="Hir", cfg="cfail2")]
417     #[rustc_clean(label="Hir", cfg="cfail3")]
418     #[rustc_metadata_dirty(cfg="cfail2")]
419     #[rustc_metadata_clean(cfg="cfail3")]
420     pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b: 'a>(&self) { }
421 }
422
423
424
425 // Add Lifetime Bound to Type Parameter of Method ------------------------------
426 #[cfg(cfail1)]
427 impl Foo {
428     pub fn add_lifetime_bound_to_type_param_of_method<'a, T>(&self) { }
429 }
430
431 #[cfg(not(cfail1))]
432 #[rustc_clean(label="Hir", cfg="cfail2")]
433 #[rustc_clean(label="Hir", cfg="cfail3")]
434 #[rustc_metadata_clean(cfg="cfail2")]
435 #[rustc_metadata_clean(cfg="cfail3")]
436 impl Foo {
437     #[rustc_dirty(label="Hir", cfg="cfail2")]
438     #[rustc_clean(label="Hir", cfg="cfail3")]
439     #[rustc_metadata_dirty(cfg="cfail2")]
440     #[rustc_metadata_clean(cfg="cfail3")]
441     pub fn add_lifetime_bound_to_type_param_of_method<'a, T: 'a>(&self) { }
442 }
443
444
445
446 // Add Trait Bound to Type Parameter of Method ------------------------------
447 #[cfg(cfail1)]
448 impl Foo {
449     pub fn add_trait_bound_to_type_param_of_method<T>(&self) { }
450 }
451
452 #[cfg(not(cfail1))]
453 #[rustc_clean(label="Hir", cfg="cfail2")]
454 #[rustc_clean(label="Hir", cfg="cfail3")]
455 #[rustc_metadata_clean(cfg="cfail2")]
456 #[rustc_metadata_clean(cfg="cfail3")]
457 impl Foo {
458     #[rustc_dirty(label="Hir", cfg="cfail2")]
459     #[rustc_clean(label="Hir", cfg="cfail3")]
460     #[rustc_metadata_dirty(cfg="cfail2")]
461     #[rustc_metadata_clean(cfg="cfail3")]
462     pub fn add_trait_bound_to_type_param_of_method<T: Clone>(&self) { }
463 }
464
465
466
467 // Add #[no_mangle] to Method --------------------------------------------------
468 #[cfg(cfail1)]
469 impl Foo {
470     pub fn add_no_mangle_to_method(&self) { }
471 }
472
473 #[cfg(not(cfail1))]
474 #[rustc_clean(label="Hir", cfg="cfail2")]
475 #[rustc_clean(label="Hir", cfg="cfail3")]
476 #[rustc_metadata_clean(cfg="cfail2")]
477 #[rustc_metadata_clean(cfg="cfail3")]
478 impl Foo {
479     #[rustc_dirty(label="Hir", cfg="cfail2")]
480     #[rustc_clean(label="Hir", cfg="cfail3")]
481     #[rustc_metadata_dirty(cfg="cfail2")]
482     #[rustc_metadata_clean(cfg="cfail3")]
483     #[no_mangle]
484     pub fn add_no_mangle_to_method(&self) { }
485 }
486
487
488
489 struct Bar<T>(T);
490
491 // Add Type Parameter To Impl --------------------------------------------------
492 #[cfg(cfail1)]
493 impl Bar<u32> {
494     pub fn add_type_parameter_to_impl(&self) { }
495 }
496
497 #[cfg(not(cfail1))]
498 #[rustc_dirty(label="Hir", cfg="cfail2")]
499 #[rustc_clean(label="Hir", cfg="cfail3")]
500 #[rustc_metadata_dirty(cfg="cfail2")]
501 #[rustc_metadata_clean(cfg="cfail3")]
502 impl<T> Bar<T> {
503     #[rustc_clean(label="Hir", cfg="cfail2")]
504     #[rustc_clean(label="Hir", cfg="cfail3")]
505     #[rustc_metadata_dirty(cfg="cfail2")]
506     #[rustc_metadata_clean(cfg="cfail3")]
507     pub fn add_type_parameter_to_impl(&self) { }
508 }
509
510
511
512 // Change Self Type of Impl ----------------------------------------------------
513 #[cfg(cfail1)]
514 impl Bar<u32> {
515     pub fn change_impl_self_type(&self) { }
516 }
517
518 #[cfg(not(cfail1))]
519 #[rustc_dirty(label="Hir", cfg="cfail2")]
520 #[rustc_clean(label="Hir", cfg="cfail3")]
521 #[rustc_metadata_dirty(cfg="cfail2")]
522 #[rustc_metadata_clean(cfg="cfail3")]
523 impl Bar<u64> {
524     #[rustc_clean(label="Hir", cfg="cfail2")]
525     #[rustc_clean(label="Hir", cfg="cfail3")]
526     #[rustc_metadata_dirty(cfg="cfail2")]
527     #[rustc_metadata_clean(cfg="cfail3")]
528     pub fn change_impl_self_type(&self) { }
529 }
530
531
532
533 // Add Lifetime Bound to Impl --------------------------------------------------
534 #[cfg(cfail1)]
535 impl<T> Bar<T> {
536     pub fn add_lifetime_bound_to_impl_parameter(&self) { }
537 }
538
539 #[cfg(not(cfail1))]
540 #[rustc_dirty(label="Hir", cfg="cfail2")]
541 #[rustc_clean(label="Hir", cfg="cfail3")]
542 #[rustc_metadata_dirty(cfg="cfail2")]
543 #[rustc_metadata_clean(cfg="cfail3")]
544 impl<T: 'static> Bar<T> {
545     #[rustc_clean(label="Hir", cfg="cfail2")]
546     #[rustc_clean(label="Hir", cfg="cfail3")]
547     #[rustc_metadata_dirty(cfg="cfail2")]
548     #[rustc_metadata_clean(cfg="cfail3")]
549     pub fn add_lifetime_bound_to_impl_parameter(&self) { }
550 }
551
552
553
554 // Add Trait Bound to Impl Parameter -------------------------------------------
555 #[cfg(cfail1)]
556 impl<T> Bar<T> {
557     pub fn add_trait_bound_to_impl_parameter(&self) { }
558 }
559
560 #[cfg(not(cfail1))]
561 #[rustc_dirty(label="Hir", cfg="cfail2")]
562 #[rustc_clean(label="Hir", cfg="cfail3")]
563 #[rustc_metadata_dirty(cfg="cfail2")]
564 #[rustc_metadata_clean(cfg="cfail3")]
565 impl<T: Clone> Bar<T> {
566     #[rustc_clean(label="Hir", cfg="cfail2")]
567     #[rustc_clean(label="Hir", cfg="cfail3")]
568     #[rustc_metadata_dirty(cfg="cfail2")]
569     #[rustc_metadata_clean(cfg="cfail3")]
570     pub fn add_trait_bound_to_impl_parameter(&self) { }
571 }