Add test for panic!(format!(..)) lint.
This commit is contained in:
parent
a428ab17ab
commit
9f97a0b364
2 changed files with 16 additions and 1 deletions
|
@ -35,6 +35,8 @@ fn main() {
|
||||||
|
|
||||||
panic!(a!()); //~ WARN panic message is not a string literal
|
panic!(a!()); //~ WARN panic message is not a string literal
|
||||||
|
|
||||||
|
panic!(format!("{}", 1)); //~ WARN panic message is not a string literal
|
||||||
|
|
||||||
// Check that the lint only triggers for std::panic and core::panic,
|
// Check that the lint only triggers for std::panic and core::panic,
|
||||||
// not any panic macro:
|
// not any panic macro:
|
||||||
macro_rules! panic {
|
macro_rules! panic {
|
||||||
|
|
|
@ -199,5 +199,18 @@ help: or use std::panic::panic_any instead
|
||||||
LL | std::panic::panic_any(a!());
|
LL | std::panic::panic_any(a!());
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: 15 warnings emitted
|
warning: panic message is not a string literal
|
||||||
|
--> $DIR/non-fmt-panic.rs:38:12
|
||||||
|
|
|
||||||
|
LL | panic!(format!("{}", 1));
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this is no longer accepted in Rust 2021
|
||||||
|
= note: the panic!() macro supports formatting, so there's no need for the format!() macro here
|
||||||
|
help: remove the `format!(..)` macro call
|
||||||
|
|
|
||||||
|
LL | panic!("{}", 1);
|
||||||
|
| -- --
|
||||||
|
|
||||||
|
warning: 16 warnings emitted
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue