mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
131 lines
4.3 KiB
Text
131 lines
4.3 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/simple_conditionals.rs:15:9
|
|
|
|
|
LL | if x.is_some() {
|
|
| ----------- the check is happening here
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
|
note: the lint level is defined here
|
|
--> $DIR/simple_conditionals.rs:1:35
|
|
|
|
|
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/simple_conditionals.rs:17:9
|
|
|
|
|
LL | if x.is_some() {
|
|
| ----------- because of this check
|
|
...
|
|
LL | x.unwrap(); // will panic
|
|
| ^^^^^^^^^^
|
|
|
|
|
note: the lint level is defined here
|
|
--> $DIR/simple_conditionals.rs:1:9
|
|
|
|
|
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/simple_conditionals.rs:20: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/simple_conditionals.rs:22: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/simple_conditionals.rs:7:13
|
|
|
|
|
LL | if $a.is_some() {
|
|
| ------------ the check is happening here
|
|
LL | $a.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^^
|
|
...
|
|
LL | m!(x);
|
|
| ------ in this macro invocation
|
|
|
|
|
= 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`.
|
|
--> $DIR/simple_conditionals.rs:27: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/simple_conditionals.rs:28: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/simple_conditionals.rs:30: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/simple_conditionals.rs:31: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/simple_conditionals.rs:34: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/simple_conditionals.rs:35: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/simple_conditionals.rs:37: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/simple_conditionals.rs:38:9
|
|
|
|
|
LL | if x.is_err() {
|
|
| ---------- because of this check
|
|
...
|
|
LL | x.unwrap_err(); // will panic
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: aborting due to 13 previous errors
|
|
|