Skip to content

Commit 5f2a627

Browse files
committed
extend macro braces test
1 parent b5c37e8 commit 5f2a627

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

src/test/ui/const-generics/macro_rules-braces.full.stderr

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ help: enclose the `const` expression in braces
99
LL | 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+
1223
error: 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

src/test/ui/const-generics/macro_rules-braces.min.stderr

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ help: enclose the `const` expression in braces
99
LL | 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+
1223
error: 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

src/test/ui/const-generics/macro_rules-braces.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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

4161
fn main() {

0 commit comments

Comments
 (0)