1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for function interfaces.
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.
8 // build-pass (FIXME(62277): could be check-pass?)
9 // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
10 // compile-flags: -Z query-dep-graph -O
11 // [cfail1]compile-flags: -Zincremental-ignore-spans
12 // [cfail2]compile-flags: -Zincremental-ignore-spans
13 // [cfail3]compile-flags: -Zincremental-ignore-spans
14 // [cfail4]compile-flags: -Zincremental-relative-spans
15 // [cfail5]compile-flags: -Zincremental-relative-spans
16 // [cfail6]compile-flags: -Zincremental-relative-spans
20 #![feature(rustc_attrs)]
21 #![crate_type = "rlib"]
23 // Add Parameter ---------------------------------------------------------------
25 #[cfg(any(cfail1,cfail4))]
26 pub fn add_parameter() {}
28 #[cfg(not(any(cfail1,cfail4)))]
31 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
33 #[rustc_clean(cfg = "cfail3")]
36 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
38 #[rustc_clean(cfg = "cfail6")]
39 pub fn add_parameter(p: i32) {}
41 // Add Return Type -------------------------------------------------------------
43 #[cfg(any(cfail1,cfail4))]
44 pub fn add_return_type() {}
46 #[cfg(not(any(cfail1,cfail4)))]
47 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes")]
48 #[rustc_clean(cfg = "cfail3")]
49 #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, optimized_mir")]
50 #[rustc_clean(cfg = "cfail6")]
51 pub fn add_return_type() -> () {}
53 // Change Parameter Type -------------------------------------------------------
55 #[cfg(any(cfail1,cfail4))]
56 pub fn type_of_parameter(p: i32) {}
58 #[cfg(not(any(cfail1,cfail4)))]
61 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
63 #[rustc_clean(cfg = "cfail3")]
66 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
68 #[rustc_clean(cfg = "cfail6")]
69 pub fn type_of_parameter(p: i64) {}
71 // Change Parameter Type Reference ---------------------------------------------
73 #[cfg(any(cfail1,cfail4))]
74 pub fn type_of_parameter_ref(p: &i32) {}
76 #[cfg(not(any(cfail1,cfail4)))]
79 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
81 #[rustc_clean(cfg = "cfail3")]
84 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
86 #[rustc_clean(cfg = "cfail6")]
87 pub fn type_of_parameter_ref(p: &mut i32) {}
89 // Change Parameter Order ------------------------------------------------------
91 #[cfg(any(cfail1,cfail4))]
92 pub fn order_of_parameters(p1: i32, p2: i64) {}
94 #[cfg(not(any(cfail1,cfail4)))]
97 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
99 #[rustc_clean(cfg = "cfail3")]
102 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
104 #[rustc_clean(cfg = "cfail6")]
105 pub fn order_of_parameters(p2: i64, p1: i32) {}
107 // Unsafe ----------------------------------------------------------------------
109 #[cfg(any(cfail1,cfail4))]
110 pub fn make_unsafe() {}
112 #[cfg(not(any(cfail1,cfail4)))]
115 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
117 #[rustc_clean(cfg = "cfail3")]
120 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
122 #[rustc_clean(cfg = "cfail6")]
123 pub unsafe fn make_unsafe() {}
125 // Extern ----------------------------------------------------------------------
127 #[cfg(any(cfail1,cfail4))]
128 pub fn make_extern() {}
130 #[cfg(not(any(cfail1,cfail4)))]
131 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")]
132 #[rustc_clean(cfg = "cfail3")]
133 #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")]
134 #[rustc_clean(cfg = "cfail6")]
135 pub extern "C" fn make_extern() {}
137 // Type Parameter --------------------------------------------------------------
139 #[cfg(any(cfail1,cfail4))]
140 pub fn type_parameter () {}
142 #[cfg(not(any(cfail1,cfail4)))]
145 except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of"
147 #[rustc_clean(cfg = "cfail3")]
150 except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of"
152 #[rustc_clean(cfg = "cfail6")]
153 pub fn type_parameter<T>() {}
155 // Lifetime Parameter ----------------------------------------------------------
157 #[cfg(any(cfail1,cfail4))]
158 pub fn lifetime_parameter () {}
160 #[cfg(not(any(cfail1,cfail4)))]
161 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, generics_of,fn_sig")]
162 #[rustc_clean(cfg = "cfail3")]
163 #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, generics_of,fn_sig")]
164 #[rustc_clean(cfg = "cfail6")]
165 pub fn lifetime_parameter<'a>() {}
167 // Trait Bound -----------------------------------------------------------------
169 #[cfg(any(cfail1,cfail4))]
170 pub fn trait_bound<T >() {}
172 #[cfg(not(any(cfail1,cfail4)))]
173 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
174 #[rustc_clean(cfg = "cfail3")]
175 pub fn trait_bound<T: Eq>() {}
177 // Builtin Bound ---------------------------------------------------------------
179 #[cfg(any(cfail1,cfail4))]
180 pub fn builtin_bound<T >() {}
182 #[cfg(not(any(cfail1,cfail4)))]
183 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
184 #[rustc_clean(cfg = "cfail3")]
185 #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
186 #[rustc_clean(cfg = "cfail6")]
187 pub fn builtin_bound<T: Send>() {}
189 // Lifetime Bound --------------------------------------------------------------
191 #[cfg(any(cfail1,cfail4))]
192 pub fn lifetime_bound<'a, T>() {}
194 #[cfg(not(any(cfail1,cfail4)))]
197 except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
199 #[rustc_clean(cfg = "cfail3")]
202 except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig,optimized_mir"
204 #[rustc_clean(cfg = "cfail6")]
205 pub fn lifetime_bound<'a, T: 'a>() {}
207 // Second Trait Bound ----------------------------------------------------------
209 #[cfg(any(cfail1,cfail4))]
210 pub fn second_trait_bound<T: Eq >() {}
212 #[cfg(not(any(cfail1,cfail4)))]
213 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
214 #[rustc_clean(cfg = "cfail3")]
215 pub fn second_trait_bound<T: Eq + Clone>() {}
217 // Second Builtin Bound --------------------------------------------------------
219 #[cfg(any(cfail1,cfail4))]
220 pub fn second_builtin_bound<T: Send >() {}
222 #[cfg(not(any(cfail1,cfail4)))]
223 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
224 #[rustc_clean(cfg = "cfail3")]
225 #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
226 #[rustc_clean(cfg = "cfail6")]
227 pub fn second_builtin_bound<T: Send + Sized>() {}
229 // Second Lifetime Bound -------------------------------------------------------
231 #[cfg(any(cfail1,cfail4))]
232 pub fn second_lifetime_bound<'a, 'b, T: 'a >() {}
234 #[cfg(not(any(cfail1,cfail4)))]
237 except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
239 #[rustc_clean(cfg = "cfail3")]
242 except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
244 #[rustc_clean(cfg = "cfail6")]
245 pub fn second_lifetime_bound<'a, 'b, T: 'a + 'b>() {}
247 // Inline ----------------------------------------------------------------------
249 #[cfg(any(cfail1,cfail4))]
252 #[cfg(not(any(cfail1,cfail4)))]
253 #[rustc_clean(cfg = "cfail2")]
254 #[rustc_clean(cfg = "cfail3")]
255 #[rustc_clean(cfg = "cfail5")]
256 #[rustc_clean(cfg = "cfail6")]
260 // Inline Never ----------------------------------------------------------------
262 #[cfg(any(cfail1,cfail4))]
264 pub fn inline_never() {}
266 #[cfg(not(any(cfail1,cfail4)))]
267 #[rustc_clean(cfg = "cfail2")]
268 #[rustc_clean(cfg = "cfail3")]
269 #[rustc_clean(cfg = "cfail5")]
270 #[rustc_clean(cfg = "cfail6")]
272 pub fn inline_never() {}
274 // No Mangle -------------------------------------------------------------------
276 #[cfg(any(cfail1,cfail4))]
277 pub fn no_mangle() {}
279 #[cfg(not(any(cfail1,cfail4)))]
280 #[rustc_clean(cfg = "cfail2")]
281 #[rustc_clean(cfg = "cfail3")]
282 #[rustc_clean(cfg = "cfail5")]
283 #[rustc_clean(cfg = "cfail6")]
285 pub fn no_mangle() {}
287 // Linkage ---------------------------------------------------------------------
289 #[cfg(any(cfail1,cfail4))]
292 #[cfg(not(any(cfail1,cfail4)))]
293 #[rustc_clean(cfg = "cfail2")]
294 #[rustc_clean(cfg = "cfail3")]
295 #[rustc_clean(cfg = "cfail5")]
296 #[rustc_clean(cfg = "cfail6")]
297 #[linkage = "weak_odr"]
300 // Return Impl Trait -----------------------------------------------------------
302 #[cfg(any(cfail1,cfail4))]
303 pub fn return_impl_trait() -> i32 {
307 #[cfg(not(any(cfail1,cfail4)))]
308 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")]
309 #[rustc_clean(cfg = "cfail3")]
310 #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")]
311 #[rustc_clean(cfg = "cfail6")]
312 pub fn return_impl_trait() -> impl Clone {
316 // Change Return Impl Trait ----------------------------------------------------
318 #[cfg(any(cfail1,cfail4))]
319 pub fn change_return_impl_trait() -> impl Clone {
323 #[cfg(not(any(cfail1,cfail4)))]
324 #[rustc_clean(cfg = "cfail2")]
325 #[rustc_clean(cfg = "cfail3")]
326 #[rustc_clean(cfg = "cfail5")]
327 #[rustc_clean(cfg = "cfail6")]
328 pub fn change_return_impl_trait() -> impl Copy {
332 // Change Return Type Indirectly -----------------------------------------------
334 pub struct ReferencedType1;
335 pub struct ReferencedType2;
337 pub mod change_return_type_indirectly {
338 #[cfg(any(cfail1,cfail4))]
339 use super::ReferencedType1 as ReturnType;
340 #[cfg(not(any(cfail1,cfail4)))]
341 use super::ReferencedType2 as ReturnType;
345 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
347 #[rustc_clean(cfg = "cfail3")]
350 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
352 #[rustc_clean(cfg = "cfail6")]
353 pub fn indirect_return_type() -> ReturnType {
358 // Change Parameter Type Indirectly --------------------------------------------
360 pub mod change_parameter_type_indirectly {
361 #[cfg(any(cfail1,cfail4))]
362 use super::ReferencedType1 as ParameterType;
363 #[cfg(not(any(cfail1,cfail4)))]
364 use super::ReferencedType2 as ParameterType;
368 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
370 #[rustc_clean(cfg = "cfail3")]
373 except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
375 #[rustc_clean(cfg = "cfail6")]
376 pub fn indirect_parameter_type(p: ParameterType) {}
379 // Change Trait Bound Indirectly -----------------------------------------------
381 pub trait ReferencedTrait1 {}
382 pub trait ReferencedTrait2 {}
384 pub mod change_trait_bound_indirectly {
385 #[cfg(any(cfail1,cfail4))]
386 use super::ReferencedTrait1 as Trait;
387 #[cfg(not(any(cfail1,cfail4)))]
388 use super::ReferencedTrait2 as Trait;
390 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
391 #[rustc_clean(cfg = "cfail3")]
392 #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
393 #[rustc_clean(cfg = "cfail6")]
394 pub fn indirect_trait_bound<T: Trait>(p: T) {}
397 // Change Trait Bound Indirectly In Where Clause -------------------------------
399 pub mod change_trait_bound_indirectly_in_where_clause {
400 #[cfg(any(cfail1,cfail4))]
401 use super::ReferencedTrait1 as Trait;
402 #[cfg(not(any(cfail1,cfail4)))]
403 use super::ReferencedTrait2 as Trait;
405 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
406 #[rustc_clean(cfg = "cfail3")]
407 #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
408 #[rustc_clean(cfg = "cfail6")]
409 pub fn indirect_trait_bound_where<T>(p: T)