rust/tests/ui/match/issue-72680.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.6 KiB
Rust
Raw Normal View History

// run-pass
fn main() {
2020-11-09 18:19:34 +00:00
assert!(f("", 0));
assert!(f("a", 1));
assert!(f("b", 1));
2020-11-09 18:19:34 +00:00
assert!(!f("", 1));
assert!(!f("a", 0));
assert!(!f("b", 0));
assert!(!f("asdf", 32));
////
2020-11-09 18:19:34 +00:00
assert!(!g(true, true, true));
assert!(!g(false, true, true));
assert!(!g(true, false, true));
assert!(!g(false, false, true));
assert!(!g(true, true, false));
2020-11-09 18:19:34 +00:00
assert!(g(false, true, false));
assert!(g(true, false, false));
assert!(g(false, false, false));
////
2020-11-09 18:19:34 +00:00
assert!(!h(true, true, true));
assert!(!h(false, true, true));
assert!(!h(true, false, true));
assert!(!h(false, false, true));
assert!(!h(true, true, false));
2020-11-09 18:19:34 +00:00
assert!(h(false, true, false));
assert!(h(true, false, false));
assert!(h(false, false, false));
}
fn f(s: &str, num: usize) -> bool {
match (s, num) {
("", 0) | ("a" | "b", 1) => true,
_ => false,
}
}
fn g(x: bool, y: bool, z: bool) -> bool {
match (x, y, x, z) {
(true | false, false, true, false) => true,
(false, true | false, true | false, false) => true,
(true | false, true | false, true | false, true) => false,
(true, true | false, true | false, false) => false,
}
}
fn h(x: bool, y: bool, z: bool) -> bool {
match (x, (y, (x, (z,)))) {
(true | false, (false, (true, (false,)))) => true,
(false, (true | false, (true | false, (false,)))) => true,
(true | false, (true | false, (true | false, (true,)))) => false,
(true, (true | false, (true | false, (false,)))) => false,
}
}