rust/tests/ui/consts/assoc-const.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
360 B
Rust
Raw Normal View History

// run-pass
#![allow(unused_variables)]
trait Nat {
const VALUE: usize;
}
struct Zero;
2022-07-25 15:36:03 -05:00
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];
}