File tree 2 files changed +36
-1
lines changed
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ fn main() {
37
37
38
38
panic ! ( format!( "{}" , 1 ) ) ; //~ WARN panic message is not a string literal
39
39
40
+ panic ! [ 123 ] ; //~ WARN panic message is not a string literal
41
+ panic ! { 123 } ; //~ WARN panic message is not a string literal
42
+
40
43
// Check that the lint only triggers for std::panic and core::panic,
41
44
// not any panic macro:
42
45
macro_rules! panic {
Original file line number Diff line number Diff line change @@ -212,5 +212,37 @@ help: remove the `format!(..)` macro call
212
212
LL | panic!("{}", 1);
213
213
| -- --
214
214
215
- warning: 16 warnings emitted
215
+ warning: panic message is not a string literal
216
+ --> $DIR/non-fmt-panic.rs:40:12
217
+ |
218
+ LL | panic![123];
219
+ | ^^^
220
+ |
221
+ = note: this is no longer accepted in Rust 2021
222
+ help: add a "{}" format string to Display the message
223
+ |
224
+ LL | panic!["{}", 123];
225
+ | ^^^^^
226
+ help: or use std::panic::panic_any instead
227
+ |
228
+ LL | std::panic::panic_any(123);
229
+ | ^^^^^^^^^^^^^^^^^^^^^^ ^
230
+
231
+ warning: panic message is not a string literal
232
+ --> $DIR/non-fmt-panic.rs:41:12
233
+ |
234
+ LL | panic!{123};
235
+ | ^^^
236
+ |
237
+ = note: this is no longer accepted in Rust 2021
238
+ help: add a "{}" format string to Display the message
239
+ |
240
+ LL | panic!{"{}", 123};
241
+ | ^^^^^
242
+ help: or use std::panic::panic_any instead
243
+ |
244
+ LL | std::panic::panic_any(123);
245
+ | ^^^^^^^^^^^^^^^^^^^^^^ ^
246
+
247
+ warning: 18 warnings emitted
216
248
You can’t perform that action at this time.
0 commit comments