forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#70434 - Centril:fix-34421, r=estebank
suggest `;` on expr `mac!()` which is good as stmt `mac!()` Fixes rust-lang#34421 by implementing @jseyfried's suggestion in rust-lang#34421 (comment). r? @petrochenkov
- Loading branch information
Showing
4 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/test/ui/macros/issue-34421-mac-expr-bad-stmt-good-add-semi.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
macro_rules! make_item { | ||
($a:ident) => { | ||
struct $a; | ||
}; //~^ ERROR expected expression | ||
//~| ERROR expected expression | ||
} | ||
|
||
fn a() { | ||
make_item!(A) | ||
} | ||
fn b() { | ||
make_item!(B) | ||
} | ||
|
||
fn main() {} |
34 changes: 34 additions & 0 deletions
34
src/test/ui/macros/issue-34421-mac-expr-bad-stmt-good-add-semi.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
error: expected expression, found keyword `struct` | ||
--> $DIR/issue-34421-mac-expr-bad-stmt-good-add-semi.rs:3:9 | ||
| | ||
LL | struct $a; | ||
| ^^^^^^ expected expression | ||
... | ||
LL | make_item!(A) | ||
| ------------- in this macro invocation | ||
| | ||
= note: the macro call doesn't expand to an expression, but it can expand to a statement | ||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: add `;` to interpret the expansion as a statement | ||
| | ||
LL | make_item!(A); | ||
| ^ | ||
|
||
error: expected expression, found keyword `struct` | ||
--> $DIR/issue-34421-mac-expr-bad-stmt-good-add-semi.rs:3:9 | ||
| | ||
LL | struct $a; | ||
| ^^^^^^ expected expression | ||
... | ||
LL | make_item!(B) | ||
| ------------- in this macro invocation | ||
| | ||
= note: the macro call doesn't expand to an expression, but it can expand to a statement | ||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: add `;` to interpret the expansion as a statement | ||
| | ||
LL | make_item!(B); | ||
| ^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters