rust/tests/ui/consts/assoc-const.rs
2023-01-11 09:32:08 +00:00

22 lines
360 B
Rust

// 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];
}