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