File tree 3 files changed +44
-2
lines changed
src/test/ui/const-generics
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
9
9
LL | let _: baz!({ N });
10
10
| ^ ^
11
11
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
+
12
23
error: constant expression depends on a generic parameter
13
24
--> $DIR/macro_rules-braces.rs:10:13
14
25
|
@@ -57,5 +68,5 @@ LL | let _: biz!({ N });
57
68
= note: this may fail depending on what value the parameter takes
58
69
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
59
70
60
- error: aborting due to 5 previous errors
71
+ error: aborting due to 6 previous errors
61
72
Original file line number Diff line number Diff line change @@ -9,6 +9,17 @@ help: enclose the `const` expression in braces
9
9
LL | let _: baz!({ N });
10
10
| ^ ^
11
11
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
+
12
23
error: generic parameters may not be used in const operations
13
24
--> $DIR/macro_rules-braces.rs:31:20
14
25
|
@@ -41,5 +52,5 @@ LL | let _: biz!({ N });
41
52
|
42
53
= help: const parameters may only be used as standalone arguments, i.e. `N`
43
54
44
- error: aborting due to 5 previous errors
55
+ error: aborting due to 6 previous errors
45
56
Original file line number Diff line number Diff line change @@ -36,6 +36,26 @@ fn test<const N: usize>() {
36
36
let _: baz ! ( { { N } } ) ; //[min]~ ERROR generic parameters may not
37
37
let _: biz ! ( N ) ;
38
38
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 } ) ;
39
59
}
40
60
41
61
fn main ( ) {
You can’t perform that action at this time.
0 commit comments