summaryrefslogtreecommitdiffstats
path: root/src/test/incremental/hashes/function_interfaces.rs
blob: 076eddaabc048b818a302cfe66957c701a9307cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
// This test case tests the incremental compilation hash (ICH) implementation
// for function interfaces.

// The general pattern followed here is: Change one thing between rev1 and rev2
// and make sure that the hash has changed, then change nothing between rev2 and
// rev3 and make sure that the hash has not changed.

// build-pass (FIXME(62277): could be check-pass?)
// revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
// compile-flags: -Z query-dep-graph -O
// [cfail1]compile-flags: -Zincremental-ignore-spans
// [cfail2]compile-flags: -Zincremental-ignore-spans
// [cfail3]compile-flags: -Zincremental-ignore-spans
// [cfail4]compile-flags: -Zincremental-relative-spans
// [cfail5]compile-flags: -Zincremental-relative-spans
// [cfail6]compile-flags: -Zincremental-relative-spans

#![allow(warnings)]
#![feature(linkage)]
#![feature(rustc_attrs)]
#![crate_type = "rlib"]

// Add Parameter ---------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn add_parameter() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(
    cfg = "cfail2",
    except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
)]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(
    cfg = "cfail5",
    except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
)]
#[rustc_clean(cfg = "cfail6")]
pub fn add_parameter(p: i32) {}

// Add Return Type -------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn add_return_type()       {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, optimized_mir")]
#[rustc_clean(cfg = "cfail6")]
pub fn add_return_type() -> () {}

// Change Parameter Type -------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn type_of_parameter(p: i32) {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(
    cfg = "cfail2",
    except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
)]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(
    cfg = "cfail5",
    except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
)]
#[rustc_clean(cfg = "cfail6")]
pub fn type_of_parameter(p: i64) {}

// Change Parameter Type Reference ---------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn type_of_parameter_ref(p: &i32) {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(
    cfg = "cfail2",
    except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
)]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(
    cfg = "cfail5",
    except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
)]
#[rustc_clean(cfg = "cfail6")]
pub fn type_of_parameter_ref(p: &mut i32) {}

// Change Parameter Order ------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn order_of_parameters(p1: i32, p2: i64) {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(
    cfg = "cfail2",
    except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
)]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(
    cfg = "cfail5",
    except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
)]
#[rustc_clean(cfg = "cfail6")]
pub fn order_of_parameters(p2: i64, p1: i32) {}

// Unsafe ----------------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn make_unsafe() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(
    cfg = "cfail2",
    except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
)]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(
    cfg = "cfail5",
    except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
)]
#[rustc_clean(cfg = "cfail6")]
pub unsafe fn make_unsafe() {}

// Extern ----------------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub            fn make_extern() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")]
#[rustc_clean(cfg = "cfail6")]
pub extern "C" fn make_extern() {}

// Type Parameter --------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn type_parameter   () {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(
    cfg = "cfail2",
    except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of"
)]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(
    cfg = "cfail5",
    except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of"
)]
#[rustc_clean(cfg = "cfail6")]
pub fn type_parameter<T>() {}

// Lifetime Parameter ----------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn lifetime_parameter    () {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, generics_of,fn_sig")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, generics_of,fn_sig")]
#[rustc_clean(cfg = "cfail6")]
pub fn lifetime_parameter<'a>() {}

// Trait Bound -----------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn trait_bound<T    >() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
#[rustc_clean(cfg = "cfail3")]
pub fn trait_bound<T: Eq>() {}

// Builtin Bound ---------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn builtin_bound<T      >() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
#[rustc_clean(cfg = "cfail6")]
pub fn builtin_bound<T: Send>() {}

// Lifetime Bound --------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn lifetime_bound<'a, T>() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(
    cfg = "cfail2",
    except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
)]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(
    cfg = "cfail5",
    except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig,optimized_mir"
)]
#[rustc_clean(cfg = "cfail6")]
pub fn lifetime_bound<'a, T: 'a>() {}

// Second Trait Bound ----------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn second_trait_bound<T: Eq        >() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
#[rustc_clean(cfg = "cfail3")]
pub fn second_trait_bound<T: Eq + Clone>() {}

// Second Builtin Bound --------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn second_builtin_bound<T: Send        >() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
#[rustc_clean(cfg = "cfail6")]
pub fn second_builtin_bound<T: Send + Sized>() {}

