summary refs log tree commit diff
path: root/src/test/ui/const-generics/macro_rules-braces.rs
blob: c3e2c8ba20359ff020cc1f28059f583b5747b7ca (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
// revisions: full min
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(min, feature(min_const_generics))]

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

    let _: foo!(N);
    let _: foo!({ N });
    let _: foo!({{ N }}); //[min]~ ERROR generic parameters may not
    let _: bar!(N);
    let _: bar!({ N }); //[min]~ ERROR generic parameters may not
    let _: baz!(N); //~ ERROR expressions must be enclosed in braces
    let _: baz!({ N });
    let _: baz!({{ N }}); //[min]~ ERROR generic parameters may not
    let _: biz!(N);
    let _: biz!({ N }); //[min]~ ERROR generic parameters may not
}

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