replace usize with u32 to make it easier to bless

This commit is contained in:
Simon Vandel Sillesen 2020-09-19 23:38:54 +02:00
parent 5cc93950ac
commit 04834139c4
3 changed files with 15 additions and 18 deletions

View File

@ -1,19 +1,18 @@
// compile-flags: -Z mir-opt-level=3
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff
fn opt1(x: Option<usize>, y:Option<usize>) -> usize {
match (x,y) {
fn opt1(x: Option<u32>, y: Option<u32>) -> u32 {
match (x, y) {
(Some(a), Some(b)) => 0,
_ => 1
_ => 1,
}
}
// EMIT_MIR early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff
fn opt2(x: Option<usize>, y:Option<usize>) -> usize {
match (x,y) {
fn opt2(x: Option<u32>, y: Option<u32>) -> u32 {
match (x, y) {
(Some(a), Some(b)) => 0,
(None, None) => 0,
_ => 1
_ => 1,
}
}

View File

@ -1,11 +1,10 @@
// compile-flags: -Z mir-opt-level=3
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff
fn opt1(x: Option<usize>, y:Option<usize>, z:Option<usize>) -> usize {
match (x,y,z) {
fn opt1(x: Option<u32>, y: Option<u32>, z: Option<u32>) -> u32 {
match (x, y, z) {
(Some(a), Some(b), Some(c)) => 0,
_ => 1
_ => 1,
}
}

View File

@ -3,23 +3,22 @@
// must not optimize as it does not follow the pattern of
// left and right hand side being the same variant
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// EMIT_MIR early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff
fn noopt1(x: Option<usize>, y:Option<usize>) -> usize {
match (x,y) {
fn noopt1(x: Option<u32>, y: Option<u32>) -> u32 {
match (x, y) {
(Some(a), Some(b)) => 0,
(Some(a), None) => 1,
(None, Some(b)) => 2,
(None, None) => 3
(None, None) => 3,
}
}
// must not optimize as the types being matched on are not identical
// EMIT_MIR early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff
fn noopt2(x: Option<usize>, y:Option<bool>) -> usize {
match (x,y) {
fn noopt2(x: Option<u32>, y: Option<bool>) -> u32 {
match (x, y) {
(Some(a), Some(b)) => 0,
_ => 1
_ => 1,
}
}