Skip to content

Commit

Permalink
extend macro braces test
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Nov 17, 2020
1 parent b5c37e8 commit 5f2a627
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/test/ui/const-generics/macro_rules-braces.full.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ help: enclose the `const` expression in braces
LL | let _: baz!({ N });
| ^ ^

error: expressions must be enclosed in braces to be used as const generic arguments
--> $DIR/macro_rules-braces.rs:54:17
|
LL | let _: baz!(10 + 7);
| ^^^^^^
|
help: enclose the `const` expression in braces
|
LL | let _: baz!({ 10 + 7 });
| ^ ^

error: constant expression depends on a generic parameter
--> $DIR/macro_rules-braces.rs:10:13
|
Expand Down Expand Up @@ -57,5 +68,5 @@ LL | let _: biz!({ N });
= note: this may fail depending on what value the parameter takes
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 5 previous errors
error: aborting due to 6 previous errors

13 changes: 12 additions & 1 deletion src/test/ui/const-generics/macro_rules-braces.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ help: enclose the `const` expression in braces
LL | let _: baz!({ N });
| ^ ^

error: expressions must be enclosed in braces to be used as const generic arguments
--> $DIR/macro_rules-braces.rs:54:17
|
LL | let _: baz!(10 + 7);
| ^^^^^^
|
help: enclose the `const` expression in braces
|
LL | let _: baz!({ 10 + 7 });
| ^ ^

error: generic parameters may not be used in const operations
--> $DIR/macro_rules-braces.rs:31:20
|
Expand Down Expand Up @@ -41,5 +52,5 @@ LL | let _: biz!({ N });
|
= help: const parameters may only be used as standalone arguments, i.e. `N`

error: aborting due to 5 previous errors
error: aborting due to 6 previous errors

20 changes: 20 additions & 0 deletions src/test/ui/const-generics/macro_rules-braces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ fn test<const N: usize>() {
let _: baz!({{ N }}); //[min]~ ERROR generic parameters may not
let _: biz!(N);
let _: biz!({ N }); //[min]~ ERROR generic parameters may not
let _: foo!(3);
let _: foo!({ 3 });
let _: foo!({{ 3 }});
let _: bar!(3);
let _: bar!({ 3 });
let _: baz!(3);
let _: baz!({ 3 });
let _: baz!({{ 3 }});
let _: biz!(3);
let _: biz!({ 3 });
let _: foo!(10 + 7);
let _: foo!({ 10 + 7 });
let _: foo!({{ 10 + 7 }});
let _: bar!(10 + 7);
let _: bar!({ 10 + 7 });
let _: baz!(10 + 7); //~ ERROR expressions must be enclosed in braces
let _: baz!({ 10 + 7 });
let _: baz!({{ 10 + 7 }});
let _: biz!(10 + 7);
let _: biz!({ 10 + 7 });
}

fn main() {
Expand Down

0 comments on commit 5f2a627

Please sign in to comment.