2016-11-10 14:06:51 -06:00
|
|
|
// This test case tests the incremental compilation hash (ICH) implementation
|
|
|
|
// for if expressions.
|
|
|
|
|
|
|
|
// 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-11-10 14:06:51 -06:00
|
|
|
|
|
|
|
#![allow(warnings)]
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
#![crate_type="rlib"]
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change condition (if)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_condition(x: bool) -> u32 {
|
2021-04-22 14:33:16 -05:00
|
|
|
if x {
|
2016-11-10 14:06:51 -06:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2022-04-12 15:44:19 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
|
2017-11-12 18:13:42 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2022-04-12 15:44:19 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_condition(x: bool) -> u32 {
|
|
|
|
if !x {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change then branch (if)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_then_branch(x: bool) -> u32 {
|
|
|
|
if x {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
|
2017-11-12 18:13:42 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_then_branch(x: bool) -> u32 {
|
|
|
|
if x {
|
|
|
|
return 2
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change else branch (if)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_else_branch(x: bool) -> u32 {
|
|
|
|
if x {
|
|
|
|
1
|
|
|
|
} else {
|
|
|
|
2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
|
2017-11-12 18:13:42 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_else_branch(x: bool) -> u32 {
|
|
|
|
if x {
|
|
|
|
1
|
|
|
|
} else {
|
|
|
|
3
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Add else branch (if)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn add_else_branch(x: bool) -> u32 {
|
|
|
|
let mut ret = 1;
|
|
|
|
|
|
|
|
if x {
|
2017-11-14 14:12:04 -06:00
|
|
|
ret = 2;
|
2021-04-22 14:33:16 -05:00
|
|
|
/*----*/
|
2016-11-10 14:06:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
ret
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2022-04-12 15:44:19 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,typeck")]
|
2017-11-12 18:13:42 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2022-04-12 15:44:19 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,typeck")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn add_else_branch(x: bool) -> u32 {
|
|
|
|
let mut ret = 1;
|
|
|
|
|
|
|
|
if x {
|
2017-11-14 14:12:04 -06:00
|
|
|
ret = 2;
|
2016-11-10 14:06:51 -06:00
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
ret
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change condition (if let)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_condition_if_let(x: Option<u32>) -> u32 {
|
|
|
|
if let Some(_x) = x {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
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-11-12 18:13:42 -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")]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_condition_if_let(x: Option<u32>) -> u32 {
|
2021-04-22 14:33:16 -05:00
|
|
|
if let Some(_ ) = x {
|
2016-11-10 14:06:51 -06:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change then branch (if let)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_then_branch_if_let(x: Option<u32>) -> u32 {
|
|
|
|
if let Some(x) = x {
|
2021-04-22 14:33:16 -05:00
|
|
|
return x //-
|
2016-11-10 14:06:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2022-04-12 15:44:19 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
|
2017-11-12 18:13:42 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2022-04-12 15:44:19 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,optimized_mir,typeck")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_then_branch_if_let(x: Option<u32>) -> u32 {
|
|
|
|
if let Some(x) = x {
|
|
|
|
return x + 1
|
|
|
|
}
|
|
|
|
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Change else branch (if let)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_else_branch_if_let(x: Option<u32>) -> u32 {
|
|
|
|
if let Some(x) = x {
|
|
|
|
x
|
|
|
|
} else {
|
|
|
|
1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2020-07-06 17:35:06 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
|
2017-11-12 18:13:42 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
|
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn change_else_branch_if_let(x: Option<u32>) -> u32 {
|
|
|
|
if let Some(x) = x {
|
|
|
|
x
|
|
|
|
} else {
|
|
|
|
2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 16:31:46 -05:00
|
|
|
// Add else branch (if let)
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(any(cfail1,cfail4))]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn add_else_branch_if_let(x: Option<u32>) -> u32 {
|
|
|
|
let mut ret = 1;
|
|
|
|
|
|
|
|
if let Some(x) = x {
|
2017-11-14 14:12:04 -06:00
|
|
|
ret = x;
|
2021-04-22 14:33:16 -05:00
|
|
|
/*----*/
|
2016-11-10 14:06:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
ret
|
|
|
|
}
|
|
|
|
|
2021-04-22 14:33:16 -05:00
|
|
|
#[cfg(not(any(cfail1,cfail4)))]
|
2022-04-12 15:44:19 -05:00
|
|
|
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,typeck")]
|
2017-11-12 18:13:42 -06:00
|
|
|
#[rustc_clean(cfg="cfail3")]
|
2022-04-12 15:44:19 -05:00
|
|
|
#[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,typeck,optimized_mir")]
|
2021-04-22 14:33:16 -05:00
|
|
|
#[rustc_clean(cfg="cfail6")]
|
2016-11-10 14:06:51 -06:00
|
|
|
pub fn add_else_branch_if_let(x: Option<u32>) -> u32 {
|
|
|
|
let mut ret = 1;
|
|
|
|
|
|
|
|
if let Some(x) = x {
|
2017-11-14 14:12:04 -06:00
|
|
|
ret = x;
|
2016-11-10 14:06:51 -06:00
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
ret
|
|
|
|
}
|