1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for function interfaces.
3 
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.
7 
8 // build-pass (FIXME(62277): could be check-pass?)
9 // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
10 // compile-flags: -Z query-dep-graph
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
17 
18 #![allow(warnings)]
19 #![feature(linkage)]
20 #![feature(rustc_attrs)]
21 #![crate_type = "rlib"]
22 
23 // Add Parameter ---------------------------------------------------------------
24 
25 #[cfg(any(cfail1,cfail4))]
add_parameter()26 pub fn add_parameter() {}
27 
28 #[cfg(not(any(cfail1,cfail4)))]
29 #[rustc_clean(
30     cfg = "cfail2",
31     except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
32 )]
33 #[rustc_clean(cfg = "cfail3")]
34 #[rustc_clean(
35     cfg = "cfail5",
36     except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
37 )]
38 #[rustc_clean(cfg = "cfail6")]
add_parameter(p: i32)39 pub fn add_parameter(p: i32) {}
40 
41 // Add Return Type -------------------------------------------------------------
42 
43 #[cfg(any(cfail1,cfail4))]
add_return_type()44 pub fn add_return_type()       {}
45 
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")]
add_return_type() -> ()51 pub fn add_return_type() -> () {}
52 
53 // Change Parameter Type -------------------------------------------------------
54 
55 #[cfg(any(cfail1,cfail4))]
type_of_parameter(p: i32)56 pub fn type_of_parameter(p: i32) {}
57 
58 #[cfg(not(any(cfail1,cfail4)))]
59 #[rustc_clean(
60     cfg = "cfail2",
61     except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
62 )]
63 #[rustc_clean(cfg = "cfail3")]
64 #[rustc_clean(
65     cfg = "cfail5",
66     except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
67 )]
68 #[rustc_clean(cfg = "cfail6")]
type_of_parameter(p: i64)69 pub fn type_of_parameter(p: i64) {}
70 
71 // Change Parameter Type Reference ---------------------------------------------
72 
73 #[cfg(any(cfail1,cfail4))]
type_of_parameter_ref(p: &i32)74 pub fn type_of_parameter_ref(p: &i32) {}
75 
76 #[cfg(not(any(cfail1,cfail4)))]
77 #[rustc_clean(
78     cfg = "cfail2",
79     except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
80 )]
81 #[rustc_clean(cfg = "cfail3")]
82 #[rustc_clean(
83     cfg = "cfail5",
84     except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
85 )]
86 #[rustc_clean(cfg = "cfail6")]
type_of_parameter_ref(p: &mut i32)87 pub fn type_of_parameter_ref(p: &mut i32) {}
88 
89 // Change Parameter Order ------------------------------------------------------
90 
91 #[cfg(any(cfail1,cfail4))]
order_of_parameters(p1: i32, p2: i64)92 pub fn order_of_parameters(p1: i32, p2: i64) {}
93 
94 #[cfg(not(any(cfail1,cfail4)))]
95 #[rustc_clean(
96     cfg = "cfail2",
97     except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
98 )]
99 #[rustc_clean(cfg = "cfail3")]
100 #[rustc_clean(
101     cfg = "cfail5",
102     except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
103 )]
104 #[rustc_clean(cfg = "cfail6")]
order_of_parameters(p2: i64, p1: i32)105 pub fn order_of_parameters(p2: i64, p1: i32) {}
106 
107 // Unsafe ----------------------------------------------------------------------
108 
109 #[cfg(any(cfail1,cfail4))]
make_unsafe()110 pub fn make_unsafe() {}
111 
112 #[cfg(not(any(cfail1,cfail4)))]
113 #[rustc_clean(
114     cfg = "cfail2",
115     except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
116 )]
117 #[rustc_clean(cfg = "cfail3")]
118 #[rustc_clean(
119     cfg = "cfail5",
120     except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
121 )]
122 #[rustc_clean(cfg = "cfail6")]
make_unsafe()123 pub unsafe fn make_unsafe() {}
124 
125 // Extern ----------------------------------------------------------------------
126 
127 #[cfg(any(cfail1,cfail4))]
make_extern()128 pub            fn make_extern() {}
129 
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")]
make_extern()135 pub extern "C" fn make_extern() {}
136 
137 // Type Parameter --------------------------------------------------------------
138 
139 #[cfg(any(cfail1,cfail4))]
type_parameter()140 pub fn type_parameter   () {}
141 
142 #[cfg(not(any(cfail1,cfail4)))]
143 #[rustc_clean(
144     cfg = "cfail2",
145     except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of"
146 )]
147 #[rustc_clean(cfg = "cfail3")]
148 #[rustc_clean(
149     cfg = "cfail5",
150     except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of"
151 )]
152 #[rustc_clean(cfg = "cfail6")]
type_parameter<T>()153 pub fn type_parameter<T>() {}
154 
155 // Lifetime Parameter ----------------------------------------------------------
156 
157 #[cfg(any(cfail1,cfail4))]
lifetime_parameter()158 pub fn lifetime_parameter    () {}
159 
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")]
lifetime_parameter<'a>()165 pub fn lifetime_parameter<'a>() {}
166 
167 // Trait Bound -----------------------------------------------------------------
168 
169 #[cfg(any(cfail1,cfail4))]
trait_bound<T >()170 pub fn trait_bound<T    >() {}
171 
172 #[cfg(not(any(cfail1,cfail4)))]
173 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
174 #[rustc_clean(cfg = "cfail3")]
trait_bound<T: Eq>()175 pub fn trait_bound<T: Eq>() {}
176 
177 // Builtin Bound ---------------------------------------------------------------
178 
179 #[cfg(any(cfail1,cfail4))]
builtin_bound<T >()180 pub fn builtin_bound<T      >() {}
181 
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")]
builtin_bound<T: Send>()187 pub fn builtin_bound<T: Send>() {}
188 
189 // Lifetime Bound --------------------------------------------------------------
190 
191 #[cfg(any(cfail1,cfail4))]
lifetime_bound<'a, T>()192 pub fn lifetime_bound<'a, T>() {}
193 
194 #[cfg(not(any(cfail1,cfail4)))]
195 #[rustc_clean(
196     cfg = "cfail2",
197     except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
198 )]
199 #[rustc_clean(cfg = "cfail3")]
200 #[rustc_clean(
201     cfg = "cfail5",
202     except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig,optimized_mir"
203 )]
204 #[rustc_clean(cfg = "cfail6")]
lifetime_bound<'a, T: 'a>()205 pub fn lifetime_bound<'a, T: 'a>() {}
206 
207 // Second Trait Bound ----------------------------------------------------------
208 
209 #[cfg(any(cfail1,cfail4))]
second_trait_bound<T: Eq >()210 pub fn second_trait_bound<T: Eq        >() {}
211 
212 #[cfg(not(any(cfail1,cfail4)))]
213 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
214 #[rustc_clean(cfg = "cfail3")]
second_trait_bound<T: Eq + Clone>()215 pub fn second_trait_bound<T: Eq + Clone>() {}
216 
217 // Second Builtin Bound --------------------------------------------------------
218 
219 #[cfg(any(cfail1,cfail4))]
second_builtin_bound<T: Send >()220 pub fn second_builtin_bound<T: Send        >() {}
221 
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")]
second_builtin_bound<T: Send + Sized>()227 pub fn second_builtin_bound<T: Send + Sized>() {}
228 
229 // Second Lifetime Bound -------------------------------------------------------
230 
231 #[cfg(any(cfail1,cfail4))]
second_lifetime_bound<'a, 'b, T: 'a >()232 pub fn second_lifetime_bound<'a, 'b, T: 'a     >() {}
233 
234 #[cfg(not(any(cfail1,cfail4)))]
235 #[rustc_clean(
236     cfg = "cfail2",
237     except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
238 )]
239 #[rustc_clean(cfg = "cfail3")]
240 #[rustc_clean(
241     cfg = "cfail5",
242     except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
243 )]
244 #[rustc_clean(cfg = "cfail6")]
second_lifetime_bound<'a, 'b, T: 'a + 'b>()245 pub fn second_lifetime_bound<'a, 'b, T: 'a + 'b>() {}
246 
247 // Inline ----------------------------------------------------------------------
248 
249 #[cfg(any(cfail1,cfail4))]
inline()250 pub fn inline() {}
251 
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")]
257 #[inline]
inline()258 pub fn inline() {}
259 
260 // Inline Never ----------------------------------------------------------------
261 
262 #[cfg(any(cfail1,cfail4))]
263 #[inline(always)]
inline_never()264 pub fn inline_never() {}
265 
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")]
271 #[inline(never)]
inline_never()272 pub fn inline_never() {}
273 
274 // No Mangle -------------------------------------------------------------------
275 
276 #[cfg(any(cfail1,cfail4))]
no_mangle()277 pub fn no_mangle() {}
278 
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")]
284 #[no_mangle]
no_mangle()285 pub fn no_mangle() {}
286 
287 // Linkage ---------------------------------------------------------------------
288 
289 #[cfg(any(cfail1,cfail4))]
linkage()290 pub fn linkage() {}
291 
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"]
linkage()298 pub fn linkage() {}
299 
300 // Return Impl Trait -----------------------------------------------------------
301 
302 #[cfg(any(cfail1,cfail4))]
return_impl_trait() -> i32303 pub fn return_impl_trait() -> i32        {
304     0
305 }
306 
307 #[cfg(not(any(cfail1,cfail4)))]
308 #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")]
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")]
return_impl_trait() -> impl Clone312 pub fn return_impl_trait() -> impl Clone {
313     0
314 }
315 
316 // Change Return Impl Trait ----------------------------------------------------
317 
318 #[cfg(any(cfail1,cfail4))]
change_return_impl_trait() -> impl Clone319 pub fn change_return_impl_trait() -> impl Clone {
320     0u32
321 }
322 
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")]
change_return_impl_trait() -> impl Copy328 pub fn change_return_impl_trait() -> impl  Copy {
329     0u32
330 }
331 
332 // Change Return Type Indirectly -----------------------------------------------
333 
334 pub struct ReferencedType1;
335 pub struct ReferencedType2;
336 
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;
342 
343     #[rustc_clean(
344         cfg = "cfail2",
345         except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
346     )]
347     #[rustc_clean(cfg = "cfail3")]
348     #[rustc_clean(
349         cfg = "cfail5",
350         except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
351     )]
352     #[rustc_clean(cfg = "cfail6")]
indirect_return_type() -> ReturnType353     pub fn indirect_return_type() -> ReturnType {
354         ReturnType {}
355     }
356 }
357 
358 // Change Parameter Type Indirectly --------------------------------------------
359 
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;
365 
366     #[rustc_clean(
367         cfg = "cfail2",
368         except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
369     )]
370     #[rustc_clean(cfg = "cfail3")]
371     #[rustc_clean(
372         cfg = "cfail5",
373         except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
374     )]
375     #[rustc_clean(cfg = "cfail6")]
indirect_parameter_type(p: ParameterType)376     pub fn indirect_parameter_type(p: ParameterType) {}
377 }
378 
379 // Change Trait Bound Indirectly -----------------------------------------------
380 
381 pub trait ReferencedTrait1 {}
382 pub trait ReferencedTrait2 {}
383 
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;
389 
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")]
indirect_trait_bound<T: Trait>(p: T)394     pub fn indirect_trait_bound<T: Trait>(p: T) {}
395 }
396 
397 // Change Trait Bound Indirectly In Where Clause -------------------------------
398 
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;
404 
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")]
indirect_trait_bound_where<T>(p: T) where T: Trait,409     pub fn indirect_trait_bound_where<T>(p: T)
410     where
411         T: Trait,
412     {
413     }
414 }
415