-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #9223 - sgued:unwrap-expect-used, r=giraffate
unwrap_used: Don't recommend using `expect` when the `expect_used` lint is not allowed Fixes #9222 ``` changelog: [`unwrap_used`]: Don't recommend using `expect` when the `expect_used` lint is not allowed ```
- Loading branch information
Showing
7 changed files
with
80 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![warn(clippy::unwrap_used, clippy::expect_used)] | ||
|
||
fn main() { | ||
Some(3).unwrap(); | ||
Some(3).expect("Hello world!"); | ||
|
||
let a: Result<i32, i32> = Ok(3); | ||
a.unwrap(); | ||
a.expect("Hello world!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
error: used `unwrap()` on `an Option` value | ||
--> $DIR/unwrap_expect_used.rs:4:5 | ||
| | ||
LL | Some(3).unwrap(); | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::unwrap-used` implied by `-D warnings` | ||
= help: if this value is `None`, it will panic | ||
|
||
error: used `expect()` on `an Option` value | ||
--> $DIR/unwrap_expect_used.rs:5:5 | ||
| | ||
LL | Some(3).expect("Hello world!"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::expect-used` implied by `-D warnings` | ||
= help: if this value is `None`, it will panic | ||
|
||
error: used `unwrap()` on `a Result` value | ||
--> $DIR/unwrap_expect_used.rs:8:5 | ||
| | ||
LL | a.unwrap(); | ||
| ^^^^^^^^^^ | ||
| | ||
= help: if this value is an `Err`, it will panic | ||
|
||
error: used `expect()` on `a Result` value | ||
--> $DIR/unwrap_expect_used.rs:9:5 | ||
| | ||
LL | a.expect("Hello world!"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: if this value is an `Err`, it will panic | ||
|
||
error: aborting due to 4 previous errors | ||
|