mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
38d4ac7cea
Discussion previously happened in https://github.com/rust-lang/rust/pull/43498
313 lines
10 KiB
Text
313 lines
10 KiB
Text
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
|
|
--> $DIR/checked_unwrap.rs:7:9
|
|
|
|
|
LL | if x.is_some() {
|
|
| ----------- the check is happening here
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
|
note: lint level defined here
|
|
--> $DIR/checked_unwrap.rs:1:35
|
|
|
|
|
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:9:9
|
|
|
|
|
LL | if x.is_some() {
|
|
| ----------- because of this check
|
|
...
|
|
LL | x.unwrap(); // will panic
|
|
| ^^^^^^^^^^
|
|
|
|
|
note: lint level defined here
|
|
--> $DIR/checked_unwrap.rs:1:9
|
|
|
|
|
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:12:9
|
|
|
|
|
LL | if x.is_none() {
|
|
| ----------- because of this check
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:14:9
|
|
|
|
|
LL | if x.is_none() {
|
|
| ----------- the check is happening here
|
|
...
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:18:9
|
|
|
|
|
LL | if x.is_ok() {
|
|
| --------- the check is happening here
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
error: This call to `unwrap_err()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:19:9
|
|
|
|
|
LL | if x.is_ok() {
|
|
| --------- because of this check
|
|
LL | x.unwrap(); // unnecessary
|
|
LL | x.unwrap_err(); // will panic
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:21:9
|
|
|
|
|
LL | if x.is_ok() {
|
|
| --------- because of this check
|
|
...
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:22:9
|
|
|
|
|
LL | if x.is_ok() {
|
|
| --------- the check is happening here
|
|
...
|
|
LL | x.unwrap_err(); // unnecessary
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:25:9
|
|
|
|
|
LL | if x.is_err() {
|
|
| ---------- because of this check
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:26:9
|
|
|
|
|
LL | if x.is_err() {
|
|
| ---------- the check is happening here
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:28:9
|
|
|
|
|
LL | if x.is_err() {
|
|
| ---------- the check is happening here
|
|
...
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
error: This call to `unwrap_err()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:29:9
|
|
|
|
|
LL | if x.is_err() {
|
|
| ---------- because of this check
|
|
...
|
|
LL | x.unwrap_err(); // will panic
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
|
|
--> $DIR/checked_unwrap.rs:46:9
|
|
|
|
|
LL | if x.is_ok() && y.is_err() {
|
|
| --------- the check is happening here
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
error: This call to `unwrap_err()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:47:9
|
|
|
|
|
LL | if x.is_ok() && y.is_err() {
|
|
| --------- because of this check
|
|
LL | x.unwrap(); // unnecessary
|
|
LL | x.unwrap_err(); // will panic
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:48:9
|
|
|
|
|
LL | if x.is_ok() && y.is_err() {
|
|
| ---------- because of this check
|
|
...
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:49:9
|
|
|
|
|
LL | if x.is_ok() && y.is_err() {
|
|
| ---------- the check is happening here
|
|
...
|
|
LL | y.unwrap_err(); // unnecessary
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:63:9
|
|
|
|
|
LL | if x.is_ok() || y.is_ok() {
|
|
| --------- because of this check
|
|
...
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:64:9
|
|
|
|
|
LL | if x.is_ok() || y.is_ok() {
|
|
| --------- the check is happening here
|
|
...
|
|
LL | x.unwrap_err(); // unnecessary
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:65:9
|
|
|
|
|
LL | if x.is_ok() || y.is_ok() {
|
|
| --------- because of this check
|
|
...
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:66:9
|
|
|
|
|
LL | if x.is_ok() || y.is_ok() {
|
|
| --------- the check is happening here
|
|
...
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:70:9
|
|
|
|
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
|
|
| --------- the check is happening here
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
error: This call to `unwrap_err()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:71:9
|
|
|
|
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
|
|
| --------- because of this check
|
|
LL | x.unwrap(); // unnecessary
|
|
LL | x.unwrap_err(); // will panic
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:72:9
|
|
|
|
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
|
|
| --------- because of this check
|
|
...
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:73:9
|
|
|
|
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
|
|
| --------- the check is happening here
|
|
...
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:74:9
|
|
|
|
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
|
|
| ---------- the check is happening here
|
|
...
|
|
LL | z.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
error: This call to `unwrap_err()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:75:9
|
|
|
|
|
LL | if x.is_ok() && !(y.is_ok() || z.is_err()) {
|
|
| ---------- because of this check
|
|
...
|
|
LL | z.unwrap_err(); // will panic
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:83:9
|
|
|
|
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
|
|
| --------- because of this check
|
|
...
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:84:9
|
|
|
|
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
|
|
| --------- the check is happening here
|
|
...
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:85:9
|
|
|
|
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
|
|
| --------- the check is happening here
|
|
...
|
|
LL | y.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
error: This call to `unwrap_err()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:86:9
|
|
|
|
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
|
|
| --------- because of this check
|
|
...
|
|
LL | y.unwrap_err(); // will panic
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:87:9
|
|
|
|
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
|
|
| ---------- because of this check
|
|
...
|
|
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`.
|
|
--> $DIR/checked_unwrap.rs:88:9
|
|
|
|
|
LL | if x.is_ok() || !(y.is_ok() && z.is_err()) {
|
|
| ---------- the check is happening here
|
|
...
|
|
LL | z.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`.
|
|
--> $DIR/checked_unwrap.rs:96:13
|
|
|
|
|
LL | if x.is_some() {
|
|
| ----------- the check is happening here
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/checked_unwrap.rs:98:13
|
|
|
|
|
LL | if x.is_some() {
|
|
| ----------- because of this check
|
|
...
|
|
LL | x.unwrap(); // will panic
|
|
| ^^^^^^^^^^
|
|
|
|
error: aborting due to 34 previous errors
|
|
|