Skip to content

Commit 14dcf0a

Browse files
committed
Test for formating placeholders in panic_fmt lint test.
1 parent b8a8b68 commit 14dcf0a

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/test/ui/panic-brace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
fn main() {
55
panic!("here's a brace: {"); //~ WARN Panic message contains a brace
66
std::panic!("another one: }"); //~ WARN Panic message contains a brace
7-
core::panic!("Hello { { {"); //~ WARN Panic message contains a brace
8-
assert!(false, "} } }..."); //~ WARN Panic message contains a brace
7+
core::panic!("Hello {}"); //~ WARN Panic message contains an unused formatting placeholder
8+
assert!(false, "{:03x} bla"); //~ WARN Panic message contains an unused formatting placeholder
99
}

src/test/ui/panic-brace.stderr

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,36 @@ help: add a "{}" format string to use the message literally
2323
LL | std::panic!("{}", "another one: }");
2424
| ^^^^^
2525

26-
warning: Panic message contains a brace
27-
--> $DIR/panic-brace.rs:7:5
26+
warning: Panic message contains an unused formatting placeholder
27+
--> $DIR/panic-brace.rs:7:18
2828
|
29-
LL | core::panic!("Hello { { {");
30-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29+
LL | core::panic!("Hello {}");
30+
| ^^^^^^^^^^
3131
|
32-
= note: This message is not used as a format string, but will be in a future Rust version
33-
help: add a "{}" format string to use the message literally
32+
= note: This message is not used as a format string when given without arguments, but will be in a future Rust version
33+
help: add the missing argument(s)
34+
|
35+
LL | core::panic!("Hello {}", argument);
36+
| ^^^^^^^^^^
37+
help: or add a "{}" format string to use the message literally
3438
|
35-
LL | core::panic!("{}", "Hello { { {");
39+
LL | core::panic!("{}", "Hello {}");
3640
| ^^^^^
3741

38-
warning: Panic message contains a brace
39-
--> $DIR/panic-brace.rs:8:5
42+
warning: Panic message contains an unused formatting placeholder
43+
--> $DIR/panic-brace.rs:8:20
4044
|
41-
LL | assert!(false, "} } }...");
42-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
45+
LL | assert!(false, "{:03x} bla");
46+
| ^^^^^^^^^^^^
4347
|
44-
= note: This message is not used as a format string, but will be in a future Rust version
45-
help: add a "{}" format string to use the message literally
48+
= note: This message is not used as a format string when given without arguments, but will be in a future Rust version
49+
help: add the missing argument(s)
50+
|
51+
LL | assert!(false, "{:03x} bla", argument);
52+
| ^^^^^^^^^^
53+
help: or add a "{}" format string to use the message literally
4654
|
47-
LL | assert!(false, "{}", "} } }...");
55+
LL | assert!(false, "{}", "{:03x} bla");
4856
| ^^^^^
4957

5058
warning: 4 warnings emitted

0 commit comments

Comments
 (0)