]> git.proxmox.com Git - rustc.git/blame - tests/incremental/hashes/closure_expressions.rs
New upstream version 1.72.1+dfsg1
[rustc.git] / tests / incremental / hashes / closure_expressions.rs
CommitLineData
476ff2be
SL
1// This test case tests the incremental compilation hash (ICH) implementation
2// for closure expression.
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
416331ca 8// build-pass (FIXME(62277): could be check-pass?)
c295e0f8 9// revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
923072b8 10// compile-flags: -Z query-dep-graph -O
c295e0f8
XL
11// [cfail1]compile-flags: -Zincremental-ignore-spans
12// [cfail2]compile-flags: -Zincremental-ignore-spans
13// [cfail3]compile-flags: -Zincremental-ignore-spans
476ff2be
SL
14
15#![allow(warnings)]
16#![feature(rustc_attrs)]
17#![crate_type="rlib"]
18
19
e1599b0c 20// Change closure body
c295e0f8 21#[cfg(any(cfail1,cfail4))]
ff7c6d11 22pub fn change_closure_body() {
476ff2be
SL
23 let _ = || 1u32;
24}
25
c295e0f8 26#[cfg(not(any(cfail1,cfail4)))]
ba9703b0 27#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
ff7c6d11 28#[rustc_clean(cfg="cfail3")]
c295e0f8
XL
29#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
30#[rustc_clean(cfg="cfail6")]
ff7c6d11 31pub fn change_closure_body() {
476ff2be
SL
32 let _ = || 3u32;
33}
34
35
36
e1599b0c 37// Add parameter
c295e0f8 38#[cfg(any(cfail1,cfail4))]
ff7c6d11 39pub fn add_parameter() {
476ff2be 40 let x = 0u32;
c295e0f8 41 let _ = | | x + 1;
476ff2be
SL
42}
43
c295e0f8 44#[cfg(not(any(cfail1,cfail4)))]
9c376795 45#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")]
ff7c6d11 46#[rustc_clean(cfg="cfail3")]
9c376795 47#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, typeck")]
c295e0f8 48#[rustc_clean(cfg="cfail6")]
ff7c6d11 49pub fn add_parameter() {
476ff2be
SL
50 let x = 0u32;
51 let _ = |x: u32| x + 1;
52}
53
54
55
e1599b0c 56// Change parameter pattern
c295e0f8 57#[cfg(any(cfail1,cfail4))]
ff7c6d11 58pub fn change_parameter_pattern() {
c295e0f8 59 let _ = | x : (u32,)| x;
476ff2be
SL
60}
61
c295e0f8 62#[cfg(not(any(cfail1,cfail4)))]
923072b8 63#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")]
ff7c6d11 64#[rustc_clean(cfg="cfail3")]
923072b8 65#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, typeck")]
c295e0f8 66#[rustc_clean(cfg="cfail6")]
ff7c6d11 67pub fn change_parameter_pattern() {
48663c56 68 let _ = |(x,): (u32,)| x;
476ff2be
SL
69}
70
71
72
e1599b0c 73// Add `move` to closure
c295e0f8 74#[cfg(any(cfail1,cfail4))]
ff7c6d11 75pub fn add_move() {
c295e0f8 76 let _ = || 1;
476ff2be
SL
77}
78
c295e0f8 79#[cfg(not(any(cfail1,cfail4)))]
ba9703b0 80#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
ff7c6d11 81#[rustc_clean(cfg="cfail3")]
923072b8 82#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
c295e0f8 83#[rustc_clean(cfg="cfail6")]
ff7c6d11 84pub fn add_move() {
476ff2be
SL
85 let _ = move || 1;
86}
87
88
89
e1599b0c 90// Add type ascription to parameter
c295e0f8 91#[cfg(any(cfail1,cfail4))]
ff7c6d11 92pub fn add_type_ascription_to_parameter() {
c295e0f8 93 let closure = |x | x + 1u32;
476ff2be
SL
94 let _: u32 = closure(1);
95}
96
c295e0f8 97#[cfg(not(any(cfail1,cfail4)))]
3dfed10e 98#[rustc_clean(cfg = "cfail2", except = "hir_owner_nodes, typeck")]
ba9703b0 99#[rustc_clean(cfg = "cfail3")]
c295e0f8
XL
100#[rustc_clean(cfg = "cfail5", except = "hir_owner_nodes, typeck")]
101#[rustc_clean(cfg = "cfail6")]
ff7c6d11 102pub fn add_type_ascription_to_parameter() {
476ff2be
SL
103 let closure = |x: u32| x + 1u32;
104 let _: u32 = closure(1);
105}
106
107
108
e1599b0c 109// Change parameter type
c295e0f8 110#[cfg(any(cfail1,cfail4))]
ff7c6d11 111pub fn change_parameter_type() {
476ff2be
SL
112 let closure = |x: u32| (x as u64) + 1;
113 let _ = closure(1);
114}
115
c295e0f8 116#[cfg(not(any(cfail1,cfail4)))]
3dfed10e 117#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
ff7c6d11 118#[rustc_clean(cfg="cfail3")]
c295e0f8
XL
119#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
120#[rustc_clean(cfg="cfail6")]
ff7c6d11 121pub fn change_parameter_type() {
476ff2be
SL
122 let closure = |x: u16| (x as u64) + 1;
123 let _ = closure(1);
124}