]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/macro_rules-braces.rs
Rollup merge of #78138 - fortanix:raoul/dlmalloc0.2, r=Mark-Simulacrum
[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 #![cfg_attr(min, feature(min_const_generics))]
5
6 fn test<const N: usize>() {
7     struct Foo<const M: usize>;
8     macro_rules! foo {
9         ($x:expr) => {
10             [u8; $x] //[full]~ ERROR constant expression depends
11         }
12     }
13     macro_rules! bar {
14         ($x:expr) => {
15             [u8; { $x }] //[full]~ ERROR constant expression depends
16         }
17     }
18     macro_rules! baz {
19         ( $x:expr) => {
20             Foo<$x> //[full]~ ERROR constant expression depends
21         }
22     }
23     macro_rules! biz {
24         ($x:expr) => {
25             Foo<{ $x }> //[full]~ ERROR constant expression depends
26         };
27     }
28
29     let _: foo!(N);
30     let _: foo!({ N });
31     let _: foo!({{ N }}); //[min]~ ERROR generic parameters may not
32     let _: bar!(N);
33     let _: bar!({ N }); //[min]~ ERROR generic parameters may not
34     let _: baz!(N); //~ ERROR expressions must be enclosed in braces
35     let _: baz!({ N });
36     let _: baz!({{ N }}); //[min]~ ERROR generic parameters may not
37     let _: biz!(N);
38     let _: biz!({ N }); //[min]~ ERROR generic parameters may not
39 }
40
41 fn main() {
42     test::<3>();
43 }