-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #60039 - rasendubi:assert-trailing-junk, r=alexcrichton
Make assert! ensure the macro is parsed completely Fixes #60024
- Loading branch information
Showing
3 changed files
with
151 additions
and
14 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
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,24 @@ | ||
// Ensure assert macro does not ignore trailing garbage. | ||
// | ||
// See https://github.com/rust-lang/rust/issues/60024 for details. | ||
|
||
fn main() { | ||
assert!(true some extra junk, "whatever"); | ||
//~^ ERROR expected one of | ||
|
||
assert!(true some extra junk); | ||
//~^ ERROR expected one of | ||
|
||
assert!(true, "whatever" blah); | ||
//~^ ERROR no rules expected | ||
|
||
assert!(true "whatever" blah); | ||
//~^ WARN unexpected string literal | ||
//~^^ ERROR no rules expected | ||
|
||
assert!(true;); | ||
//~^ WARN macro requires an expression | ||
|
||
assert!(false || true "error message"); | ||
//~^ WARN unexpected string literal | ||
} |
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,60 @@ | ||
error: expected one of `,`, `.`, `?`, or an operator, found `some` | ||
--> $DIR/assert-trailing-junk.rs:6:18 | ||
| | ||
LL | assert!(true some extra junk, "whatever"); | ||
| ^^^^ expected one of `,`, `.`, `?`, or an operator here | ||
|
||
error: expected one of `,`, `.`, `?`, or an operator, found `some` | ||
--> $DIR/assert-trailing-junk.rs:9:18 | ||
| | ||
LL | assert!(true some extra junk); | ||
| ^^^^ expected one of `,`, `.`, `?`, or an operator here | ||
|
||
error: no rules expected the token `blah` | ||
--> $DIR/assert-trailing-junk.rs:12:30 | ||
| | ||
LL | assert!(true, "whatever" blah); | ||
| -^^^^ no rules expected this token in macro call | ||
| | | ||
| help: missing comma here | ||
|
||
warning: unexpected string literal | ||
--> $DIR/assert-trailing-junk.rs:15:18 | ||
| | ||
LL | assert!(true "whatever" blah); | ||
| -^^^^^^^^^^ | ||
| | | ||
| help: try adding a comma | ||
| | ||
= note: this is going to be an error in the future | ||
|
||
error: no rules expected the token `blah` | ||
--> $DIR/assert-trailing-junk.rs:15:29 | ||
| | ||
LL | assert!(true "whatever" blah); | ||
| -^^^^ no rules expected this token in macro call | ||
| | | ||
| help: missing comma here | ||
|
||
warning: macro requires an expression as an argument | ||
--> $DIR/assert-trailing-junk.rs:19:5 | ||
| | ||
LL | assert!(true;); | ||
| ^^^^^^^^^^^^-^^ | ||
| | | ||
| help: try removing semicolon | ||
| | ||
= note: this is going to be an error in the future | ||
|
||
warning: unexpected string literal | ||
--> $DIR/assert-trailing-junk.rs:22:27 | ||
| | ||
LL | assert!(false || true "error message"); | ||
| -^^^^^^^^^^^^^^^ | ||
| | | ||
| help: try adding a comma | ||
| | ||
= note: this is going to be an error in the future | ||
|
||
error: aborting due to 4 previous errors | ||
|