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