2016-11-17 13:28:38 -06:00
|
|
|
// This test case tests the incremental compilation hash (ICH) implementation
|
|
|
|
// for `while let` loops.
|
|
|
|
|
|
|
|
// 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?)
|
2016-11-17 13:28:38 -06:00
|
|
|
// revisions: cfail1 cfail2 cfail3
|
2017-12-04 05:47:16 -06:00
|
|
|
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
|
2016-11-17 13:28:38 -06:00
|
|
|
|
|
|
|
#![allow(warnings)]
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
#![crate_type="rlib"]
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change loop body
|
2016-11-17 13:28:38 -06:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 16:57:35 -06:00
|
|
|
pub fn change_loop_body() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 08:34:10 -06:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items, mir_built")]
|
2017-12-05 16:57:35 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn change_loop_body() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
while let Some(0u32) = None {
|
|
|
|
_x = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change loop body
|
2016-11-17 13:28:38 -06:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 16:57:35 -06:00
|
|
|
pub fn change_loop_condition() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 08:34:10 -06:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items, mir_built")]
|
2017-12-05 16:57:35 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn change_loop_condition() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
while let Some(1u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Add break
|
2016-11-17 13:28:38 -06:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 16:57:35 -06:00
|
|
|
pub fn add_break() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 08:34:10 -06:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items, mir_built, typeck_tables_of")]
|
2017-12-05 16:57:35 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn add_break() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Add loop label
|
2016-11-17 13:28:38 -06:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 16:57:35 -06:00
|
|
|
pub fn add_loop_label() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 08:34:10 -06:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items")]
|
2017-12-05 16:57:35 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn add_loop_label() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
'label: while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Add loop label to break
|
2016-11-17 13:28:38 -06:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 16:57:35 -06:00
|
|
|
pub fn add_loop_label_to_break() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
'label: while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 08:34:10 -06:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items")]
|
2017-12-05 16:57:35 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn add_loop_label_to_break() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
'label: while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
break 'label;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change break label
|
2016-11-17 13:28:38 -06:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 16:57:35 -06:00
|
|
|
pub fn change_break_label() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
'outer: while let Some(0u32) = None {
|
|
|
|
'inner: while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
break 'inner;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 08:34:10 -06:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items, mir_built")]
|
2017-12-05 16:57:35 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn change_break_label() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
'outer: while let Some(0u32) = None {
|
|
|
|
'inner: while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
break 'outer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Add loop label to continue
|
2016-11-17 13:28:38 -06:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 16:57:35 -06:00
|
|
|
pub fn add_loop_label_to_continue() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
'label: while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 08:34:10 -06:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items")]
|
2017-12-05 16:57:35 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn add_loop_label_to_continue() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
'label: while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
continue 'label;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change continue label
|
2016-11-17 13:28:38 -06:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 16:57:35 -06:00
|
|
|
pub fn change_continue_label() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
'outer: while let Some(0u32) = None {
|
|
|
|
'inner: while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
continue 'inner;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 08:34:10 -06:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items, mir_built")]
|
2017-12-05 16:57:35 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn change_continue_label() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
'outer: while let Some(0u32) = None {
|
|
|
|
'inner: while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
continue 'outer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change continue to break
|
2016-11-17 13:28:38 -06:00
|
|
|
#[cfg(cfail1)]
|
2017-12-05 16:57:35 -06:00
|
|
|
pub fn change_continue_to_break() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(cfail1))]
|
2020-02-12 08:34:10 -06:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_items, mir_built")]
|
2017-12-05 16:57:35 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
|
|
|
pub fn change_continue_to_break() {
|
2016-11-17 13:28:38 -06:00
|
|
|
let mut _x = 0;
|
|
|
|
while let Some(0u32) = None {
|
|
|
|
_x = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|