summaryrefslogtreecommitdiffstats
path: root/src/test/ui/const-generics/early/macro_rules-braces.rs
blob: 0ae914635995898a563c450a30ef484e8a28c89b (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
mod m {
    pub const P: usize = 0;
}

const Q: usize = 0;

fn test<const N: usize>() {
    struct Foo<const M: usize>;
    macro_rules! foo {
        ($x:expr) => {
            [u8; $x]
        }
    }
    macro_rules! bar {
        ($x:expr) => {
            [u8; { $x }]
        }
    }
    macro_rules! baz {
        ( $x:expr) => {
            Foo<$x>
        }
    }
    macro_rules! biz {
        ($x:expr) => {
            Foo<{ $x }>
        };
    }

    let _: foo!(N);
    let _: foo!({ N });
    let _: foo!({{ N }}); //~ ERROR generic parameters may not
    let _: foo!(Q);
    let _: foo!(m::P);
    let _: bar!(N);
    let _: bar!({ N }); //~ ERROR generic parameters may not
    let _: bar!(Q);
    let _: bar!(m::P);
    let _: baz!(N);
    let _: baz!({ N });
    let _: baz!({{ N }}); //~ ERROR generic parameters may not
    let _: baz!(Q);
    let _: baz!({ m::P });
    let _: baz!(m::P); //~ ERROR expressions must be enclosed in braces
    let _: biz!(N);
    let _: biz!({ N }); //~ ERROR generic parameters may not
    let _: biz!(Q);
    let _: biz!(m::P);
    let _: foo!(3);
    let _: foo!({ 3 });
    let _: foo!({{ 3 }});
    let _: bar!(3);
    let _: bar!({ 3 });
    let _: baz!(3);
    let _: baz!({ 3 });
    let _: baz!({{ 3 }});
    let _: biz!(3);
    let _: biz!({ 3 });
    let _: foo!(10 + 7);
    let _: foo!({ 10 + 7 });
    let _: foo!({{ 10 + 7 }});
    let _: bar!(10 + 7);
    let _: bar!({ 10 + 7 });
    let _: baz!(10 + 7); //~ ERROR expressions must be enclosed in braces
    let _: baz!({ 10 + 7 });
    let _: baz!({{ 10 + 7 }});
    let _: biz!(10 + 7);
    let _: biz!({ 10 + 7 });
}

fn main() {
    test::<3>();
}