about summary refs log tree commit diff
diff options
context:
space:
mode:
authortogami2864 <tuabobo123@gmail.com>2021-11-19 16:17:17 +0900
committertogami2864 <tuabobo123@gmail.com>2021-11-19 16:17:17 +0900
commitcd81bb9dc329fc369531dcb0e6c2b1032e8914ce (patch)
treed04afea61627fdd5be42e942fe750c9d9bf3dbaf
parentabb7155387b086fa70ed122c764d04e6c918cbf1 (diff)
downloadrust-cd81bb9dc329fc369531dcb0e6c2b1032e8914ce.tar.gz
rust-cd81bb9dc329fc369531dcb0e6c2b1032e8914ce.zip
fix stderr
-rw-r--r--tests/ui/option_map_or_none.fixed4
-rw-r--r--tests/ui/option_map_or_none.stderr18
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<i32, i32> = 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<i32> = 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<i32> = 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<i32> = 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<i32> = 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<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
+  --> $DIR/option_map_or_none.rs:20:26
    |
 LL |       let _: Option<i32> = 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<i32> = 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