// Second Lifetime Bound -------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn second_lifetime_bound<'a, 'b, T: 'a     >() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(
    cfg = "cfail2",
    except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
)]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(
    cfg = "cfail5",
    except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig"
)]
#[rustc_clean(cfg = "cfail6")]
pub fn second_lifetime_bound<'a, 'b, T: 'a + 'b>() {}

// Inline ----------------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn inline() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5")]
#[rustc_clean(cfg = "cfail6")]
#[inline]
pub fn inline() {}

// Inline Never ----------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
#[inline(always)]
pub fn inline_never() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5")]
#[rustc_clean(cfg = "cfail6")]
#[inline(never)]
pub fn inline_never() {}

// No Mangle -------------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn no_mangle() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5")]
#[rustc_clean(cfg = "cfail6")]
#[no_mangle]
pub fn no_mangle() {}

// Linkage ---------------------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn linkage() {}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5")]
#[rustc_clean(cfg = "cfail6")]
#[linkage = "weak_odr"]
pub fn linkage() {}

// Return Impl Trait -----------------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn return_impl_trait() -> i32        {
    0
}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")]
#[rustc_clean(cfg = "cfail6")]
pub fn return_impl_trait() -> impl Clone {
    0
}

// Change Return Impl Trait ----------------------------------------------------

#[cfg(any(cfail1,cfail4))]
pub fn change_return_impl_trait() -> impl Clone {
    0u32
}

#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg = "cfail2")]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(cfg = "cfail5")]
#[rustc_clean(cfg = "cfail6")]
pub fn change_return_impl_trait() -> impl  Copy {
    0u32
}

// Change Return Type Indirectly -----------------------------------------------

pub struct ReferencedType1;
pub struct ReferencedType2;

pub mod change_return_type_indirectly {
    #[cfg(any(cfail1,cfail4))]
    use super::ReferencedType1 as ReturnType;
    #[cfg(not(any(cfail1,cfail4)))]
    use super::ReferencedType2 as ReturnType;

    #[rustc_clean(
        cfg = "cfail2",
        except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
    )]
    #[rustc_clean(cfg = "cfail3")]
    #[rustc_clean(
        cfg = "cfail5",
        except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
    )]
    #[rustc_clean(cfg = "cfail6")]
    pub fn indirect_return_type() -> ReturnType {
        ReturnType {}
    }
}

// Change Parameter Type Indirectly --------------------------------------------

pub mod change_parameter_type_indirectly {
    #[cfg(any(cfail1,cfail4))]
    use super::ReferencedType1 as ParameterType;
    #[cfg(not(any(cfail1,cfail4)))]
    use super::ReferencedType2 as ParameterType;

    #[rustc_clean(
        cfg = "cfail2",
        except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
    )]
    #[rustc_clean(cfg = "cfail3")]
    #[rustc_clean(
        cfg = "cfail5",
        except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
    )]
    #[rustc_clean(cfg = "cfail6")]
    pub fn indirect_parameter_type(p: ParameterType) {}
}

// Change Trait Bound Indirectly -----------------------------------------------

pub trait ReferencedTrait1 {}
pub trait ReferencedTrait2 {}

pub mod change_trait_bound_indirectly {
    #[cfg(any(cfail1,cfail4))]
    use super::ReferencedTrait1 as Trait;
    #[cfg(not(any(cfail1,cfail4)))]
    use super::ReferencedTrait2 as Trait;

    #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
    #[rustc_clean(cfg = "cfail3")]
    #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
    #[rustc_clean(cfg = "cfail6")]
    pub fn indirect_trait_bound<T: Trait>(p: T) {}
}

// Change Trait Bound Indirectly In Where Clause -------------------------------

pub mod change_trait_bound_indirectly_in_where_clause {
    #[cfg(any(cfail1,cfail4))]
    use super::ReferencedTrait1 as Trait;
    #[cfg(not(any(cfail1,cfail4)))]
    use super::ReferencedTrait2 as Trait;

    #[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, predicates_of")]
    #[rustc_clean(cfg = "cfail3")]
    #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, predicates_of")]
    #[rustc_clean(cfg = "cfail6")]
    pub fn indirect_trait_bound_where<T>(p: T)
    where
        T: Trait,
    {
    }
}