Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend macro braces test #79130

Merged
merged 1 commit into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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