mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 16:39:26 +00:00
167 lines
5 KiB
Text
167 lines
5 KiB
Text
error: called `unwrap` on `x` after checking its variant with `is_some`
|
|
--> $DIR/simple_conditionals.rs:40:9
|
|
|
|
|
LL | if x.is_some() {
|
|
| -------------- help: try: `if let Some(..) = x`
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
|
note: the lint level is defined here
|
|
--> $DIR/simple_conditionals.rs:2:35
|
|
|
|
|
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: called `expect` on `x` after checking its variant with `is_some`
|
|
--> $DIR/simple_conditionals.rs:41:9
|
|
|
|
|
LL | if x.is_some() {
|
|
| -------------- help: try: `if let Some(..) = x`
|
|
LL | x.unwrap(); // unnecessary
|
|
LL | x.expect("an error message"); // unnecessary
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: this call to `unwrap()` will always panic
|
|
--> $DIR/simple_conditionals.rs:43: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:2:9
|
|
|
|
|
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: this call to `expect()` will always panic
|
|
--> $DIR/simple_conditionals.rs:44:9
|
|
|
|
|
LL | if x.is_some() {
|
|
| ----------- because of this check
|
|
...
|
|
LL | x.expect("an error message"); // will panic
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: this call to `unwrap()` will always panic
|
|
--> $DIR/simple_conditionals.rs:47:9
|
|
|
|
|
LL | if x.is_none() {
|
|
| ----------- because of this check
|
|
LL | x.unwrap(); // will panic
|
|
| ^^^^^^^^^^
|
|
|
|
error: called `unwrap` on `x` after checking its variant with `is_none`
|
|
--> $DIR/simple_conditionals.rs:49:9
|
|
|
|
|
LL | if x.is_none() {
|
|
| -------------- help: try: `if let Some(..) = x`
|
|
...
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
error: called `unwrap` on `x` after checking its variant with `is_some`
|
|
--> $DIR/simple_conditionals.rs:8:13
|
|
|
|
|
LL | if $a.is_some() {
|
|
| --------------- help: try: `if let Some(..) = x`
|
|
LL | $a.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^^
|
|
...
|
|
LL | m!(x);
|
|
| ----- in this macro invocation
|
|
|
|
|
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error: called `unwrap` on `x` after checking its variant with `is_ok`
|
|
--> $DIR/simple_conditionals.rs:57:9
|
|
|
|
|
LL | if x.is_ok() {
|
|
| ------------ help: try: `if let Ok(..) = x`
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
error: called `expect` on `x` after checking its variant with `is_ok`
|
|
--> $DIR/simple_conditionals.rs:58:9
|
|
|
|
|
LL | if x.is_ok() {
|
|
| ------------ help: try: `if let Ok(..) = x`
|
|
LL | x.unwrap(); // unnecessary
|
|
LL | x.expect("an error message"); // unnecessary
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: this call to `unwrap_err()` will always panic
|
|
--> $DIR/simple_conditionals.rs:59:9
|
|
|
|
|
LL | if x.is_ok() {
|
|
| --------- because of this check
|
|
...
|
|
LL | x.unwrap_err(); // will panic
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: this call to `unwrap()` will always panic
|
|
--> $DIR/simple_conditionals.rs:61:9
|
|
|
|
|
LL | if x.is_ok() {
|
|
| --------- because of this check
|
|
...
|
|
LL | x.unwrap(); // will panic
|
|
| ^^^^^^^^^^
|
|
|
|
error: this call to `expect()` will always panic
|
|
--> $DIR/simple_conditionals.rs:62:9
|
|
|
|
|
LL | if x.is_ok() {
|
|
| --------- because of this check
|
|
...
|
|
LL | x.expect("an error message"); // will panic
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: called `unwrap_err` on `x` after checking its variant with `is_ok`
|
|
--> $DIR/simple_conditionals.rs:63:9
|
|
|
|
|
LL | if x.is_ok() {
|
|
| ------------ help: try: `if let Err(..) = x`
|
|
...
|
|
LL | x.unwrap_err(); // unnecessary
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: this call to `unwrap()` will always panic
|
|
--> $DIR/simple_conditionals.rs:66:9
|
|
|
|
|
LL | if x.is_err() {
|
|
| ---------- because of this check
|
|
LL | x.unwrap(); // will panic
|
|
| ^^^^^^^^^^
|
|
|
|
error: called `unwrap_err` on `x` after checking its variant with `is_err`
|
|
--> $DIR/simple_conditionals.rs:67:9
|
|
|
|
|
LL | if x.is_err() {
|
|
| ------------- help: try: `if let Err(..) = x`
|
|
LL | x.unwrap(); // will panic
|
|
LL | x.unwrap_err(); // unnecessary
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: called `unwrap` on `x` after checking its variant with `is_err`
|
|
--> $DIR/simple_conditionals.rs:69:9
|
|
|
|
|
LL | if x.is_err() {
|
|
| ------------- help: try: `if let Ok(..) = x`
|
|
...
|
|
LL | x.unwrap(); // unnecessary
|
|
| ^^^^^^^^^^
|
|
|
|
error: this call to `unwrap_err()` will always panic
|
|
--> $DIR/simple_conditionals.rs:70:9
|
|
|
|
|
LL | if x.is_err() {
|
|
| ---------- because of this check
|
|
...
|
|
LL | x.unwrap_err(); // will panic
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
error: aborting due to 17 previous errors
|
|
|