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#121651 - ShE3py:issue-121647, r=estebank
Properly emit `expected ;` on `#[attr] expr` Fixes rust-lang#121647 See rust-lang#118182, rust-lang#120586 --- r? estebank
- Loading branch information
Showing
5 changed files
with
45 additions
and
6 deletions.
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
File renamed without changes.
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
tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body-2.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 @@ | ||
// Issue #121647: recovery path leaving unemitted error behind | ||
|
||
macro_rules! the_macro { | ||
( $foo:stmt ; $bar:stmt ; ) => { | ||
#[cfg()] | ||
$foo //~ ERROR expected `;`, found `#` | ||
|
||
#[cfg(bar)] | ||
$bar | ||
}; | ||
} | ||
|
||
fn main() { | ||
the_macro!( (); (); ); | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/ui/parser/attribute/properly-recover-from-trailing-outer-attribute-in-body-2.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,26 @@ | ||
error: expected `;`, found `#` | ||
--> $DIR/properly-recover-from-trailing-outer-attribute-in-body-2.rs:6:13 | ||
| | ||
LL | #[cfg()] | ||
| -------- only `;` terminated statements or tail expressions are allowed after this attribute | ||
LL | $foo | ||
| ^ expected `;` here | ||
LL | | ||
LL | #[cfg(bar)] | ||
| - unexpected token | ||
... | ||
LL | the_macro!( (); (); ); | ||
| --------------------- in this macro invocation | ||
| | ||
= note: this error originates in the macro `the_macro` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: add `;` here | ||
| | ||
LL | $foo; | ||
| + | ||
help: alternatively, consider surrounding the expression with a block | ||
| | ||
LL | the_macro!( { () }; (); ); | ||
| + + | ||
|
||
error: aborting due to 1 previous error | ||
|