1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for closure expression.
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
19 #![feature(rustc_attrs)]
23 // Change closure body
24 #[cfg(any(cfail1,cfail4))]
25 pub fn change_closure_body() {
29 #[cfg(not(any(cfail1,cfail4)))]
30 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
31 #[rustc_clean(cfg="cfail3")]
32 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
33 #[rustc_clean(cfg="cfail6")]
34 pub fn change_closure_body() {
41 #[cfg(any(cfail1,cfail4))]
42 pub fn add_parameter() {
47 #[cfg(not(any(cfail1,cfail4)))]
48 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
49 #[rustc_clean(cfg="cfail3")]
50 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
51 #[rustc_clean(cfg="cfail6")]
52 pub fn add_parameter() {
54 let _ = |x: u32| x + 1;
59 // Change parameter pattern
60 #[cfg(any(cfail1,cfail4))]
61 pub fn change_parameter_pattern() {
62 let _ = | x : (u32,)| x;
65 #[cfg(not(any(cfail1,cfail4)))]
66 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")]
67 #[rustc_clean(cfg="cfail3")]
68 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, typeck")]
69 #[rustc_clean(cfg="cfail6")]
70 pub fn change_parameter_pattern() {
71 let _ = |(x,): (u32,)| x;
76 // Add `move` to closure
77 #[cfg(any(cfail1,cfail4))]
82 #[cfg(not(any(cfail1,cfail4)))]
83 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
84 #[rustc_clean(cfg="cfail3")]
85 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
86 #[rustc_clean(cfg="cfail6")]
93 // Add type ascription to parameter
94 #[cfg(any(cfail1,cfail4))]
95 pub fn add_type_ascription_to_parameter() {
96 let closure = |x | x + 1u32;
97 let _: u32 = closure(1);
100 #[cfg(not(any(cfail1,cfail4)))]
101 #[rustc_clean(cfg = "cfail2", except = "hir_owner_nodes, typeck")]
102 #[rustc_clean(cfg = "cfail3")]
103 #[rustc_clean(cfg = "cfail5", except = "hir_owner_nodes, typeck")]
104 #[rustc_clean(cfg = "cfail6")]
105 pub fn add_type_ascription_to_parameter() {
106 let closure = |x: u32| x + 1u32;
107 let _: u32 = closure(1);
112 // Change parameter type
113 #[cfg(any(cfail1,cfail4))]
114 pub fn change_parameter_type() {
115 let closure = |x: u32| (x as u64) + 1;
119 #[cfg(not(any(cfail1,cfail4)))]
120 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
121 #[rustc_clean(cfg="cfail3")]
122 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
123 #[rustc_clean(cfg="cfail6")]
124 pub fn change_parameter_type() {
125 let closure = |x: u16| (x as u64) + 1;