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.
9 // revisions: cfail1 cfail2 cfail3
10 // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
13 #![feature(rustc_attrs)]
17 // Change closure body ---------------------------------------------------------
19 pub fn change_closure_body() {
24 #[rustc_clean(cfg="cfail2", except="HirBody")]
25 #[rustc_clean(cfg="cfail3")]
26 pub fn change_closure_body() {
32 // Add parameter ---------------------------------------------------------------
34 pub fn add_parameter() {
40 #[rustc_clean(cfg="cfail2", except="HirBody, MirBuilt, MirOptimized, TypeckTables")]
41 #[rustc_clean(cfg="cfail3")]
42 pub fn add_parameter() {
44 let _ = |x: u32| x + 1;
49 // Change parameter pattern ----------------------------------------------------
51 pub fn change_parameter_pattern() {
56 #[rustc_clean(cfg="cfail2", except="HirBody, MirBuilt, TypeckTables")]
57 #[rustc_clean(cfg="cfail3")]
58 pub fn change_parameter_pattern() {
64 // Add `move` to closure -------------------------------------------------------
71 #[rustc_clean(cfg="cfail2", except="HirBody")]
72 #[rustc_clean(cfg="cfail3")]
79 // Add type ascription to parameter --------------------------------------------
81 pub fn add_type_ascription_to_parameter() {
82 let closure = |x| x + 1u32;
83 let _: u32 = closure(1);
87 #[rustc_clean(cfg="cfail2", except="HirBody, MirBuilt, TypeckTables")]
88 #[rustc_clean(cfg="cfail3")]
89 pub fn add_type_ascription_to_parameter() {
90 let closure = |x: u32| x + 1u32;
91 let _: u32 = closure(1);
96 // Change parameter type -------------------------------------------------------
98 pub fn change_parameter_type() {
99 let closure = |x: u32| (x as u64) + 1;
104 #[rustc_clean(cfg="cfail2", except="HirBody, MirBuilt, MirOptimized, TypeckTables")]
105 #[rustc_clean(cfg="cfail3")]
106 pub fn change_parameter_type() {
107 let closure = |x: u16| (x as u64) + 1;