mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-22 19:13:29 +00:00
48bff49484
This splits up `tests/ui/checked_unwrap.rs` into: * `tests/ui/checked_unwrap/complex.rs` * `tests/ui/checked_unwrap/simple.rs` Based on the naming of the methods in the tests. cc #2038
209 lines
7.2 KiB
Text
209 lines
7.2 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/complex_conditionals.rs:8:9
|
|
|
|
|
LL | if x.is_ok() && y.is_err() {
|
|
| --------- the check is happening here
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
|
note: lint level defined here
|
|
--> $DIR/complex_conditionals.rs:1:35
|
|
|
|
|
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap_err()` will always panic.
|
|
--> $DIR/complex_conditionals.rs:9:9
|
|
|
|
|
LL | if x.is_ok() && y.is_err() {
|
|
| --------- because of this check
|
|
LL | x.unwrap(); // unnecessary
|
|
LL | x.unwrap_err(); // will panic
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
note: lint level defined here
|
|
--> $DIR/complex_conditionals.rs:1:9
|
|
|
|
|
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/complex_conditionals.rs:10: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/complex_conditionals.rs:11: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/complex_conditionals.rs:25: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/complex_conditionals.rs:26: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/complex_conditionals.rs:27: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/complex_conditionals.rs:28: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/complex_conditionals.rs:32: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/complex_conditionals.rs:33: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/complex_conditionals.rs:34: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/complex_conditionals.rs:35: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/complex_conditionals.rs:36: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/complex_conditionals.rs:37: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/complex_conditionals.rs:45: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/complex_conditionals.rs:46: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/complex_conditionals.rs:47: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/complex_conditionals.rs:48: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/complex_conditionals.rs:49: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/complex_conditionals.rs:50: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/complex_conditionals.rs:58:13
|
|
|
|
|
LL | if x.is_some() {
|
|
| ----------- the check is happening here
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
error: This call to `unwrap()` will always panic.
|
|
--> $DIR/complex_conditionals.rs:60:13
|
|
|
|
|
LL | if x.is_some() {
|
|
| ----------- because of this check
|
|
...
|
|
LL | x.unwrap(); // will panic
|
|
| ^^^^^^^^^^
|
|
|
|
error: aborting due to 22 previous errors
|
|
|