-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This also explicitly checks that the types are `bool`. `try_eval_bool` also appears to just succeed for `u8`, so this ensures that it actually is a bool before casting.
- Loading branch information
1 parent
c0a811a
commit fd74026
Showing
6 changed files
with
179 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/test/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff.32bit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
- // MIR for `exhaustive_match` before MatchBranchSimplification | ||
+ // MIR for `exhaustive_match` after MatchBranchSimplification | ||
|
||
fn exhaustive_match(_1: E) -> u8 { | ||
debug e => _1; // in scope 0 at $DIR/matches_u8.rs:11:25: 11:26 | ||
let mut _0: u8; // return place in scope 0 at $DIR/matches_u8.rs:11:34: 11:36 | ||
let mut _2: isize; // in scope 0 at $DIR/matches_u8.rs:13:9: 13:13 | ||
|
||
bb0: { | ||
_2 = discriminant(_1); // scope 0 at $DIR/matches_u8.rs:13:9: 13:13 | ||
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_u8.rs:13:9: 13:13 | ||
} | ||
|
||
bb1: { | ||
_0 = const 1_u8; // scope 0 at $DIR/matches_u8.rs:14:17: 14:18 | ||
// ty::Const | ||
// + ty: u8 | ||
// + val: Value(Scalar(0x01)) | ||
// mir::Constant | ||
// + span: $DIR/matches_u8.rs:14:17: 14:18 | ||
// + literal: Const { ty: u8, val: Value(Scalar(0x01)) } | ||
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:12:5: 15:6 | ||
} | ||
|
||
bb2: { | ||
_0 = const 0_u8; // scope 0 at $DIR/matches_u8.rs:13:17: 13:18 | ||
// ty::Const | ||
// + ty: u8 | ||
// + val: Value(Scalar(0x00)) | ||
// mir::Constant | ||
// + span: $DIR/matches_u8.rs:13:17: 13:18 | ||
// + literal: Const { ty: u8, val: Value(Scalar(0x00)) } | ||
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:12:5: 15:6 | ||
} | ||
|
||
bb3: { | ||
return; // scope 0 at $DIR/matches_u8.rs:16:2: 16:2 | ||
} | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
src/test/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff.64bit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
- // MIR for `exhaustive_match` before MatchBranchSimplification | ||
+ // MIR for `exhaustive_match` after MatchBranchSimplification | ||
|
||
fn exhaustive_match(_1: E) -> u8 { | ||
debug e => _1; // in scope 0 at $DIR/matches_u8.rs:11:25: 11:26 | ||
let mut _0: u8; // return place in scope 0 at $DIR/matches_u8.rs:11:34: 11:36 | ||
let mut _2: isize; // in scope 0 at $DIR/matches_u8.rs:13:9: 13:13 | ||
|
||
bb0: { | ||
_2 = discriminant(_1); // scope 0 at $DIR/matches_u8.rs:13:9: 13:13 | ||
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_u8.rs:13:9: 13:13 | ||
} | ||
|
||
bb1: { | ||
_0 = const 1_u8; // scope 0 at $DIR/matches_u8.rs:14:17: 14:18 | ||
// ty::Const | ||
// + ty: u8 | ||
// + val: Value(Scalar(0x01)) | ||
// mir::Constant | ||
// + span: $DIR/matches_u8.rs:14:17: 14:18 | ||
// + literal: Const { ty: u8, val: Value(Scalar(0x01)) } | ||
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:12:5: 15:6 | ||
} | ||
|
||
bb2: { | ||
_0 = const 0_u8; // scope 0 at $DIR/matches_u8.rs:13:17: 13:18 | ||
// ty::Const | ||
// + ty: u8 | ||
// + val: Value(Scalar(0x00)) | ||
// mir::Constant | ||
// + span: $DIR/matches_u8.rs:13:17: 13:18 | ||
// + literal: Const { ty: u8, val: Value(Scalar(0x00)) } | ||
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:12:5: 15:6 | ||
} | ||
|
||
bb3: { | ||
return; // scope 0 at $DIR/matches_u8.rs:16:2: 16:2 | ||
} | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
src/test/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff.32bit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
- // MIR for `exhaustive_match_i8` before MatchBranchSimplification | ||
+ // MIR for `exhaustive_match_i8` after MatchBranchSimplification | ||
|
||
fn exhaustive_match_i8(_1: E) -> i8 { | ||
debug e => _1; // in scope 0 at $DIR/matches_u8.rs:19:28: 19:29 | ||
let mut _0: i8; // return place in scope 0 at $DIR/matches_u8.rs:19:37: 19:39 | ||
let mut _2: isize; // in scope 0 at $DIR/matches_u8.rs:21:9: 21:13 | ||
|
||
bb0: { | ||
_2 = discriminant(_1); // scope 0 at $DIR/matches_u8.rs:21:9: 21:13 | ||
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_u8.rs:21:9: 21:13 | ||
} | ||
|
||
bb1: { | ||
_0 = const 1_i8; // scope 0 at $DIR/matches_u8.rs:22:17: 22:18 | ||
// ty::Const | ||
// + ty: i8 | ||
// + val: Value(Scalar(0x01)) | ||
// mir::Constant | ||
// + span: $DIR/matches_u8.rs:22:17: 22:18 | ||
// + literal: Const { ty: i8, val: Value(Scalar(0x01)) } | ||
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:20:5: 23:6 | ||
} | ||
|
||
bb2: { | ||
_0 = const 0_i8; // scope 0 at $DIR/matches_u8.rs:21:17: 21:18 | ||
// ty::Const | ||
// + ty: i8 | ||
// + val: Value(Scalar(0x00)) | ||
// mir::Constant | ||
// + span: $DIR/matches_u8.rs:21:17: 21:18 | ||
// + literal: Const { ty: i8, val: Value(Scalar(0x00)) } | ||
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:20:5: 23:6 | ||
} | ||
|
||
bb3: { | ||
return; // scope 0 at $DIR/matches_u8.rs:24:2: 24:2 | ||
} | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
src/test/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff.64bit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
- // MIR for `exhaustive_match_i8` before MatchBranchSimplification | ||
+ // MIR for `exhaustive_match_i8` after MatchBranchSimplification | ||
|
||
fn exhaustive_match_i8(_1: E) -> i8 { | ||
debug e => _1; // in scope 0 at $DIR/matches_u8.rs:19:28: 19:29 | ||
let mut _0: i8; // return place in scope 0 at $DIR/matches_u8.rs:19:37: 19:39 | ||
let mut _2: isize; // in scope 0 at $DIR/matches_u8.rs:21:9: 21:13 | ||
|
||
bb0: { | ||
_2 = discriminant(_1); // scope 0 at $DIR/matches_u8.rs:21:9: 21:13 | ||
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/matches_u8.rs:21:9: 21:13 | ||
} | ||
|
||
bb1: { | ||
_0 = const 1_i8; // scope 0 at $DIR/matches_u8.rs:22:17: 22:18 | ||
// ty::Const | ||
// + ty: i8 | ||
// + val: Value(Scalar(0x01)) | ||
// mir::Constant | ||
// + span: $DIR/matches_u8.rs:22:17: 22:18 | ||
// + literal: Const { ty: i8, val: Value(Scalar(0x01)) } | ||
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:20:5: 23:6 | ||
} | ||
|
||
bb2: { | ||
_0 = const 0_i8; // scope 0 at $DIR/matches_u8.rs:21:17: 21:18 | ||
// ty::Const | ||
// + ty: i8 | ||
// + val: Value(Scalar(0x00)) | ||
// mir::Constant | ||
// + span: $DIR/matches_u8.rs:21:17: 21:18 | ||
// + literal: Const { ty: i8, val: Value(Scalar(0x00)) } | ||
goto -> bb3; // scope 0 at $DIR/matches_u8.rs:20:5: 23:6 | ||
} | ||
|
||
bb3: { | ||
return; // scope 0 at $DIR/matches_u8.rs:24:2: 24:2 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters