2016-12-06 15:58:23 -06:00
|
|
|
// This test case tests the incremental compilation hash (ICH) implementation
|
|
|
|
// for closure expression.
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
2019-07-02 16:30:28 -05:00
|
|
|
// build-pass (FIXME(62277): could be check-pass?)
|
2021-04-22 14:33:16 -05:00
|
|
|
// revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
|
2022-05-27 20:17:39 -05:00
|
|
|
// compile-flags: -Z query-dep-graph -O
|
2021-04-22 14:33:16 -05:00
|
|
|
// [cfail1]compile-flags: -Zincremental-ignore-spans
|
|
|
|
// [cfail2]compile-flags: -Zincremental-ignore-spans
|
|
|
|
// [cfail3]compile-flags: -Zincremental-ignore-spans
|
2016-12-06 15:58:23 -06:00
|
|
|
|
|
|
|
#![allow(warnings)]
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
#![crate_type="rlib"]
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change closure body
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn change_closure_body() {
|
2016-12-06 15:58:23 -06:00
|
|
|
let _ = || 1u32;
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-03-17 20:48:17 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
|
2017-12-05 16:03:24 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn change_closure_body() {
|
2016-12-06 15:58:23 -06:00
|
|
|
let _ = || 3u32;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Add parameter
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn add_parameter() {
|
2016-12-06 15:58:23 -06:00
|
|
|
let x = 0u32;
|
2021-04-22 14:33:16 -05:00
|
|
|
let _ = | | x + 1;
|
2016-12-06 15:58:23 -06:00
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2022-12-06 14:05:55 -06:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")]
|
2017-12-05 16:03:24 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2022-12-06 14:05:55 -06:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, typeck")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn add_parameter() {
|
2016-12-06 15:58:23 -06:00
|
|
|
let x = 0u32;
|
|
|
|
let _ = |x: u32| x + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change parameter pattern
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn change_parameter_pattern() {
|
2021-04-22 14:33:16 -05:00
|
|
|
let _ = | x : (u32,)| x;
|
2016-12-06 15:58:23 -06:00
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2022-05-27 20:17:39 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")]
|
2017-12-05 16:03:24 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2022-05-27 20:17:39 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, typeck")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn change_parameter_pattern() {
|
2019-01-27 05:03:21 -06:00
|
|
|
let _ = |(x,): (u32,)| x;
|
2016-12-06 15:58:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Add `move` to closure
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn add_move() {
|
2021-04-22 14:33:16 -05:00
|
|
|
let _ = || 1;
|
2016-12-06 15:58:23 -06:00
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-03-17 20:48:17 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
|
2017-12-05 16:03:24 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2022-05-27 20:17:39 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn add_move() {
|
2016-12-06 15:58:23 -06:00
|
|
|
let _ = move || 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Add type ascription to parameter
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn add_type_ascription_to_parameter() {
|
2021-04-22 14:33:16 -05:00
|
|
|
let closure = |x | x + 1u32;
|
2016-12-06 15:58:23 -06:00
|
|
|
let _: u32 = closure(1);
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-17 03:47:04 -05:00
|
|
|
#[rustc_clean(cfg = "cfail2", except = "hir_owner_nodes, typeck")]
|
2020-02-15 06:13:20 -06:00
|
|
|
#[rustc_clean(cfg = "cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg = "cfail5", except = "hir_owner_nodes, typeck")]
|
|
|
|
#[rustc_clean(cfg = "cfail6")]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn add_type_ascription_to_parameter() {
|
2016-12-06 15:58:23 -06:00
|
|
|
let closure = |x: u32| x + 1u32;
|
|
|
|
let _: u32 = closure(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change parameter type
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn change_parameter_type() {
|
2016-12-06 15:58:23 -06:00
|
|
|
let closure = |x: u32| (x as u64) + 1;
|
|
|
|
let _ = closure(1);
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-17 03:47:04 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
|
2017-12-05 16:03:24 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2017-12-05 16:03:24 -06:00
|
|
|
pub fn change_parameter_type() {
|
2016-12-06 15:58:23 -06:00
|
|
|
let closure = |x: u16| (x as u64) + 1;
|
|
|
|
let _ = closure(1);
|
|
|
|
}
|