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.
19 // must-compile-successfully
20 // revisions: cfail1 cfail2 cfail3
21 // compile-flags: -Z query-dep-graph
25 #![feature(conservative_impl_trait)]
26 #![feature(intrinsics)]
28 #![feature(rustc_attrs)]
32 // Add Parameter ---------------------------------------------------------------
38 #[rustc_dirty(label="Hir", cfg="cfail2")]
39 #[rustc_clean(label="Hir", cfg="cfail3")]
40 #[rustc_metadata_dirty(cfg="cfail2")]
41 #[rustc_metadata_clean(cfg="cfail3")]
42 fn add_parameter(p
: i32) {}
45 // Add Return Type -------------------------------------------------------------
48 fn add_return_type() {}
51 #[rustc_dirty(label="Hir", cfg="cfail2")]
52 #[rustc_clean(label="Hir", cfg="cfail3")]
53 #[rustc_metadata_dirty(cfg="cfail2")]
54 #[rustc_metadata_clean(cfg="cfail3")]
55 fn add_return_type() -> () {}
58 // Change Parameter Type -------------------------------------------------------
61 fn type_of_parameter(p
: i32) {}
64 #[rustc_dirty(label="Hir", cfg="cfail2")]
65 #[rustc_clean(label="Hir", cfg="cfail3")]
66 #[rustc_metadata_dirty(cfg="cfail2")]
67 #[rustc_metadata_clean(cfg="cfail3")]
68 fn type_of_parameter(p
: i64) {}
71 // Change Parameter Type Reference ---------------------------------------------
74 fn type_of_parameter_ref(p
: &i32) {}
77 #[rustc_dirty(label="Hir", cfg="cfail2")]
78 #[rustc_clean(label="Hir", cfg="cfail3")]
79 #[rustc_metadata_dirty(cfg="cfail2")]
80 #[rustc_metadata_clean(cfg="cfail3")]
81 fn type_of_parameter_ref(p
: &mut i32) {}
84 // Change Parameter Order ------------------------------------------------------
87 fn order_of_parameters(p1
: i32, p2
: i64) {}
90 #[rustc_dirty(label="Hir", cfg="cfail2")]
91 #[rustc_clean(label="Hir", cfg="cfail3")]
92 #[rustc_metadata_dirty(cfg="cfail2")]
93 #[rustc_metadata_clean(cfg="cfail3")]
94 fn order_of_parameters(p2
: i64, p1
: i32) {}
97 // Unsafe ----------------------------------------------------------------------
103 #[rustc_dirty(label="Hir", cfg="cfail2")]
104 #[rustc_clean(label="Hir", cfg="cfail3")]
105 #[rustc_metadata_dirty(cfg="cfail2")]
106 #[rustc_metadata_clean(cfg="cfail3")]
107 unsafe fn make_unsafe() {}
110 // Extern ----------------------------------------------------------------------
116 #[rustc_dirty(label="Hir", cfg="cfail2")]
117 #[rustc_clean(label="Hir", cfg="cfail3")]
118 #[rustc_metadata_dirty(cfg="cfail2")]
119 #[rustc_metadata_clean(cfg="cfail3")]
120 extern fn make_extern() {}
123 // Extern C Extern Rust-Intrinsic ----------------------------------------------
126 extern "C" fn make_intrinsic() {}
129 #[rustc_dirty(label="Hir", cfg="cfail2")]
130 #[rustc_clean(label="Hir", cfg="cfail3")]
131 #[rustc_metadata_dirty(cfg="cfail2")]
132 #[rustc_metadata_clean(cfg="cfail3")]
133 extern "rust-intrinsic" fn make_intrinsic() {}
136 // Type Parameter --------------------------------------------------------------
139 fn type_parameter() {}
142 #[rustc_dirty(label="Hir", cfg="cfail2")]
143 #[rustc_clean(label="Hir", cfg="cfail3")]
144 #[rustc_metadata_dirty(cfg="cfail2")]
145 #[rustc_metadata_clean(cfg="cfail3")]
146 fn type_parameter
<T
>() {}
149 // Lifetime Parameter ----------------------------------------------------------
152 fn lifetime_parameter() {}
155 #[rustc_dirty(label="Hir", cfg="cfail2")]
156 #[rustc_clean(label="Hir", cfg="cfail3")]
157 #[rustc_metadata_dirty(cfg="cfail2")]
158 #[rustc_metadata_clean(cfg="cfail3")]
159 fn lifetime_parameter
<'a
>() {}
162 // Trait Bound -----------------------------------------------------------------
165 fn trait_bound
<T
>() {}
168 #[rustc_dirty(label="Hir", cfg="cfail2")]
169 #[rustc_clean(label="Hir", cfg="cfail3")]
170 #[rustc_metadata_dirty(cfg="cfail2")]
171 #[rustc_metadata_clean(cfg="cfail3")]
172 fn trait_bound
<T
: Eq
>() {}
175 // Builtin Bound ---------------------------------------------------------------
178 fn builtin_bound
<T
>() {}
181 #[rustc_dirty(label="Hir", cfg="cfail2")]
182 #[rustc_clean(label="Hir", cfg="cfail3")]
183 #[rustc_metadata_dirty(cfg="cfail2")]
184 #[rustc_metadata_clean(cfg="cfail3")]
185 fn builtin_bound
<T
: Send
>() {}
188 // Lifetime Bound --------------------------------------------------------------
191 fn lifetime_bound
<'a
, T
>() {}
194 #[rustc_dirty(label="Hir", cfg="cfail2")]
195 #[rustc_clean(label="Hir", cfg="cfail3")]
196 #[rustc_metadata_dirty(cfg="cfail2")]
197 #[rustc_metadata_clean(cfg="cfail3")]
198 fn lifetime_bound
<'a
, T
: 'a
>() {}
201 // Second Trait Bound ----------------------------------------------------------
204 fn second_trait_bound
<T
: Eq
>() {}
207 #[rustc_dirty(label="Hir", cfg="cfail2")]
208 #[rustc_clean(label="Hir", cfg="cfail3")]
209 #[rustc_metadata_dirty(cfg="cfail2")]
210 #[rustc_metadata_clean(cfg="cfail3")]
211 fn second_trait_bound
<T
: Eq
+ Clone
>() {}
214 // Second Builtin Bound --------------------------------------------------------
217 fn second_builtin_bound
<T
: Send
>() {}
220 #[rustc_dirty(label="Hir", cfg="cfail2")]
221 #[rustc_clean(label="Hir", cfg="cfail3")]
222 #[rustc_metadata_dirty(cfg="cfail2")]
223 #[rustc_metadata_clean(cfg="cfail3")]
224 fn second_builtin_bound
<T
: Send
+ Sized
>() {}
227 // Second Lifetime Bound -------------------------------------------------------
230 fn second_lifetime_bound
<'a
, 'b
, T
: 'a
>() {}
233 #[rustc_dirty(label="Hir", cfg="cfail2")]
234 #[rustc_clean(label="Hir", cfg="cfail3")]
235 #[rustc_metadata_dirty(cfg="cfail2")]
236 #[rustc_metadata_clean(cfg="cfail3")]
237 fn second_lifetime_bound
<'a
, 'b
, T
: 'a
+ 'b
>() {}
240 // Inline ----------------------------------------------------------------------
246 #[rustc_dirty(label="Hir", cfg="cfail2")]
247 #[rustc_clean(label="Hir", cfg="cfail3")]
248 #[rustc_metadata_dirty(cfg="cfail2")]
249 #[rustc_metadata_clean(cfg="cfail3")]
254 // Inline Never ----------------------------------------------------------------
261 #[rustc_dirty(label="Hir", cfg="cfail2")]
262 #[rustc_clean(label="Hir", cfg="cfail3")]
263 #[rustc_metadata_dirty(cfg="cfail2")]
264 #[rustc_metadata_clean(cfg="cfail3")]
269 // No Mangle -------------------------------------------------------------------
275 #[rustc_dirty(label="Hir", cfg="cfail2")]
276 #[rustc_clean(label="Hir", cfg="cfail3")]
277 #[rustc_metadata_dirty(cfg="cfail2")]
278 #[rustc_metadata_clean(cfg="cfail3")]
283 // Linkage ---------------------------------------------------------------------
289 #[rustc_dirty(label="Hir", cfg="cfail2")]
290 #[rustc_clean(label="Hir", cfg="cfail3")]
291 #[rustc_metadata_dirty(cfg="cfail2")]
292 #[rustc_metadata_clean(cfg="cfail3")]
293 #[linkage="weak_odr"]
297 // Return Impl Trait -----------------------------------------------------------
300 fn return_impl_trait() -> i32 {
305 #[rustc_dirty(label="Hir", cfg="cfail2")]
306 #[rustc_clean(label="Hir", cfg="cfail3")]
307 #[rustc_metadata_dirty(cfg="cfail2")]
308 #[rustc_metadata_clean(cfg="cfail3")]
309 fn return_impl_trait() -> impl Clone
{
314 // Change Return Impl Trait ----------------------------------------------------
317 fn change_return_impl_trait() -> impl Clone
{
322 #[rustc_dirty(label="Hir", cfg="cfail2")]
323 #[rustc_clean(label="Hir", cfg="cfail3")]
324 #[rustc_metadata_dirty(cfg="cfail2")]
325 #[rustc_metadata_clean(cfg="cfail3")]
326 fn change_return_impl_trait() -> impl Copy
{
331 // Change Return Type Indirectly -----------------------------------------------
333 struct ReferencedType1
;
334 struct ReferencedType2
;
336 mod change_return_type_indirectly
{
338 use super::ReferencedType1
as ReturnType
;
340 use super::ReferencedType2
as ReturnType
;
342 #[rustc_dirty(label="Hir", cfg="cfail2")]
343 #[rustc_clean(label="Hir", cfg="cfail3")]
344 #[rustc_metadata_dirty(cfg="cfail2")]
345 #[rustc_metadata_clean(cfg="cfail3")]
346 fn indirect_return_type() -> ReturnType
{
352 // Change Parameter Type Indirectly --------------------------------------------
354 mod change_parameter_type_indirectly
{
356 use super::ReferencedType1
as ParameterType
;
358 use super::ReferencedType2
as ParameterType
;
360 #[rustc_dirty(label="Hir", cfg="cfail2")]
361 #[rustc_clean(label="Hir", cfg="cfail3")]
362 #[rustc_metadata_dirty(cfg="cfail2")]
363 #[rustc_metadata_clean(cfg="cfail3")]
364 fn indirect_parameter_type(p
: ParameterType
) {}
368 // Change Trait Bound Indirectly -----------------------------------------------
370 trait ReferencedTrait1 {}
371 trait ReferencedTrait2 {}
373 mod change_trait_bound_indirectly
{
375 use super::ReferencedTrait1
as Trait
;
377 use super::ReferencedTrait2
as Trait
;
379 #[rustc_dirty(label="Hir", cfg="cfail2")]
380 #[rustc_clean(label="Hir", cfg="cfail3")]
381 #[rustc_metadata_dirty(cfg="cfail2")]
382 #[rustc_metadata_clean(cfg="cfail3")]
383 fn indirect_trait_bound
<T
: Trait
>(p
: T
) {}
387 // Change Trait Bound Indirectly In Where Clause -------------------------------
389 mod change_trait_bound_indirectly_in_where_clause
{
391 use super::ReferencedTrait1
as Trait
;
393 use super::ReferencedTrait2
as Trait
;
395 #[rustc_dirty(label="Hir", cfg="cfail2")]
396 #[rustc_clean(label="Hir", cfg="cfail3")]
397 #[rustc_metadata_dirty(cfg="cfail2")]
398 #[rustc_metadata_clean(cfg="cfail3")]
399 fn indirect_trait_bound_where
<T
>(p
: T
) where T
: Trait {}