Skip to content

Commit 8ad12bb

Browse files
committed
Add ui tests for panic![123] and panic!{123}.
1 parent 37c532c commit 8ad12bb

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/test/ui/non-fmt-panic.rs

+3
Original file line numberDiff line numberDiff 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 {

src/test/ui/non-fmt-panic.stderr

+33-1
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,37 @@ help: remove the `format!(..)` macro call
212212
LL | 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

0 commit comments

Comments
 (0)