]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/macro_rules-braces.rs
Auto merge of #79578 - alexcrichton:update-waasi, r=KodrAus
[rust.git] / src / test / ui / const-generics / macro_rules-braces.rs
1 // revisions: full min
2 #![cfg_attr(full, allow(incomplete_features))]
3 #![cfg_attr(full, feature(const_generics))]
4
5 mod m {
6     pub const P: usize = 0;
7 }
8
9 const Q: usize = 0;
10
11 fn test<const N: usize>() {
12     struct Foo<const M: usize>;
13     macro_rules! foo {
14         ($x:expr) => {
15             [u8; $x] //[full]~ ERROR constant expression depends
16         }
17     }
18     macro_rules! bar {
19         ($x:expr) => {
20             [u8; { $x }] //[full]~ ERROR constant expression depends
21         }
22     }
23     macro_rules! baz {
24         ( $x:expr) => {
25             Foo<$x> //[full]~ ERROR constant expression depends
26         }
27     }
28     macro_rules! biz {
29         ($x:expr) => {
30             Foo<{ $x }> //[full]~ ERROR constant expression depends
31         };
32     }
33
34     let _: foo!(N);
35     let _: foo!({ N });
36     let _: foo!({{ N }}); //[min]~ ERROR generic parameters may not
37     let _: foo!(Q);
38     let _: foo!(m::P);
39     let _: bar!(N);
40     let _: bar!({ N }); //[min]~ ERROR generic parameters may not
41     let _: bar!(Q);
42     let _: bar!(m::P);
43     let _: baz!(N);
44     let _: baz!({ N });
45     let _: baz!({{ N }}); //[min]~ ERROR generic parameters may not
46     let _: baz!(Q);
47     let _: baz!({ m::P });
48     let _: baz!(m::P); //~ ERROR expressions must be enclosed in braces
49     let _: biz!(N);
50     let _: biz!({ N }); //[min]~ ERROR generic parameters may not
51     let _: biz!(Q);
52     let _: biz!(m::P);
53     let _: foo!(3);
54     let _: foo!({ 3 });
55     let _: foo!({{ 3 }});
56     let _: bar!(3);
57     let _: bar!({ 3 });
58     let _: baz!(3);
59     let _: baz!({ 3 });
60     let _: baz!({{ 3 }});
61     let _: biz!(3);
62     let _: biz!({ 3 });
63     let _: foo!(10 + 7);
64     let _: foo!({ 10 + 7 });
65     let _: foo!({{ 10 + 7 }});
66     let _: bar!(10 + 7);
67     let _: bar!({ 10 + 7 });
68     let _: baz!(10 + 7); //~ ERROR expressions must be enclosed in braces
69     let _: baz!({ 10 + 7 });
70     let _: baz!({{ 10 + 7 }});
71     let _: biz!(10 + 7);
72     let _: biz!({ 10 + 7 });
73 }
74
75 fn main() {
76     test::<3>();
77 }