summaryrefslogtreecommitdiffstats
path: root/src/test/ui/lint/dead-code/anon-const-in-pat.rs
blob: d3e39c0de69c85db3a6bfff5bad18ff1526ed826 (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
41
42
43
44
45
// check-pass
#![feature(inline_const_pat)]
#![allow(incomplete_features)]
#![deny(dead_code)]

const fn one() -> i32 {
    1
}

const fn two() -> i32 {
    2
}

const fn three() -> i32 {
    3
}

fn inline_const() {
    // rust-lang/rust#78171: dead_code lint triggers even though function is used in const pattern
    match 1 {
        const { one() } => {}
        _ => {}
    }
}

fn inline_const_range() {
    match 1 {
        1 ..= const { two() } => {}
        _ => {}
    }
}

struct S<const C: i32>;

fn const_generic_arg() {
    match S::<3> {
        S::<{three()}> => {}
    }
}

fn main() {
    inline_const();
    inline_const_range();
    const_generic_arg();
}