1
Fork 0

Add test for non_fmt_panic lint for panic!(some_macro!()).

This commit is contained in:
Mara Bos 2021-02-14 18:17:34 +01:00
parent ef778e7965
commit 1abc1e2a43
2 changed files with 23 additions and 1 deletions

View file

@ -29,6 +29,12 @@ fn main() {
fancy_panic::fancy_panic!(S);
//~^ WARN panic message is not a string literal
macro_rules! a {
() => { 123 };
}
panic!(a!()); //~ 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 {

View file

@ -183,5 +183,21 @@ LL | fancy_panic::fancy_panic!(S);
|
= note: this is no longer accepted in Rust 2021
warning: 14 warnings emitted
warning: panic message is not a string literal
--> $DIR/non-fmt-panic.rs:36:12
|
LL | panic!(a!());
| ^^^^
|
= note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
|
LL | panic!("{}", a!());
| ^^^^^
help: or use std::panic::panic_any instead
|
LL | std::panic::panic_any(a!());
| ^^^^^^^^^^^^^^^^^^^^^^
warning: 15 warnings emitted