-
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 #7971 - togami2864:fix/option-map-or-none, r=llogiq
fix suggestion in option_map_or_none fix: #7960 changelog: change suggestion in the lint rule `option_map_or_none`
- Loading branch information
Showing
4 changed files
with
141 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,45 @@ | ||
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `and_then(..)` instead | ||
--> $DIR/option_map_or_none.rs:10:13 | ||
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead | ||
--> $DIR/option_map_or_none.rs:11:26 | ||
| | ||
LL | let _ = opt.map_or(None, |x| Some(x + 1)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `and_then` instead: `opt.and_then(|x| Some(x + 1))` | ||
LL | let _: Option<i32> = opt.map_or(None, |x| Some(x + 1)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `map` instead: `opt.map(|x| x + 1)` | ||
| | ||
= note: `-D clippy::option-map-or-none` implied by `-D warnings` | ||
|
||
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `and_then(..)` instead | ||
--> $DIR/option_map_or_none.rs:13:13 | ||
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead | ||
--> $DIR/option_map_or_none.rs:14:26 | ||
| | ||
LL | let _ = opt.map_or(None, |x| { | ||
| _____________^ | ||
LL | let _: Option<i32> = opt.map_or(None, |x| { | ||
| __________________________^ | ||
LL | | Some(x + 1) | ||
LL | | }); | ||
| |_________________________^ | ||
| |_________________________^ help: try using `map` instead: `opt.map(|x| x + 1)` | ||
|
||
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `and_then(..)` instead | ||
--> $DIR/option_map_or_none.rs:18:26 | ||
| | ||
LL | let _: Option<i32> = opt.map_or(None, bar); | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: try using `and_then` instead: `opt.and_then(bar)` | ||
|
||
error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `and_then(..)` instead | ||
--> $DIR/option_map_or_none.rs:19:26 | ||
| | ||
LL | let _: Option<i32> = opt.map_or(None, |x| { | ||
| __________________________^ | ||
LL | | let offset = 0; | ||
LL | | let height = x; | ||
LL | | Some(offset + height) | ||
LL | | }); | ||
| |______^ | ||
| | ||
help: try using `and_then` instead | ||
| | ||
LL ~ let _ = opt.and_then(|x| { | ||
LL + Some(x + 1) | ||
LL ~ }); | ||
LL ~ let _: Option<i32> = opt.and_then(|x| { | ||
LL + let offset = 0; | ||
LL + let height = x; | ||
LL + Some(offset + height) | ||
LL ~ }); | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 4 previous errors | ||
|