summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/assoc-const.rs
blob: f542f2dcb523f5e662b40f76d9113440eea458ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// run-pass
#![allow(unused_variables)]

trait Nat {
    const VALUE: usize;
}

struct Zero;
struct Succ<N>(#[allow(unused_tuple_struct_fields)] N);

impl Nat for Zero {
    const VALUE: usize = 0;
}

impl<N: Nat> Nat for Succ<N> {
    const VALUE: usize = N::VALUE + 1;
}

fn main() {
    let x: [i32; <Succ<Succ<Succ<Succ<Zero>>>>>::VALUE] = [1, 2, 3, 4];
}