rust-clippy/tests/ui/option_map_or_none.stderr

56 lines
2 KiB
Text
Raw Normal View History

2023-11-23 12:30:36 +00:00
error: called `map_or(None, ..)` on an `Option` value
--> $DIR/option_map_or_none.rs:10:26
|
LL | let _: Option<i32> = opt.map_or(None, |x| Some(x + 1));
2024-01-18 17:17:53 +00:00
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `map`: `opt.map(|x| x + 1)`
|
= note: `-D clippy::option-map-or-none` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::option_map_or_none)]`
2023-11-23 12:30:36 +00:00
error: called `map_or(None, ..)` on an `Option` value
--> $DIR/option_map_or_none.rs:13:26
|
LL | let _: Option<i32> = opt.map_or(None, |x| {
| __________________________^
LL | | Some(x + 1)
LL | | });
2024-01-18 17:17:53 +00:00
| |_________________________^ help: consider using `map`: `opt.map(|x| x + 1)`
2023-11-23 12:30:36 +00:00
error: called `map_or(None, ..)` on an `Option` value
--> $DIR/option_map_or_none.rs:17:26
|
LL | let _: Option<i32> = opt.map_or(None, bar);
2024-01-18 17:17:53 +00:00
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using `and_then`: `opt.and_then(bar)`
2023-11-23 12:30:36 +00:00
error: called `map_or(None, ..)` on an `Option` value
--> $DIR/option_map_or_none.rs:18:26
|
LL | let _: Option<i32> = opt.map_or(None, |x| {
| __________________________^
LL | | let offset = 0;
LL | | let height = x;
LL | | Some(offset + height)
LL | | });
| |______^
2019-10-26 19:53:42 +00:00
|
2024-01-18 17:17:53 +00:00
help: consider using `and_then`
|
LL ~ let _: Option<i32> = opt.and_then(|x| {
LL + let offset = 0;
LL + let height = x;
LL + Some(offset + height)
LL ~ });
|
2023-11-23 12:30:36 +00:00
error: called `map_or(None, Some)` on a `Result` value
--> $DIR/option_map_or_none.rs:25:26
|
LL | let _: Option<i32> = r.map_or(None, Some);
2024-01-18 17:17:53 +00:00
| ^^^^^^^^^^^^^^^^^^^^ help: consider using `ok`: `r.ok()`
|
= note: `-D clippy::result-map-or-into-option` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::result_map_or_into_option)]`
error: aborting due to 5 previous errors