]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/associated-consts/associated-const-range-match-patterns.rs
Auto merge of #61361 - estebank:infer-type, r=varkor
[rust.git] / src / test / run-pass / associated-consts / associated-const-range-match-patterns.rs
1 // run-pass
2 #![allow(dead_code, unreachable_patterns)]
3 #![allow(ellipsis_inclusive_range_patterns)]
4
5 struct Foo;
6
7 trait HasNum {
8     const NUM: isize;
9 }
10 impl HasNum for Foo {
11     const NUM: isize = 1;
12 }
13
14 fn main() {
15     assert!(match 2 {
16         Foo::NUM ... 3 => true,
17         _ => false,
18     });
19     assert!(match 0 {
20         -1 ... <Foo as HasNum>::NUM => true,
21         _ => false,
22     });
23     assert!(match 1 {
24         <Foo as HasNum>::NUM ... <Foo>::NUM => true,
25         _ => false,
26     });
27
28     assert!(match 2 {
29         Foo::NUM ..= 3 => true,
30         _ => false,
31     });
32     assert!(match 0 {
33         -1 ..= <Foo as HasNum>::NUM => true,
34         _ => false,
35     });
36     assert!(match 1 {
37         <Foo as HasNum>::NUM ..= <Foo>::NUM => true,
38         _ => false,
39     });
40 }