summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/target/const_generics.rs
blob: b30b7b58c12b975c757b32fa18aae109f0b4a8ed (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
struct Message {
    field2: Vec<"MessageEntity">,
    field3: Vec<1>,
    field4: Vec<2, 3>,
}

struct RectangularArray<T, const WIDTH: usize, const HEIGHT: usize> {
    array: [[T; WIDTH]; HEIGHT],
}

fn main() {
    const X: usize = 7;
    let x: RectangularArray<i32, 2, 4>;
    let y: RectangularArray<i32, X, { 2 * 2 }>;
}

fn foo<const X: usize>() {
    const Y: usize = X * 2;
    static Z: (usize, usize) = (X, X);

    struct Foo([i32; X]);
}

type Foo<const N: usize> = [i32; N + 1];

pub trait Foo: Bar<{ Baz::COUNT }> {
    const ASD: usize;
}

// #4263
fn const_generics_on_params<
    // AAAA
    const BBBB: usize,
    /* CCCC */
    const DDDD: usize,
>() {
}