File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ fn main() {
35
35
36
36
panic ! ( a!( ) ) ; //~ WARN panic message is not a string literal
37
37
38
+ panic ! ( format!( "{}" , 1 ) ) ; //~ WARN panic message is not a string literal
39
+
38
40
// Check that the lint only triggers for std::panic and core::panic,
39
41
// not any panic macro:
40
42
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
199
199
LL | std::panic::panic_any(a!());
200
200
| ^^^^^^^^^^^^^^^^^^^^^^
201
201
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
203
216
You can’t perform that action at this time.
0 commit comments