forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#81647 - m-ou-se:assert-2021-fix, r=petroche…
…nkov Fix bug with assert!() calling the wrong edition of panic!(). The span of `panic!` produced by the `assert` macro did not carry the right edition. This changes `assert` to call the right version. Also adds tests for the 2021 edition of panic and assert, that would've caught this.
- Loading branch information
Showing
4 changed files
with
54 additions
and
3 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
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,9 @@ | ||
// edition:2021 | ||
|
||
fn main() { | ||
panic!(123); //~ ERROR: format argument must be a string literal | ||
panic!("{}"); //~ ERROR: 1 positional argument in format string | ||
core::panic!("{}"); //~ ERROR: 1 positional argument in format string | ||
assert!(false, 123); //~ ERROR: format argument must be a string literal | ||
assert!(false, "{}"); //~ ERROR: 1 positional argument in format string | ||
} |
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,42 @@ | ||
error: format argument must be a string literal | ||
--> $DIR/panic-2021.rs:4:12 | ||
| | ||
LL | panic!(123); | ||
| ^^^ | ||
| | ||
help: you might be missing a string literal to format with | ||
| | ||
LL | panic!("{}", 123); | ||
| ^^^^^ | ||
|
||
error: 1 positional argument in format string, but no arguments were given | ||
--> $DIR/panic-2021.rs:5:13 | ||
| | ||
LL | panic!("{}"); | ||
| ^^ | ||
|
||
error: 1 positional argument in format string, but no arguments were given | ||
--> $DIR/panic-2021.rs:6:19 | ||
| | ||
LL | core::panic!("{}"); | ||
| ^^ | ||
|
||
error: format argument must be a string literal | ||
--> $DIR/panic-2021.rs:7:20 | ||
| | ||
LL | assert!(false, 123); | ||
| ^^^ | ||
| | ||
help: you might be missing a string literal to format with | ||
| | ||
LL | assert!(false, "{}", 123); | ||
| ^^^^^ | ||
|
||
error: 1 positional argument in format string, but no arguments were given | ||
--> $DIR/panic-2021.rs:8:21 | ||
| | ||
LL | assert!(false, "{}"); | ||
| ^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|