forked from rust-lang/rust-clippy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for
option_map_or_err_ok
lint
- Loading branch information
1 parent
952f295
commit a980fff
Showing
4 changed files
with
35 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#![warn(clippy::option_map_or_err_ok)] | ||
|
||
fn main() { | ||
let x = Some("a"); | ||
let _ = x.ok_or("a"); | ||
//~^ ERROR: called `map_or(Err(_), Ok)` on an `Option` value | ||
} |
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,7 @@ | ||
#![warn(clippy::option_map_or_err_ok)] | ||
|
||
fn main() { | ||
let x = Some("a"); | ||
let _ = x.map_or(Err("a"), Ok); | ||
//~^ ERROR: called `map_or(Err(_), Ok)` on an `Option` value | ||
} |
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,11 @@ | ||
error: called `map_or(Err(_), Ok)` on an `Option` value | ||
--> $DIR/option_map_or_err_ok.rs:5:13 | ||
| | ||
LL | let _ = x.map_or(Err("a"), Ok); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try using `ok_or` instead: `x.ok_or("a")` | ||
| | ||
= note: `-D clippy::option-map-or-err-ok` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::option_map_or_err_ok)]` | ||
|
||
error: aborting due to previous error | ||
|