about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-02-14 18:53:10 +0100
committerMara Bos <m-ou.se@m-ou.se>2021-02-14 18:53:10 +0100
commit9f97a0b364bcbb261f05d6ac62436b6802bfa80b (patch)
tree76a54dbc0445c8d246f62d2a227559faac9ac5d8
parenta428ab17abc310c17ca13eeb6f74b3c5bddff940 (diff)
downloadrust-9f97a0b364bcbb261f05d6ac62436b6802bfa80b.tar.gz
rust-9f97a0b364bcbb261f05d6ac62436b6802bfa80b.zip
Add test for panic!(format!(..)) lint.
-rw-r--r--src/test/ui/non-fmt-panic.rs2
-rw-r--r--src/test/ui/non-fmt-panic.stderr15
2 files changed, 16 insertions, 1 deletions
diff --git a/src/test/ui/non-fmt-panic.rs b/src/test/ui/non-fmt-panic.rs
index ff9e3b497f2..c20df5ffd10 100644
--- a/src/test/ui/non-fmt-panic.rs
+++ b/src/test/ui/non-fmt-panic.rs
@@ -35,6 +35,8 @@ fn main() {
 
     panic!(a!()); //~ WARN panic message is not a string literal
 
+    panic!(format!("{}", 1)); //~ WARN panic message is not a string literal
+
     // Check that the lint only triggers for std::panic and core::panic,
     // not any panic macro:
     macro_rules! panic {
diff --git a/src/test/ui/non-fmt-panic.stderr b/src/test/ui/non-fmt-panic.stderr
index 2f33f04cb19..043c4b0f750 100644
--- a/src/test/ui/non-fmt-panic.stderr
+++ b/src/test/ui/non-fmt-panic.stderr
@@ -199,5 +199,18 @@ help: or use std::panic::panic_any instead
 LL |     std::panic::panic_any(a!());
    |     ^^^^^^^^^^^^^^^^^^^^^^
 
-warning: 15 warnings emitted
+warning: panic message is not a string literal
+  --> $DIR/non-fmt-panic.rs:38:12
+   |
+LL |     panic!(format!("{}", 1));
+   |            ^^^^^^^^^^^^^^^^
+   |
+   = note: this is no longer accepted in Rust 2021
+   = note: the panic!() macro supports formatting, so there's no need for the format!() macro here
+help: remove the `format!(..)` macro call
+   |
+LL |     panic!("{}", 1);
+   |           --     --
+
+warning: 16 warnings emitted