about summary refs log tree commit diff
path: root/tests/ui/consts/mono-reachable-invalid-const.rs
blob: aba41dabe71f932ba76536860a3d751711536f9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//@ build-fail

struct Bar<const BITS: usize>;

impl<const BITS: usize> Bar<BITS> {
    const ASSERT: bool = {
        let b = std::convert::identity(1);
        ["oops"][b]; //~ ERROR index out of bounds: the length is 1 but the index is 1
        true
    };

    fn assert() {
        let val = Self::ASSERT;
        if val {
            std::convert::identity(val);
        }
    }
}

fn main() {
    Bar::<0>::assert();
}