File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ fn main() {
3535
3636 panic ! ( a!( ) ) ; //~ WARN panic message is not a string literal
3737
38+ panic ! ( format!( "{}" , 1 ) ) ; //~ WARN panic message is not a string literal
39+
3840 // Check that the lint only triggers for std::panic and core::panic,
3941 // not any panic macro:
4042 macro_rules! panic {
Original file line number Diff line number Diff line change @@ -199,5 +199,18 @@ help: or use std::panic::panic_any instead
199199LL | std::panic::panic_any(a!());
200200 | ^^^^^^^^^^^^^^^^^^^^^^
201201
202- warning: 15 warnings emitted
202+ warning: panic message is not a string literal
203+ --> $DIR/non-fmt-panic.rs:38:12
204+ |
205+ LL | panic!(format!("{}", 1));
206+ | ^^^^^^^^^^^^^^^^
207+ |
208+ = note: this is no longer accepted in Rust 2021
209+ = note: the panic!() macro supports formatting, so there's no need for the format!() macro here
210+ help: remove the `format!(..)` macro call
211+ |
212+ LL | panic!("{}", 1);
213+ | -- --
214+
215+ warning: 16 warnings emitted
203216
You can’t perform that action at this time.
0 commit comments