From cd81bb9dc329fc369531dcb0e6c2b1032e8914ce Mon Sep 17 00:00:00 2001 From: togami2864 Date: Fri, 19 Nov 2021 16:17:17 +0900 Subject: [PATCH] fix stderr --- tests/ui/option_map_or_none.fixed | 4 ++++ tests/ui/option_map_or_none.stderr | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/ui/option_map_or_none.fixed b/tests/ui/option_map_or_none.fixed index 177054f763b..04bfac7735f 100644 --- a/tests/ui/option_map_or_none.fixed +++ b/tests/ui/option_map_or_none.fixed @@ -4,6 +4,7 @@ fn main() { let opt = Some(1); + let r: Result = Ok(1); let bar = |_| Some(1); // Check `OPTION_MAP_OR_NONE`. @@ -19,4 +20,7 @@ fn main() { let height = x; Some(offset + height) }); + + // Check `RESULT_MAP_OR_INTO_OPTION`. + let _: Option = r.ok(); } diff --git a/tests/ui/option_map_or_none.stderr b/tests/ui/option_map_or_none.stderr index 11bdd887b6d..7befcb89086 100644 --- a/tests/ui/option_map_or_none.stderr +++ b/tests/ui/option_map_or_none.stderr @@ -1,5 +1,5 @@ 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 + --> $DIR/option_map_or_none.rs:12:26 | LL | let _: Option = opt.map_or(None, |x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `map` instead: `opt.map(|x| x + 1)` @@ -7,7 +7,7 @@ LL | let _: Option = opt.map_or(None, |x| Some(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 `map(..)` instead - --> $DIR/option_map_or_none.rs:14:26 + --> $DIR/option_map_or_none.rs:15:26 | LL | let _: Option = opt.map_or(None, |x| { | __________________________^ @@ -16,13 +16,13 @@ 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 + --> $DIR/option_map_or_none.rs:19:26 | LL | let _: Option = 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 + --> $DIR/option_map_or_none.rs:20:26 | LL | let _: Option = opt.map_or(None, |x| { | __________________________^ @@ -41,5 +41,13 @@ LL + Some(offset + height) LL ~ }); | -error: aborting due to 4 previous errors +error: called `map_or(None, Some)` on a `Result` value. This can be done more directly by calling `ok()` instead + --> $DIR/option_map_or_none.rs:27:26 + | +LL | let _: Option = r.map_or(None, Some); + | ^^^^^^^^^^^^^^^^^^^^ help: try using `ok` instead: `r.ok()` + | + = note: `-D clippy::result-map-or-into-option` implied by `-D warnings` + +error: aborting due to 5 previous errors