This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed
src/test/ui/const-generics Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,17 @@ help: enclose the `const` expression in braces
99LL | let _: baz!({ N });
1010 | ^ ^
1111
12+ error: expressions must be enclosed in braces to be used as const generic arguments
13+ --> $DIR/macro_rules-braces.rs:54:17
14+ |
15+ LL | let _: baz!(10 + 7);
16+ | ^^^^^^
17+ |
18+ help: enclose the `const` expression in braces
19+ |
20+ LL | let _: baz!({ 10 + 7 });
21+ | ^ ^
22+
1223error: constant expression depends on a generic parameter
1324 --> $DIR/macro_rules-braces.rs:10:13
1425 |
@@ -57,5 +68,5 @@ LL | let _: biz!({ N });
5768 = note: this may fail depending on what value the parameter takes
5869 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
5970
60- error: aborting due to 5 previous errors
71+ error: aborting due to 6 previous errors
6172
Original file line number Diff line number Diff line change @@ -9,6 +9,17 @@ help: enclose the `const` expression in braces
99LL | let _: baz!({ N });
1010 | ^ ^
1111
12+ error: expressions must be enclosed in braces to be used as const generic arguments
13+ --> $DIR/macro_rules-braces.rs:54:17
14+ |
15+ LL | let _: baz!(10 + 7);
16+ | ^^^^^^
17+ |
18+ help: enclose the `const` expression in braces
19+ |
20+ LL | let _: baz!({ 10 + 7 });
21+ | ^ ^
22+
1223error: generic parameters may not be used in const operations
1324 --> $DIR/macro_rules-braces.rs:31:20
1425 |
@@ -41,5 +52,5 @@ LL | let _: biz!({ N });
4152 |
4253 = help: const parameters may only be used as standalone arguments, i.e. `N`
4354
44- error: aborting due to 5 previous errors
55+ error: aborting due to 6 previous errors
4556
Original file line number Diff line number Diff line change @@ -36,6 +36,26 @@ fn test<const N: usize>() {
3636 let _: baz ! ( { { N } } ) ; //[min]~ ERROR generic parameters may not
3737 let _: biz ! ( N ) ;
3838 let _: biz ! ( { N } ) ; //[min]~ ERROR generic parameters may not
39+ let _: foo ! ( 3 ) ;
40+ let _: foo ! ( { 3 } ) ;
41+ let _: foo ! ( { { 3 } } ) ;
42+ let _: bar ! ( 3 ) ;
43+ let _: bar ! ( { 3 } ) ;
44+ let _: baz ! ( 3 ) ;
45+ let _: baz ! ( { 3 } ) ;
46+ let _: baz ! ( { { 3 } } ) ;
47+ let _: biz ! ( 3 ) ;
48+ let _: biz ! ( { 3 } ) ;
49+ let _: foo ! ( 10 + 7 ) ;
50+ let _: foo ! ( { 10 + 7 } ) ;
51+ let _: foo ! ( { { 10 + 7 } } ) ;
52+ let _: bar ! ( 10 + 7 ) ;
53+ let _: bar ! ( { 10 + 7 } ) ;
54+ let _: baz ! ( 10 + 7 ) ; //~ ERROR expressions must be enclosed in braces
55+ let _: baz ! ( { 10 + 7 } ) ;
56+ let _: baz ! ( { { 10 + 7 } } ) ;
57+ let _: biz ! ( 10 + 7 ) ;
58+ let _: biz ! ( { 10 + 7 } ) ;
3959}
4060
4161fn main ( ) {
You can’t perform that action at this time.
0 commit comments