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.
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.
12 // This test case tests the incremental compilation hash (ICH) implementation
13 // for function interfaces.
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.
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
25 #![feature(intrinsics)]
27 #![feature(rustc_attrs)]
28 #![crate_type = "rlib"]
31 // Add Parameter ---------------------------------------------------------------
34 pub fn add_parameter() {}
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) {}
43 // Add Return Type -------------------------------------------------------------
46 pub fn add_return_type() {}
49 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
50 #[rustc_clean(cfg = "cfail3")]
51 pub fn add_return_type() -> () {}
54 // Change Parameter Type -------------------------------------------------------
57 pub fn type_of_parameter(p: i32) {}
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) {}
66 // Change Parameter Type Reference ---------------------------------------------
69 pub fn type_of_parameter_ref(p: &i32) {}
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) {}
78 // Change Parameter Order ------------------------------------------------------
81 pub fn order_of_parameters(p1: i32, p2: i64) {}
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) {}
90 // Unsafe ----------------------------------------------------------------------
93 pub fn make_unsafe() {}
96 #[rustc_clean(cfg = "cfail2",
97 except = "Hir, HirBody, MirValidated, MirOptimized, TypeckTables, FnSignature")]
98 #[rustc_clean(cfg = "cfail3")]
99 pub unsafe fn make_unsafe() {}
102 // Extern ----------------------------------------------------------------------
105 pub fn make_extern() {}
108 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, TypeckTables, FnSignature")]
109 #[rustc_clean(cfg = "cfail3")]
110 pub extern "C" fn make_extern() {}
113 // Extern C Extern Rust-Intrinsic ----------------------------------------------
116 pub extern "C" fn make_intrinsic() {}
119 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, TypeckTables, FnSignature")]
120 #[rustc_clean(cfg = "cfail3")]
121 pub extern "rust-intrinsic" fn make_intrinsic() {}
124 // Type Parameter --------------------------------------------------------------
127 pub fn type_parameter() {}
130 #[rustc_clean(cfg = "cfail2",
131 except = "Hir, HirBody, GenericsOfItem, TypeOfItem, PredicatesOfItem")]
132 #[rustc_clean(cfg = "cfail3")]
133 pub fn type_parameter<T>() {}
136 // Lifetime Parameter ----------------------------------------------------------
139 pub fn lifetime_parameter() {}
142 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, GenericsOfItem")]
143 #[rustc_clean(cfg = "cfail3")]
144 pub fn lifetime_parameter<'a>() {}
147 // Trait Bound -----------------------------------------------------------------
150 pub fn trait_bound<T>() {}
153 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
154 #[rustc_clean(cfg = "cfail3")]
155 pub fn trait_bound<T: Eq>() {}
158 // Builtin Bound ---------------------------------------------------------------
161 pub fn builtin_bound<T>() {}
164 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
165 #[rustc_clean(cfg = "cfail3")]
166 pub fn builtin_bound<T: Send>() {}
169 // Lifetime Bound --------------------------------------------------------------
172 pub fn lifetime_bound<'a, T>() {}
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>() {}
181 // Second Trait Bound ----------------------------------------------------------
184 pub fn second_trait_bound<T: Eq>() {}
187 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
188 #[rustc_clean(cfg = "cfail3")]
189 pub fn second_trait_bound<T: Eq + Clone>() {}
192 // Second Builtin Bound --------------------------------------------------------
195 pub fn second_builtin_bound<T: Send>() {}
198 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
199 #[rustc_clean(cfg = "cfail3")]
200 pub fn second_builtin_bound<T: Send + Sized>() {}
203 // Second Lifetime Bound -------------------------------------------------------
206 pub fn second_lifetime_bound<'a, 'b, T: 'a>() {}
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>() {}
215 // Inline ----------------------------------------------------------------------
221 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
222 #[rustc_clean(cfg = "cfail3")]
227 // Inline Never ----------------------------------------------------------------
231 pub fn inline_never() {}
234 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
235 #[rustc_clean(cfg = "cfail3")]
237 pub fn inline_never() {}
240 // No Mangle -------------------------------------------------------------------
243 pub fn no_mangle() {}
246 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
247 #[rustc_clean(cfg = "cfail3")]
249 pub fn no_mangle() {}
252 // Linkage ---------------------------------------------------------------------
258 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
259 #[rustc_clean(cfg = "cfail3")]
260 #[linkage = "weak_odr"]
264 // Return Impl Trait -----------------------------------------------------------
267 pub fn return_impl_trait() -> i32 {
272 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, TypeckTables, FnSignature")]
273 #[rustc_clean(cfg = "cfail3")]
274 pub fn return_impl_trait() -> impl Clone {
279 // Change Return Impl Trait ----------------------------------------------------
282 pub fn change_return_impl_trait() -> impl Clone {
287 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
288 #[rustc_clean(cfg = "cfail3")]
289 pub fn change_return_impl_trait() -> impl Copy {
294 // Change Return Type Indirectly -----------------------------------------------
296 pub struct ReferencedType1;
297 pub struct ReferencedType2;
299 pub mod change_return_type_indirectly {
301 use super::ReferencedType1 as ReturnType;
303 use super::ReferencedType2 as ReturnType;
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 {
314 // Change Parameter Type Indirectly --------------------------------------------
316 pub mod change_parameter_type_indirectly {
318 use super::ReferencedType1 as ParameterType;
320 use super::ReferencedType2 as ParameterType;
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) {}
329 // Change Trait Bound Indirectly -----------------------------------------------
331 pub trait ReferencedTrait1 {}
332 pub trait ReferencedTrait2 {}
334 pub mod change_trait_bound_indirectly {
336 use super::ReferencedTrait1 as Trait;
338 use super::ReferencedTrait2 as Trait;
340 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
341 #[rustc_clean(cfg = "cfail3")]
342 pub fn indirect_trait_bound<T: Trait>(p: T) {}
346 // Change Trait Bound Indirectly In Where Clause -------------------------------
348 pub mod change_trait_bound_indirectly_in_where_clause {
350 use super::ReferencedTrait1 as Trait;
352 use super::ReferencedTrait2 as Trait;
354 #[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, PredicatesOfItem")]
355 #[rustc_clean(cfg = "cfail3")]
356 pub fn indirect_trait_bound_where<T>(p: T)