]> git.proxmox.com Git - rustc.git/blame - src/test/ui/issues/issue-13867.rs
New upstream version 1.60.0+dfsg1
[rustc.git] / src / test / ui / issues / issue-13867.rs
CommitLineData
b7449926 1// run-pass
1a4d82fc
JJ
2// Test that codegen works correctly when there are multiple refutable
3// patterns in match expression.
4
5enum Foo {
c34b1796 6 FooUint(usize),
1a4d82fc
JJ
7 FooNullary,
8}
9
10fn main() {
11 let r = match (Foo::FooNullary, 'a') {
8faf50e0 12 (Foo::FooUint(..), 'a'..='z') => 1,
85aaf69f 13 (Foo::FooNullary, 'x') => 2,
1a4d82fc
JJ
14 _ => 0
15 };
16 assert_eq!(r, 0);
17
18 let r = match (Foo::FooUint(0), 'a') {
8faf50e0 19 (Foo::FooUint(1), 'a'..='z') => 1,
85aaf69f
SL
20 (Foo::FooUint(..), 'x') => 2,
21 (Foo::FooNullary, 'a') => 3,
1a4d82fc
JJ
22 _ => 0
23 };
24 assert_eq!(r, 0);
25
26 let r = match ('a', Foo::FooUint(0)) {
8faf50e0 27 ('a'..='z', Foo::FooUint(1)) => 1,
85aaf69f
SL
28 ('x', Foo::FooUint(..)) => 2,
29 ('a', Foo::FooNullary) => 3,
1a4d82fc
JJ
30 _ => 0
31 };
32 assert_eq!(r, 0);
33
34 let r = match ('a', 'a') {
8faf50e0
XL
35 ('a'..='z', 'b') => 1,
36 ('x', 'a'..='z') => 2,
1a4d82fc
JJ
37 _ => 0
38 };
39 assert_eq!(r, 0);
40
41 let r = match ('a', 'a') {
8faf50e0
XL
42 ('a'..='z', 'b') => 1,
43 ('x', 'a'..='z') => 2,
85aaf69f 44 ('a', 'a') => 3,
1a4d82fc
JJ
45 _ => 0
46 };
47 assert_eq!(r, 3);
48}