2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2014-05-04 17:16:16 -05:00
|
|
|
// Test that codegen works correctly when there are multiple refutable
|
|
|
|
// patterns in match expression.
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2014-05-04 17:16:16 -05:00
|
|
|
enum Foo {
|
2015-03-25 19:06:52 -05:00
|
|
|
FooUint(usize),
|
2014-05-04 17:16:16 -05:00
|
|
|
FooNullary,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2014-11-06 02:05:53 -06:00
|
|
|
let r = match (Foo::FooNullary, 'a') {
|
2018-05-28 21:42:11 -05:00
|
|
|
(Foo::FooUint(..), 'a'..='z') => 1,
|
2015-01-25 15:05:03 -06:00
|
|
|
(Foo::FooNullary, 'x') => 2,
|
2014-05-04 17:16:16 -05:00
|
|
|
_ => 0
|
|
|
|
};
|
|
|
|
assert_eq!(r, 0);
|
|
|
|
|
2014-11-06 02:05:53 -06:00
|
|
|
let r = match (Foo::FooUint(0), 'a') {
|
2018-05-28 21:42:11 -05:00
|
|
|
(Foo::FooUint(1), 'a'..='z') => 1,
|
2015-01-25 15:05:03 -06:00
|
|
|
(Foo::FooUint(..), 'x') => 2,
|
|
|
|
(Foo::FooNullary, 'a') => 3,
|
2014-05-04 17:16:16 -05:00
|
|
|
_ => 0
|
|
|
|
};
|
|
|
|
assert_eq!(r, 0);
|
|
|
|
|
2014-11-06 02:05:53 -06:00
|
|
|
let r = match ('a', Foo::FooUint(0)) {
|
2018-05-28 21:42:11 -05:00
|
|
|
('a'..='z', Foo::FooUint(1)) => 1,
|
2015-01-25 15:05:03 -06:00
|
|
|
('x', Foo::FooUint(..)) => 2,
|
|
|
|
('a', Foo::FooNullary) => 3,
|
2014-05-04 17:16:16 -05:00
|
|
|
_ => 0
|
|
|
|
};
|
|
|
|
assert_eq!(r, 0);
|
|
|
|
|
|
|
|
let r = match ('a', 'a') {
|
2018-05-28 21:42:11 -05:00
|
|
|
('a'..='z', 'b') => 1,
|
|
|
|
('x', 'a'..='z') => 2,
|
2014-05-04 17:16:16 -05:00
|
|
|
_ => 0
|
|
|
|
};
|
|
|
|
assert_eq!(r, 0);
|
|
|
|
|
|
|
|
let r = match ('a', 'a') {
|
2018-05-28 21:42:11 -05:00
|
|
|
('a'..='z', 'b') => 1,
|
|
|
|
('x', 'a'..='z') => 2,
|
2015-01-25 15:05:03 -06:00
|
|
|
('a', 'a') => 3,
|
2014-05-04 17:16:16 -05:00
|
|
|
_ => 0
|
|
|
|
};
|
|
|
|
assert_eq!(r, 3);
|
|
|
|
}
|