Add more assert!() tests for non_fmt_panics.
This commit is contained in:
parent
82d530577b
commit
86bc236a4c
3 changed files with 60 additions and 4 deletions
|
|
@ -65,16 +65,20 @@ fn main() {
|
|||
|
||||
fn a<T: Send + 'static>(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<T: std::fmt::Debug + Send + 'static>(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<T: std::fmt::Display + Send + 'static>(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<T: std::fmt::Display + std::fmt::Debug + Send + 'static>(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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,16 +65,20 @@ fn main() {
|
|||
|
||||
fn a<T: Send + 'static>(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<T: std::fmt::Debug + Send + 'static>(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<T: std::fmt::Display + Send + 'static>(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<T: std::fmt::Display + std::fmt::Debug + Send + 'static>(v: T) {
|
||||
panic!(v); //~ WARN panic message is not a string literal
|
||||
assert!(false, v); //~ WARN panic message is not a string literal
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,7 +323,16 @@ LL | panic!(v);
|
|||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
|
||||
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 <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
|
||||
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 <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
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 <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
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 <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
help: add a "{}" format string to Display the message
|
||||
|
|
||||
LL | assert!(false, "{}", v);
|
||||
| +++++
|
||||
|
||||
warning: 30 warnings emitted
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue