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