]> git.lizzy.rs Git - rust.git/blob - src/test/ui/binding/exhaustive-bool-match-sanity.rs
Rollup merge of #93663 - sunfishcode:sunfishcode/as-raw-name, r=joshtriplett
[rust.git] / src / test / ui / binding / exhaustive-bool-match-sanity.rs
1 // run-pass
2 // Issue #33540
3 // We previously used to generate a 3-armed boolean `SwitchInt` in the
4 // MIR of the function `foo` below. #33583 changed rustc to
5 // generate an `If` terminator instead. This test is to just ensure
6 // sanity in that we generate an if-else chain giving the correct
7 // results.
8
9 fn foo(x: bool, y: bool) -> u32 {
10     match (x, y) {
11         (false, _) => 0,
12         (_, false) => 1,
13         (true, true) => 2
14     }
15 }
16
17 fn main() {
18     assert_eq!(foo(false, true), 0);
19     assert_eq!(foo(false, false), 0);
20     assert_eq!(foo(true, false), 1);
21     assert_eq!(foo(true, true), 2);
22 }