about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2020-10-18 23:36:00 +0200
committerMara Bos <m-ou.se@m-ou.se>2020-10-18 23:36:00 +0200
commit14dcf0a8ac632e6073ec979da72e286a57c50f4c (patch)
tree14574739a3d1e032acdee8012ad85e9c10044c0e
parentb8a8b681b8ca37771a0116d7cc7c3e4e7c749e0e (diff)
downloadrust-14dcf0a8ac632e6073ec979da72e286a57c50f4c.tar.gz
rust-14dcf0a8ac632e6073ec979da72e286a57c50f4c.zip
Test for formating placeholders in panic_fmt lint test.
-rw-r--r--src/test/ui/panic-brace.rs4
-rw-r--r--src/test/ui/panic-brace.stderr36
2 files changed, 24 insertions, 16 deletions
diff --git a/src/test/ui/panic-brace.rs b/src/test/ui/panic-brace.rs
index 744ecb30037..01ffb800768 100644
--- a/src/test/ui/panic-brace.rs
+++ b/src/test/ui/panic-brace.rs
@@ -4,6 +4,6 @@
 fn main() {
     panic!("here's a brace: {"); //~ WARN Panic message contains a brace
     std::panic!("another one: }"); //~ WARN Panic message contains a brace
-    core::panic!("Hello { { {"); //~ WARN Panic message contains a brace
-    assert!(false, "} } }..."); //~ WARN Panic message contains a brace
+    core::panic!("Hello {}"); //~ WARN Panic message contains an unused formatting placeholder
+    assert!(false, "{:03x} bla"); //~ WARN Panic message contains an unused formatting placeholder
 }
diff --git a/src/test/ui/panic-brace.stderr b/src/test/ui/panic-brace.stderr
index c54044cb6c8..b91ce8f603a 100644
--- a/src/test/ui/panic-brace.stderr
+++ b/src/test/ui/panic-brace.stderr
@@ -23,28 +23,36 @@ help: add a "{}" format string to use the message literally
 LL |     std::panic!("{}", "another one: }");
    |                 ^^^^^
 
-warning: Panic message contains a brace
-  --> $DIR/panic-brace.rs:7:5
+warning: Panic message contains an unused formatting placeholder
+  --> $DIR/panic-brace.rs:7:18
    |
-LL |     core::panic!("Hello { { {");
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     core::panic!("Hello {}");
+   |                  ^^^^^^^^^^
    |
-   = note: This message is not used as a format string, but will be in a future Rust version
-help: add a "{}" format string to use the message literally
+   = note: This message is not used as a format string when given without arguments, but will be in a future Rust version
+help: add the missing argument(s)
+   |
+LL |     core::panic!("Hello {}", argument);
+   |                            ^^^^^^^^^^
+help: or add a "{}" format string to use the message literally
    |
-LL |     core::panic!("{}", "Hello { { {");
+LL |     core::panic!("{}", "Hello {}");
    |                  ^^^^^
 
-warning: Panic message contains a brace
-  --> $DIR/panic-brace.rs:8:5
+warning: Panic message contains an unused formatting placeholder
+  --> $DIR/panic-brace.rs:8:20
    |
-LL |     assert!(false, "} } }...");
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     assert!(false, "{:03x} bla");
+   |                    ^^^^^^^^^^^^
    |
-   = note: This message is not used as a format string, but will be in a future Rust version
-help: add a "{}" format string to use the message literally
+   = note: This message is not used as a format string when given without arguments, but will be in a future Rust version
+help: add the missing argument(s)
+   |
+LL |     assert!(false, "{:03x} bla", argument);
+   |                                ^^^^^^^^^^
+help: or add a "{}" format string to use the message literally
    |
-LL |     assert!(false, "{}", "} } }...");
+LL |     assert!(false, "{}", "{:03x} bla");
    |                    ^^^^^
 
 warning: 4 warnings emitted