]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/function_interfaces.rs
Rollup merge of #41087 - estebank:tuple-float-index, r=arielb1
[rust.git] / src / test / incremental / hashes / function_interfaces.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 function interfaces.
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(conservative_impl_trait)]
26 #![feature(intrinsics)]
27 #![feature(linkage)]
28 #![feature(rustc_attrs)]
29 #![crate_type="rlib"]
30
31
32 // Add Parameter ---------------------------------------------------------------
33
34 #[cfg(cfail1)]
35 fn add_parameter() {}
36
37 #[cfg(not(cfail1))]
38 #[rustc_dirty(label="Hir", cfg="cfail2")]
39 #[rustc_clean(label="Hir", cfg="cfail3")]
40 #[rustc_metadata_dirty(cfg="cfail2")]
41 #[rustc_metadata_clean(cfg="cfail3")]
42 fn add_parameter(p: i32) {}
43
44
45 // Add Return Type -------------------------------------------------------------
46
47 #[cfg(cfail1)]
48 fn add_return_type() {}
49
50 #[cfg(not(cfail1))]
51 #[rustc_dirty(label="Hir", cfg="cfail2")]
52 #[rustc_clean(label="Hir", cfg="cfail3")]
53 #[rustc_metadata_dirty(cfg="cfail2")]
54 #[rustc_metadata_clean(cfg="cfail3")]
55 fn add_return_type() -> () {}
56
57
58 // Change Parameter Type -------------------------------------------------------
59
60 #[cfg(cfail1)]
61 fn type_of_parameter(p: i32) {}
62
63 #[cfg(not(cfail1))]
64 #[rustc_dirty(label="Hir", cfg="cfail2")]
65 #[rustc_clean(label="Hir", cfg="cfail3")]
66 #[rustc_metadata_dirty(cfg="cfail2")]
67 #[rustc_metadata_clean(cfg="cfail3")]
68 fn type_of_parameter(p: i64) {}
69
70
71 // Change Parameter Type Reference ---------------------------------------------
72
73 #[cfg(cfail1)]
74 fn type_of_parameter_ref(p: &i32) {}
75
76 #[cfg(not(cfail1))]
77 #[rustc_dirty(label="Hir", cfg="cfail2")]
78 #[rustc_clean(label="Hir", cfg="cfail3")]
79 #[rustc_metadata_dirty(cfg="cfail2")]
80 #[rustc_metadata_clean(cfg="cfail3")]
81 fn type_of_parameter_ref(p: &mut i32) {}
82
83
84 // Change Parameter Order ------------------------------------------------------
85
86 #[cfg(cfail1)]
87 fn order_of_parameters(p1: i32, p2: i64) {}
88
89 #[cfg(not(cfail1))]
90 #[rustc_dirty(label="Hir", cfg="cfail2")]
91 #[rustc_clean(label="Hir", cfg="cfail3")]
92 #[rustc_metadata_dirty(cfg="cfail2")]
93 #[rustc_metadata_clean(cfg="cfail3")]
94 fn order_of_parameters(p2: i64, p1: i32) {}
95
96
97 // Unsafe ----------------------------------------------------------------------
98
99 #[cfg(cfail1)]
100 fn make_unsafe() {}
101
102 #[cfg(not(cfail1))]
103 #[rustc_dirty(label="Hir", cfg="cfail2")]
104 #[rustc_clean(label="Hir", cfg="cfail3")]
105 #[rustc_metadata_dirty(cfg="cfail2")]
106 #[rustc_metadata_clean(cfg="cfail3")]
107 unsafe fn make_unsafe() {}
108
109
110 // Extern ----------------------------------------------------------------------
111
112 #[cfg(cfail1)]
113 fn make_extern() {}
114
115 #[cfg(not(cfail1))]
116 #[rustc_dirty(label="Hir", cfg="cfail2")]
117 #[rustc_clean(label="Hir", cfg="cfail3")]
118 #[rustc_metadata_dirty(cfg="cfail2")]
119 #[rustc_metadata_clean(cfg="cfail3")]
120 extern fn make_extern() {}
121
122
123 // Extern C Extern Rust-Intrinsic ----------------------------------------------
124
125 #[cfg(cfail1)]
126 extern "C" fn make_intrinsic() {}
127
128 #[cfg(not(cfail1))]
129 #[rustc_dirty(label="Hir", cfg="cfail2")]
130 #[rustc_clean(label="Hir", cfg="cfail3")]
131 #[rustc_metadata_dirty(cfg="cfail2")]
132 #[rustc_metadata_clean(cfg="cfail3")]
133 extern "rust-intrinsic" fn make_intrinsic() {}
134
135
136 // Type Parameter --------------------------------------------------------------
137
138 #[cfg(cfail1)]
139 fn type_parameter() {}
140
141 #[cfg(not(cfail1))]
142 #[rustc_dirty(label="Hir", cfg="cfail2")]
143 #[rustc_clean(label="Hir", cfg="cfail3")]
144 #[rustc_metadata_dirty(cfg="cfail2")]
145 #[rustc_metadata_clean(cfg="cfail3")]
146 fn type_parameter<T>() {}
147
148
149 // Lifetime Parameter ----------------------------------------------------------
150
151 #[cfg(cfail1)]
152 fn lifetime_parameter() {}
153
154 #[cfg(not(cfail1))]
155 #[rustc_dirty(label="Hir", cfg="cfail2")]
156 #[rustc_clean(label="Hir", cfg="cfail3")]
157 #[rustc_metadata_dirty(cfg="cfail2")]
158 #[rustc_metadata_clean(cfg="cfail3")]
159 fn lifetime_parameter<'a>() {}
160
161
162 // Trait Bound -----------------------------------------------------------------
163
164 #[cfg(cfail1)]
165 fn trait_bound<T>() {}
166
167 #[cfg(not(cfail1))]
168 #[rustc_dirty(label="Hir", cfg="cfail2")]
169 #[rustc_clean(label="Hir", cfg="cfail3")]
170 #[rustc_metadata_dirty(cfg="cfail2")]
171 #[rustc_metadata_clean(cfg="cfail3")]
172 fn trait_bound<T: Eq>() {}
173
174
175 // Builtin Bound ---------------------------------------------------------------
176
177 #[cfg(cfail1)]
178 fn builtin_bound<T>() {}
179
180 #[cfg(not(cfail1))]
181 #[rustc_dirty(label="Hir", cfg="cfail2")]
182 #[rustc_clean(label="Hir", cfg="cfail3")]
183 #[rustc_metadata_dirty(cfg="cfail2")]
184 #[rustc_metadata_clean(cfg="cfail3")]
185 fn builtin_bound<T: Send>() {}
186
187
188 // Lifetime Bound --------------------------------------------------------------
189
190 #[cfg(cfail1)]
191 fn lifetime_bound<'a, T>() {}
192
193 #[cfg(not(cfail1))]
194 #[rustc_dirty(label="Hir", cfg="cfail2")]
195 #[rustc_clean(label="Hir", cfg="cfail3")]
196 #[rustc_metadata_dirty(cfg="cfail2")]
197 #[rustc_metadata_clean(cfg="cfail3")]
198 fn lifetime_bound<'a, T: 'a>() {}
199
200
201 // Second Trait Bound ----------------------------------------------------------
202
203 #[cfg(cfail1)]
204 fn second_trait_bound<T: Eq>() {}
205
206 #[cfg(not(cfail1))]
207 #[rustc_dirty(label="Hir", cfg="cfail2")]
208 #[rustc_clean(label="Hir", cfg="cfail3")]
209 #[rustc_metadata_dirty(cfg="cfail2")]
210 #[rustc_metadata_clean(cfg="cfail3")]
211 fn second_trait_bound<T: Eq + Clone>() {}
212
213
214 // Second Builtin Bound --------------------------------------------------------
215
216 #[cfg(cfail1)]
217 fn second_builtin_bound<T: Send>() {}
218
219 #[cfg(not(cfail1))]
220 #[rustc_dirty(label="Hir", cfg="cfail2")]
221 #[rustc_clean(label="Hir", cfg="cfail3")]
222 #[rustc_metadata_dirty(cfg="cfail2")]
223 #[rustc_metadata_clean(cfg="cfail3")]
224 fn second_builtin_bound<T: Send + Sized>() {}
225
226
227 // Second Lifetime Bound -------------------------------------------------------
228
229 #[cfg(cfail1)]
230 fn second_lifetime_bound<'a, 'b, T: 'a>() {}
231
232 #[cfg(not(cfail1))]
233 #[rustc_dirty(label="Hir", cfg="cfail2")]
234 #[rustc_clean(label="Hir", cfg="cfail3")]
235 #[rustc_metadata_dirty(cfg="cfail2")]
236 #[rustc_metadata_clean(cfg="cfail3")]
237 fn second_lifetime_bound<'a, 'b, T: 'a + 'b>() {}
238
239
240 // Inline ----------------------------------------------------------------------
241
242 #[cfg(cfail1)]
243 fn inline() {}
244
245 #[cfg(not(cfail1))]
246 #[rustc_dirty(label="Hir", cfg="cfail2")]
247 #[rustc_clean(label="Hir", cfg="cfail3")]
248 #[rustc_metadata_dirty(cfg="cfail2")]
249 #[rustc_metadata_clean(cfg="cfail3")]
250 #[inline]
251 fn inline() {}
252
253
254 // Inline Never ----------------------------------------------------------------
255
256 #[cfg(cfail1)]
257 #[inline(always)]
258 fn inline_never() {}
259
260 #[cfg(not(cfail1))]
261 #[rustc_dirty(label="Hir", cfg="cfail2")]
262 #[rustc_clean(label="Hir", cfg="cfail3")]
263 #[rustc_metadata_dirty(cfg="cfail2")]
264 #[rustc_metadata_clean(cfg="cfail3")]
265 #[inline(never)]
266 fn inline_never() {}
267
268
269 // No Mangle -------------------------------------------------------------------
270
271 #[cfg(cfail1)]
272 fn no_mangle() {}
273
274 #[cfg(not(cfail1))]
275 #[rustc_dirty(label="Hir", cfg="cfail2")]
276 #[rustc_clean(label="Hir", cfg="cfail3")]
277 #[rustc_metadata_dirty(cfg="cfail2")]
278 #[rustc_metadata_clean(cfg="cfail3")]
279 #[no_mangle]
280 fn no_mangle() {}
281
282
283 // Linkage ---------------------------------------------------------------------
284
285 #[cfg(cfail1)]
286 fn linkage() {}
287
288 #[cfg(not(cfail1))]
289 #[rustc_dirty(label="Hir", cfg="cfail2")]
290 #[rustc_clean(label="Hir", cfg="cfail3")]
291 #[rustc_metadata_dirty(cfg="cfail2")]
292 #[rustc_metadata_clean(cfg="cfail3")]
293 #[linkage="weak_odr"]
294 fn linkage() {}
295
296
297 // Return Impl Trait -----------------------------------------------------------
298
299 #[cfg(cfail1)]
300 fn return_impl_trait() -> i32 {
301     0
302 }
303
304 #[cfg(not(cfail1))]
305 #[rustc_dirty(label="Hir", cfg="cfail2")]
306 #[rustc_clean(label="Hir", cfg="cfail3")]
307 #[rustc_metadata_dirty(cfg="cfail2")]
308 #[rustc_metadata_clean(cfg="cfail3")]
309 fn return_impl_trait() -> impl Clone {
310     0
311 }
312
313
314 // Change Return Impl Trait ----------------------------------------------------
315
316 #[cfg(cfail1)]
317 fn change_return_impl_trait() -> impl Clone {
318     0
319 }
320
321 #[cfg(not(cfail1))]
322 #[rustc_dirty(label="Hir", cfg="cfail2")]
323 #[rustc_clean(label="Hir", cfg="cfail3")]
324 #[rustc_metadata_dirty(cfg="cfail2")]
325 #[rustc_metadata_clean(cfg="cfail3")]
326 fn change_return_impl_trait() -> impl Copy {
327     0
328 }
329
330
331 // Change Return Type Indirectly -----------------------------------------------
332
333 struct ReferencedType1;
334 struct ReferencedType2;
335
336 mod change_return_type_indirectly {
337     #[cfg(cfail1)]
338     use super::ReferencedType1 as ReturnType;
339     #[cfg(not(cfail1))]
340     use super::ReferencedType2 as ReturnType;
341
342     #[rustc_dirty(label="Hir", cfg="cfail2")]
343     #[rustc_clean(label="Hir", cfg="cfail3")]
344     #[rustc_metadata_dirty(cfg="cfail2")]
345     #[rustc_metadata_clean(cfg="cfail3")]
346     fn indirect_return_type() -> ReturnType {
347         ReturnType {}
348     }
349 }
350
351
352 // Change Parameter Type Indirectly --------------------------------------------
353
354 mod change_parameter_type_indirectly {
355     #[cfg(cfail1)]
356     use super::ReferencedType1 as ParameterType;
357     #[cfg(not(cfail1))]
358     use super::ReferencedType2 as ParameterType;
359
360     #[rustc_dirty(label="Hir", cfg="cfail2")]
361     #[rustc_clean(label="Hir", cfg="cfail3")]
362     #[rustc_metadata_dirty(cfg="cfail2")]
363     #[rustc_metadata_clean(cfg="cfail3")]
364     fn indirect_parameter_type(p: ParameterType) {}
365 }
366
367
368 // Change Trait Bound Indirectly -----------------------------------------------
369
370 trait ReferencedTrait1 {}
371 trait ReferencedTrait2 {}
372
373 mod change_trait_bound_indirectly {
374     #[cfg(cfail1)]
375     use super::ReferencedTrait1 as Trait;
376     #[cfg(not(cfail1))]
377     use super::ReferencedTrait2 as Trait;
378
379     #[rustc_dirty(label="Hir", cfg="cfail2")]
380     #[rustc_clean(label="Hir", cfg="cfail3")]
381     #[rustc_metadata_dirty(cfg="cfail2")]
382     #[rustc_metadata_clean(cfg="cfail3")]
383     fn indirect_trait_bound<T: Trait>(p: T) {}
384 }
385
386
387 // Change Trait Bound Indirectly In Where Clause -------------------------------
388
389 mod change_trait_bound_indirectly_in_where_clause {
390     #[cfg(cfail1)]
391     use super::ReferencedTrait1 as Trait;
392     #[cfg(not(cfail1))]
393     use super::ReferencedTrait2 as Trait;
394
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     fn indirect_trait_bound_where<T>(p: T) where T: Trait {}
400 }