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