summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern/usefulness/guards.rs
blob: b15440cf608bd3fe9d35e88fb5fd2b80eb129770 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#![feature(exclusive_range_pattern)]
#![deny(unreachable_patterns)]

enum Q { R(Option<usize>) }

pub fn main() {
    match Q::R(None) {
        Q::R(S) if S.is_some() => {}
        _ => {}
    }

    match 0u8 { //~ ERROR non-exhaustive patterns
        0 .. 128 => {}
        128 ..= 255 if true => {}
    }

    match 0u8 {
        0 .. 128 => {}
        128 ..= 255 if false => {}
        128 ..= 255 => {} // ok, because previous arm was guarded
    }
}