Skip to content

Commit

Permalink
Add ui tests for panic![123] and panic!{123}.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Feb 14, 2021
1 parent 37c532c commit 8ad12bb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/test/ui/non-fmt-panic.rs
Expand Up @@ -37,6 +37,9 @@ fn main() {

panic!(format!("{}", 1)); //~ WARN panic message is not a string literal

panic![123]; //~ WARN panic message is not a string literal
panic!{123}; //~ WARN panic message is not a string literal

// Check that the lint only triggers for std::panic and core::panic,
// not any panic macro:
macro_rules! panic {
Expand Down
34 changes: 33 additions & 1 deletion src/test/ui/non-fmt-panic.stderr
Expand Up @@ -212,5 +212,37 @@ help: remove the `format!(..)` macro call
LL | panic!("{}", 1);
| -- --

warning: 16 warnings emitted
warning: panic message is not a string literal
--> $DIR/non-fmt-panic.rs:40:12
|
LL | panic![123];
| ^^^
|
= note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
|
LL | panic!["{}", 123];
| ^^^^^
help: or use std::panic::panic_any instead
|
LL | std::panic::panic_any(123);
| ^^^^^^^^^^^^^^^^^^^^^^ ^

warning: panic message is not a string literal
--> $DIR/non-fmt-panic.rs:41:12
|
LL | panic!{123};
| ^^^
|
= note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
|
LL | panic!{"{}", 123};
| ^^^^^
help: or use std::panic::panic_any instead
|
LL | std::panic::panic_any(123);
| ^^^^^^^^^^^^^^^^^^^^^^ ^

warning: 18 warnings emitted

0 comments on commit 8ad12bb

Please sign in to comment.