summaryrefslogtreecommitdiffstats
path: root/tests/ui/associated-consts/associated-const-range-match-patterns.rs
blob: 5276869a702eeb0c83e2c597d46cc5d4b7cf54fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// run-pass
#![allow(dead_code, unreachable_patterns)]
#![allow(ellipsis_inclusive_range_patterns)]

struct Foo;

trait HasNum {
    const NUM: isize;
}
impl HasNum for Foo {
    const NUM: isize = 1;
}

fn main() {
    assert!(match 2 {
        Foo::NUM ... 3 => true,
        _ => false,
    });
    assert!(match 0 {
        -1 ... <Foo as HasNum>::NUM => true,
        _ => false,
    });
    assert!(match 1 {
        <Foo as HasNum>::NUM ... <Foo>::NUM => true,
        _ => false,
    });

    assert!(match 2 {
        Foo::NUM ..= 3 => true,
        _ => false,
    });
    assert!(match 0 {
        -1 ..= <Foo as HasNum>::NUM => true,
        _ => false,
    });
    assert!(match 1 {
        <Foo as HasNum>::NUM ..= <Foo>::NUM => true,
        _ => false,
    });
}