File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ fn main() {
3737
3838 panic ! ( format!( "{}" , 1 ) ) ; //~ WARN panic message is not a string literal
3939
40+ panic ! [ 123 ] ; //~ WARN panic message is not a string literal
41+ panic ! { 123 } ; //~ WARN panic message is not a string literal
42+
4043 // Check that the lint only triggers for std::panic and core::panic,
4144 // not any panic macro:
4245 macro_rules! panic {
Original file line number Diff line number Diff line change @@ -212,5 +212,37 @@ help: remove the `format!(..)` macro call
212212LL | panic!("{}", 1);
213213 | -- --
214214
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
216248
You can’t perform that action at this time.
0 commit comments