]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/usefulness/issue-43253.rs
Add test for eval order for a+=b
[rust.git] / src / test / ui / pattern / usefulness / issue-43253.rs
1 // check-pass
2 #![feature(exclusive_range_pattern)]
3 #![warn(unreachable_patterns)]
4 #![warn(overlapping_patterns)]
5
6 fn main() {
7     // These cases should generate no warning.
8     match 10 {
9         1..10 => {},
10         10 => {},
11         _ => {},
12     }
13
14     match 10 {
15         1..10 => {},
16         9..=10 => {}, //~ WARNING multiple patterns covering the same range
17         _ => {},
18     }
19
20     match 10 {
21         1..10 => {},
22         10..=10 => {},
23         _ => {},
24     }
25
26     // These cases should generate "unreachable pattern" warnings.
27     match 10 {
28         1..10 => {},
29         9 => {}, //~ WARNING unreachable pattern
30         _ => {},
31     }
32
33     match 10 {
34         1..10 => {},
35         8..=9 => {}, //~ WARNING unreachable pattern
36         _ => {},
37     }
38
39     match 10 {
40         5..7 => {},
41         6 => {}, //~ WARNING unreachable pattern
42         1..10 => {},
43         9..=9 => {}, //~ WARNING unreachable pattern
44         6 => {}, //~ WARNING unreachable pattern
45         _ => {},
46     }
47 }