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