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