unnecessary_unwrap, panicking_unwrap: make lints adhere to lint message convention

This commit is contained in:
Matthias Krüger 2020-07-23 17:06:29 +02:00
parent 9b7ab1d38b
commit 8679dd375b
4 changed files with 38 additions and 38 deletions

View File

@ -181,8 +181,8 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
self.cx,
UNNECESSARY_UNWRAP,
expr.span,
&format!("You checked before that `{}()` cannot fail. \
Instead of checking and unwrapping, it's better to use `if let` or `match`.",
&format!("you checked before that `{}()` cannot fail. \
Instead of checking and unwrapping, it's better to use `if let` or `match`",
method_name.ident.name),
|diag| { diag.span_label(unwrappable.check.span, "the check is happening here"); },
);
@ -191,7 +191,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
self.cx,
PANICKING_UNWRAP,
expr.span,
&format!("This call to `{}()` will always panic.",
&format!("this call to `{}()` will always panic",
method_name.ident.name),
|diag| { diag.span_label(unwrappable.check.span, "because of this check"); },
);

View File

@ -1,4 +1,4 @@
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/complex_conditionals.rs:8:9
|
LL | if x.is_ok() && y.is_err() {
@ -12,7 +12,7 @@ note: the lint level is defined here
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
error: this call to `unwrap_err()` will always panic
--> $DIR/complex_conditionals.rs:9:9
|
LL | if x.is_ok() && y.is_err() {
@ -27,7 +27,7 @@ note: the lint level is defined here
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: this call to `unwrap()` will always panic
--> $DIR/complex_conditionals.rs:10:9
|
LL | if x.is_ok() && y.is_err() {
@ -36,7 +36,7 @@ LL | if x.is_ok() && y.is_err() {
LL | y.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/complex_conditionals.rs:11:9
|
LL | if x.is_ok() && y.is_err() {
@ -45,7 +45,7 @@ LL | if x.is_ok() && y.is_err() {
LL | y.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: this call to `unwrap()` will always panic
--> $DIR/complex_conditionals.rs:25:9
|
LL | if x.is_ok() || y.is_ok() {
@ -54,7 +54,7 @@ LL | if x.is_ok() || y.is_ok() {
LL | x.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/complex_conditionals.rs:26:9
|
LL | if x.is_ok() || y.is_ok() {
@ -63,7 +63,7 @@ LL | if x.is_ok() || y.is_ok() {
LL | x.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: this call to `unwrap()` will always panic
--> $DIR/complex_conditionals.rs:27:9
|
LL | if x.is_ok() || y.is_ok() {
@ -72,7 +72,7 @@ LL | if x.is_ok() || y.is_ok() {
LL | y.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/complex_conditionals.rs:28:9
|
LL | if x.is_ok() || y.is_ok() {
@ -81,7 +81,7 @@ LL | if x.is_ok() || y.is_ok() {
LL | y.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/complex_conditionals.rs:32:9
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
@ -89,7 +89,7 @@ LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
LL | x.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
error: this call to `unwrap_err()` will always panic
--> $DIR/complex_conditionals.rs:33:9
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
@ -98,7 +98,7 @@ LL | x.unwrap(); // unnecessary
LL | x.unwrap_err(); // will panic
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: this call to `unwrap()` will always panic
--> $DIR/complex_conditionals.rs:34:9
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
@ -107,7 +107,7 @@ LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
LL | y.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/complex_conditionals.rs:35:9
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
@ -116,7 +116,7 @@ LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
LL | y.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/complex_conditionals.rs:36:9
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
@ -125,7 +125,7 @@ LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
LL | z.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
error: this call to `unwrap_err()` will always panic
--> $DIR/complex_conditionals.rs:37:9
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
@ -134,7 +134,7 @@ LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
LL | z.unwrap_err(); // will panic
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: this call to `unwrap()` will always panic
--> $DIR/complex_conditionals.rs:45:9
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
@ -143,7 +143,7 @@ LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
LL | x.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/complex_conditionals.rs:46:9
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
@ -152,7 +152,7 @@ LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
LL | x.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/complex_conditionals.rs:47:9
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
@ -161,7 +161,7 @@ LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
LL | y.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
error: this call to `unwrap_err()` will always panic
--> $DIR/complex_conditionals.rs:48:9
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
@ -170,7 +170,7 @@ LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
LL | y.unwrap_err(); // will panic
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: this call to `unwrap()` will always panic
--> $DIR/complex_conditionals.rs:49:9
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
@ -179,7 +179,7 @@ LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
LL | z.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/complex_conditionals.rs:50:9
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {

View File

@ -1,4 +1,4 @@
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/complex_conditionals_nested.rs:8:13
|
LL | if x.is_some() {
@ -12,7 +12,7 @@ note: the lint level is defined here
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: this call to `unwrap()` will always panic
--> $DIR/complex_conditionals_nested.rs:10:13
|
LL | if x.is_some() {

View File

@ -1,4 +1,4 @@
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/simple_conditionals.rs:39:9
|
LL | if x.is_some() {
@ -12,7 +12,7 @@ note: the lint level is defined here
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: this call to `unwrap()` will always panic
--> $DIR/simple_conditionals.rs:41:9
|
LL | if x.is_some() {
@ -27,7 +27,7 @@ note: the lint level is defined here
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: this call to `unwrap()` will always panic
--> $DIR/simple_conditionals.rs:44:9
|
LL | if x.is_none() {
@ -35,7 +35,7 @@ LL | if x.is_none() {
LL | x.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/simple_conditionals.rs:46:9
|
LL | if x.is_none() {
@ -44,7 +44,7 @@ LL | if x.is_none() {
LL | x.unwrap(); // unnecessary
| ^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/simple_conditionals.rs:7:13
|
LL | if $a.is_some() {
@ -57,7 +57,7 @@ LL | m!(x);
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/simple_conditionals.rs:54:9
|
LL | if x.is_ok() {
@ -65,7 +65,7 @@ LL | if x.is_ok() {
LL | x.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
error: this call to `unwrap_err()` will always panic
--> $DIR/simple_conditionals.rs:55:9
|
LL | if x.is_ok() {
@ -74,7 +74,7 @@ LL | x.unwrap(); // unnecessary
LL | x.unwrap_err(); // will panic
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: this call to `unwrap()` will always panic
--> $DIR/simple_conditionals.rs:57:9
|
LL | if x.is_ok() {
@ -83,7 +83,7 @@ LL | if x.is_ok() {
LL | x.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/simple_conditionals.rs:58:9
|
LL | if x.is_ok() {
@ -92,7 +92,7 @@ LL | if x.is_ok() {
LL | x.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: this call to `unwrap()` will always panic
--> $DIR/simple_conditionals.rs:61:9
|
LL | if x.is_err() {
@ -100,7 +100,7 @@ LL | if x.is_err() {
LL | x.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/simple_conditionals.rs:62:9
|
LL | if x.is_err() {
@ -109,7 +109,7 @@ LL | x.unwrap(); // will panic
LL | x.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: you checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`
--> $DIR/simple_conditionals.rs:64:9
|
LL | if x.is_err() {
@ -118,7 +118,7 @@ LL | if x.is_err() {
LL | x.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
error: this call to `unwrap_err()` will always panic
--> $DIR/simple_conditionals.rs:65:9
|
LL | if x.is_err() {