Skip to content

Commit 00ca4d0

Browse files
committed
Update non_fmt_panics test.
1 parent 0a31325 commit 00ca4d0

File tree

3 files changed

+68
-15
lines changed

3 files changed

+68
-15
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@ fn main() {
1717
//~^ WARN panic message contains unused formatting placeholders
1818
assert!(false, "{}", S);
1919
//~^ WARN panic message is not a string literal
20+
assert!(false, "{}", 123);
21+
//~^ WARN panic message is not a string literal
22+
assert!(false, "{:?}", Some(123));
23+
//~^ WARN panic message is not a string literal
2024
debug_assert!(false, "{}", "{{}} bla"); //~ WARN panic message contains braces
2125
panic!("{}", C); //~ WARN panic message is not a string literal
2226
panic!("{}", S); //~ WARN panic message is not a string literal
2327
std::panic::panic_any(123); //~ WARN panic message is not a string literal
2428
core::panic!("{}", &*"abc"); //~ WARN panic message is not a string literal
29+
std::panic::panic_any(Some(123)); //~ WARN panic message is not a string literal
2530
panic!("{}", concat!("{", "}")); //~ WARN panic message contains an unused formatting placeholder
2631
panic!("{}", concat!("{", "{")); //~ WARN panic message contains braces
2732

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@ fn main() {
1717
//~^ WARN panic message contains unused formatting placeholders
1818
assert!(false, S);
1919
//~^ WARN panic message is not a string literal
20+
assert!(false, 123);
21+
//~^ WARN panic message is not a string literal
22+
assert!(false, Some(123));
23+
//~^ WARN panic message is not a string literal
2024
debug_assert!(false, "{{}} bla"); //~ WARN panic message contains braces
2125
panic!(C); //~ WARN panic message is not a string literal
2226
panic!(S); //~ WARN panic message is not a string literal
2327
std::panic!(123); //~ WARN panic message is not a string literal
2428
core::panic!(&*"abc"); //~ WARN panic message is not a string literal
29+
panic!(Some(123)); //~ WARN panic message is not a string literal
2530
panic!(concat!("{", "}")); //~ WARN panic message contains an unused formatting placeholder
2631
panic!(concat!("{", "{")); //~ WARN panic message contains braces
2732

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

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,34 @@ help: add a "{}" format string to Display the message
6868
LL | assert!(false, "{}", S);
6969
| +++++
7070

71+
warning: panic message is not a string literal
72+
--> $DIR/non-fmt-panic.rs:20:20
73+
|
74+
LL | assert!(false, 123);
75+
| ^^^
76+
|
77+
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
78+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
79+
help: add a "{}" format string to Display the message
80+
|
81+
LL | assert!(false, "{}", 123);
82+
| +++++
83+
84+
warning: panic message is not a string literal
85+
--> $DIR/non-fmt-panic.rs:22:20
86+
|
87+
LL | assert!(false, Some(123));
88+
| ^^^^^^^^^
89+
|
90+
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
91+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
92+
help: add a "{:?}" format string to use the Debug implementation of `Option<i32>`
93+
|
94+
LL | assert!(false, "{:?}", Some(123));
95+
| +++++++
96+
7197
warning: panic message contains braces
72-
--> $DIR/non-fmt-panic.rs:20:27
98+
--> $DIR/non-fmt-panic.rs:24:27
7399
|
74100
LL | debug_assert!(false, "{{}} bla");
75101
| ^^^^
@@ -81,7 +107,7 @@ LL | debug_assert!(false, "{}", "{{}} bla");
81107
| +++++
82108

83109
warning: panic message is not a string literal
84-
--> $DIR/non-fmt-panic.rs:21:12
110+
--> $DIR/non-fmt-panic.rs:25:12
85111
|
86112
LL | panic!(C);
87113
| ^
@@ -94,7 +120,7 @@ LL | panic!("{}", C);
94120
| +++++
95121

96122
warning: panic message is not a string literal
97-
--> $DIR/non-fmt-panic.rs:22:12
123+
--> $DIR/non-fmt-panic.rs:26:12
98124
|
99125
LL | panic!(S);
100126
| ^
@@ -107,7 +133,7 @@ LL | panic!("{}", S);
107133
| +++++
108134

109135
warning: panic message is not a string literal
110-
--> $DIR/non-fmt-panic.rs:23:17
136+
--> $DIR/non-fmt-panic.rs:27:17
111137
|
112138
LL | std::panic!(123);
113139
| ^^^
@@ -124,7 +150,7 @@ LL | std::panic::panic_any(123);
124150
| ~~~~~~~~~~~~~~~~~~~~~
125151

126152
warning: panic message is not a string literal
127-
--> $DIR/non-fmt-panic.rs:24:18
153+
--> $DIR/non-fmt-panic.rs:28:18
128154
|
129155
LL | core::panic!(&*"abc");
130156
| ^^^^^^^
@@ -136,8 +162,25 @@ help: add a "{}" format string to Display the message
136162
LL | core::panic!("{}", &*"abc");
137163
| +++++
138164

165+
warning: panic message is not a string literal
166+
--> $DIR/non-fmt-panic.rs:29:12
167+
|
168+
LL | panic!(Some(123));
169+
| ^^^^^^^^^
170+
|
171+
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
172+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
173+
help: add a "{:?}" format string to use the Debug implementation of `Option<i32>`
174+
|
175+
LL | panic!("{:?}", Some(123));
176+
| +++++++
177+
help: or use std::panic::panic_any instead
178+
|
179+
LL | std::panic::panic_any(Some(123));
180+
| ~~~~~~~~~~~~~~~~~~~~~
181+
139182
warning: panic message contains an unused formatting placeholder
140-
--> $DIR/non-fmt-panic.rs:25:12
183+
--> $DIR/non-fmt-panic.rs:30:12
141184
|
142185
LL | panic!(concat!("{", "}"));
143186
| ^^^^^^^^^^^^^^^^^
@@ -153,7 +196,7 @@ LL | panic!("{}", concat!("{", "}"));
153196
| +++++
154197

155198
warning: panic message contains braces
156-
--> $DIR/non-fmt-panic.rs:26:5
199+
--> $DIR/non-fmt-panic.rs:31:5
157200
|
158201
LL | panic!(concat!("{", "{"));
159202
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -165,15 +208,15 @@ LL | panic!("{}", concat!("{", "{"));
165208
| +++++
166209

167210
warning: panic message contains an unused formatting placeholder
168-
--> $DIR/non-fmt-panic.rs:28:37
211+
--> $DIR/non-fmt-panic.rs:33:37
169212
|
170213
LL | fancy_panic::fancy_panic!("test {} 123");
171214
| ^^
172215
|
173216
= note: this message is not used as a format string when given without arguments, but will be in Rust 2021
174217

175218
warning: panic message is not a string literal
176-
--> $DIR/non-fmt-panic.rs:38:12
219+
--> $DIR/non-fmt-panic.rs:43:12
177220
|
178221
LL | panic!(a!());
179222
| ^^^^
@@ -190,7 +233,7 @@ LL | std::panic::panic_any(a!());
190233
| ~~~~~~~~~~~~~~~~~~~~~
191234

192235
warning: panic message is not a string literal
193-
--> $DIR/non-fmt-panic.rs:40:12
236+
--> $DIR/non-fmt-panic.rs:45:12
194237
|
195238
LL | panic!(format!("{}", 1));
196239
| ^^^^^^^^^^^^^^^^
@@ -205,7 +248,7 @@ LL + panic!("{}", 1);
205248
|
206249

207250
warning: panic message is not a string literal
208-
--> $DIR/non-fmt-panic.rs:41:20
251+
--> $DIR/non-fmt-panic.rs:46:20
209252
|
210253
LL | assert!(false, format!("{}", 1));
211254
| ^^^^^^^^^^^^^^^^
@@ -220,7 +263,7 @@ LL + assert!(false, "{}", 1);
220263
|
221264

222265
warning: panic message is not a string literal
223-
--> $DIR/non-fmt-panic.rs:42:26
266+
--> $DIR/non-fmt-panic.rs:47:26
224267
|
225268
LL | debug_assert!(false, format!("{}", 1));
226269
| ^^^^^^^^^^^^^^^^
@@ -235,7 +278,7 @@ LL + debug_assert!(false, "{}", 1);
235278
|
236279

237280
warning: panic message is not a string literal
238-
--> $DIR/non-fmt-panic.rs:44:12
281+
--> $DIR/non-fmt-panic.rs:49:12
239282
|
240283
LL | panic![123];
241284
| ^^^
@@ -252,7 +295,7 @@ LL | std::panic::panic_any(123);
252295
| ~~~~~~~~~~~~~~~~~~~~~~ ~
253296

254297
warning: panic message is not a string literal
255-
--> $DIR/non-fmt-panic.rs:45:12
298+
--> $DIR/non-fmt-panic.rs:50:12
256299
|
257300
LL | panic!{123};
258301
| ^^^
@@ -268,5 +311,5 @@ help: or use std::panic::panic_any instead
268311
LL | std::panic::panic_any(123);
269312
| ~~~~~~~~~~~~~~~~~~~~~~ ~
270313

271-
warning: 19 warnings emitted
314+
warning: 22 warnings emitted
272315

0 commit comments

Comments
 (0)