From 86bc236a4cf2a786b8eef43439729cd2a8a61b1f Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 16 Aug 2021 17:35:49 +0200 Subject: [PATCH] Add more assert!() tests for non_fmt_panics. --- src/test/ui/non-fmt-panic.fixed | 4 +++ src/test/ui/non-fmt-panic.rs | 4 +++ src/test/ui/non-fmt-panic.stderr | 56 +++++++++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/test/ui/non-fmt-panic.fixed b/src/test/ui/non-fmt-panic.fixed index 0f55f1ae817b1..d226f4129aa82 100644 --- a/src/test/ui/non-fmt-panic.fixed +++ b/src/test/ui/non-fmt-panic.fixed @@ -65,16 +65,20 @@ fn main() { fn a(v: T) { std::panic::panic_any(v); //~ WARN panic message is not a string literal + assert!(false, v); //~ WARN panic message is not a string literal } fn b(v: T) { std::panic::panic_any(v); //~ WARN panic message is not a string literal + assert!(false, "{:?}", v); //~ WARN panic message is not a string literal } fn c(v: T) { std::panic::panic_any(v); //~ WARN panic message is not a string literal + assert!(false, "{}", v); //~ WARN panic message is not a string literal } fn d(v: T) { std::panic::panic_any(v); //~ WARN panic message is not a string literal + assert!(false, "{}", v); //~ WARN panic message is not a string literal } diff --git a/src/test/ui/non-fmt-panic.rs b/src/test/ui/non-fmt-panic.rs index 6e9bdb21f0c36..2ffd7638ae0a0 100644 --- a/src/test/ui/non-fmt-panic.rs +++ b/src/test/ui/non-fmt-panic.rs @@ -65,16 +65,20 @@ fn main() { fn a(v: T) { panic!(v); //~ WARN panic message is not a string literal + assert!(false, v); //~ WARN panic message is not a string literal } fn b(v: T) { panic!(v); //~ WARN panic message is not a string literal + assert!(false, v); //~ WARN panic message is not a string literal } fn c(v: T) { panic!(v); //~ WARN panic message is not a string literal + assert!(false, v); //~ WARN panic message is not a string literal } fn d(v: T) { panic!(v); //~ WARN panic message is not a string literal + assert!(false, v); //~ WARN panic message is not a string literal } diff --git a/src/test/ui/non-fmt-panic.stderr b/src/test/ui/non-fmt-panic.stderr index 1d3346d7756e6..7b5e0ee324b39 100644 --- a/src/test/ui/non-fmt-panic.stderr +++ b/src/test/ui/non-fmt-panic.stderr @@ -323,7 +323,16 @@ LL | panic!(v); = note: for more information, see warning: panic message is not a string literal - --> $DIR/non-fmt-panic.rs:71:12 + --> $DIR/non-fmt-panic.rs:68:20 + | +LL | assert!(false, v); + | ^ + | + = note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see + +warning: panic message is not a string literal + --> $DIR/non-fmt-panic.rs:72:12 | LL | panic!(v); | ^ @@ -340,7 +349,20 @@ LL | std::panic::panic_any(v); | ~~~~~~~~~~~~~~~~~~~~~ warning: panic message is not a string literal - --> $DIR/non-fmt-panic.rs:75:12 + --> $DIR/non-fmt-panic.rs:73:20 + | +LL | assert!(false, v); + | ^ + | + = note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see +help: add a "{:?}" format string to use the Debug implementation of `T` + | +LL | assert!(false, "{:?}", v); + | +++++++ + +warning: panic message is not a string literal + --> $DIR/non-fmt-panic.rs:77:12 | LL | panic!(v); | ^ @@ -357,7 +379,20 @@ LL | std::panic::panic_any(v); | ~~~~~~~~~~~~~~~~~~~~~ warning: panic message is not a string literal - --> $DIR/non-fmt-panic.rs:79:12 + --> $DIR/non-fmt-panic.rs:78:20 + | +LL | assert!(false, v); + | ^ + | + = note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see +help: add a "{}" format string to Display the message + | +LL | assert!(false, "{}", v); + | +++++ + +warning: panic message is not a string literal + --> $DIR/non-fmt-panic.rs:82:12 | LL | panic!(v); | ^ @@ -373,5 +408,18 @@ help: or use std::panic::panic_any instead LL | std::panic::panic_any(v); | ~~~~~~~~~~~~~~~~~~~~~ -warning: 26 warnings emitted +warning: panic message is not a string literal + --> $DIR/non-fmt-panic.rs:83:20 + | +LL | assert!(false, v); + | ^ + | + = note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see +help: add a "{}" format string to Display the message + | +LL | assert!(false, "{}", v); + | +++++ + +warning: 30 warnings emitted