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