2016-12-06 16:58:23 -05: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-03 06:30:28 +09:00
|
|
|
// build-pass (FIXME(62277): could be check-pass?)
|
2016-12-06 16:58:23 -05:00
|
|
|
// revisions: cfail1 cfail2 cfail3
|
2017-12-04 12:47:16 +01:00
|
|
|
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
|
2016-12-06 16:58:23 -05:00
|
|
|
|
|
|
|
#![allow(warnings)]
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
#![crate_type="rlib"]
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Change closure body
|
2016-12-06 16:58:23 -05:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 14:03:24 -08:00
|
|
|
pub fn change_closure_body() {
|
2016-12-06 16:58:23 -05:00
|
|
|
let _ = || 1u32;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 15:34:10 +01:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items")]
|
2017-12-05 14:03:24 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn change_closure_body() {
|
2016-12-06 16:58:23 -05:00
|
|
|
let _ = || 3u32;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Add parameter
|
2016-12-06 16:58:23 -05:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 14:03:24 -08:00
|
|
|
pub fn add_parameter() {
|
2016-12-06 16:58:23 -05:00
|
|
|
let x = 0u32;
|
|
|
|
let _ = || x + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 15:34:10 +01:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items, mir_built, optimized_mir, typeck_tables_of")]
|
2017-12-05 14:03:24 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn add_parameter() {
|
2016-12-06 16:58:23 -05:00
|
|
|
let x = 0u32;
|
|
|
|
let _ = |x: u32| x + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Change parameter pattern
|
2016-12-06 16:58:23 -05:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 14:03:24 -08:00
|
|
|
pub fn change_parameter_pattern() {
|
2019-01-27 11:03:21 +00:00
|
|
|
let _ = |x: (u32,)| x;
|
2016-12-06 16:58:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 15:34:10 +01:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items, mir_built, typeck_tables_of")]
|
2017-12-05 14:03:24 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn change_parameter_pattern() {
|
2019-01-27 11:03:21 +00:00
|
|
|
let _ = |(x,): (u32,)| x;
|
2016-12-06 16:58:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Add `move` to closure
|
2016-12-06 16:58:23 -05:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 14:03:24 -08:00
|
|
|
pub fn add_move() {
|
2016-12-06 16:58:23 -05:00
|
|
|
let _ = || 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 15:34:10 +01:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items")]
|
2017-12-05 14:03:24 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn add_move() {
|
2016-12-06 16:58:23 -05:00
|
|
|
let _ = move || 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Add type ascription to parameter
|
2016-12-06 16:58:23 -05:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 14:03:24 -08:00
|
|
|
pub fn add_type_ascription_to_parameter() {
|
2016-12-06 16:58:23 -05:00
|
|
|
let closure = |x| x + 1u32;
|
|
|
|
let _: u32 = closure(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 15:34:10 +01:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items, mir_built, typeck_tables_of")]
|
2017-12-05 14:03:24 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn add_type_ascription_to_parameter() {
|
2016-12-06 16:58:23 -05:00
|
|
|
let closure = |x: u32| x + 1u32;
|
|
|
|
let _: u32 = closure(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 22:31:46 +01:00
|
|
|
// Change parameter type
|
2016-12-06 16:58:23 -05:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 14:03:24 -08:00
|
|
|
pub fn change_parameter_type() {
|
2016-12-06 16:58:23 -05:00
|
|
|
let closure = |x: u32| (x as u64) + 1;
|
|
|
|
let _ = closure(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 15:34:10 +01:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items, mir_built, optimized_mir, typeck_tables_of")]
|
2017-12-05 14:03:24 -08:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn change_parameter_type() {
|
2016-12-06 16:58:23 -05:00
|
|
|
let closure = |x: u16| (x as u64) + 1;
|
|
|
|
let _ = closure(1);
|
|
|
|
}
|