about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNick Torres <nickrtorres@icloud.com>2020-04-04 14:02:45 -0700
committerNick Torres <nickrtorres@icloud.com>2020-04-04 14:16:26 -0700
commitfb276dc3fa1d644ce6de1849ff3b78d3e54f5d9e (patch)
treed18eebe070a98dd8338523b5ecbe21d312b5bf18
parentd0738bd673fe8e2b42d26b6d116f197f4aecea82 (diff)
downloadrust-fb276dc3fa1d644ce6de1849ff3b78d3e54f5d9e.tar.gz
rust-fb276dc3fa1d644ce6de1849ff3b78d3e54f5d9e.zip
result_map_or_into_option: add `opt.map_or(None, |_| Some(y))` test
-rw-r--r--tests/ui/result_map_or_into_option.fixed5
-rw-r--r--tests/ui/result_map_or_into_option.rs5
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/ui/result_map_or_into_option.fixed b/tests/ui/result_map_or_into_option.fixed
index 07daf19fa25..331531b5165 100644
--- a/tests/ui/result_map_or_into_option.fixed
+++ b/tests/ui/result_map_or_into_option.fixed
@@ -11,4 +11,9 @@ fn main() {
     // A non-Some `f` arg should not emit the lint
     let opt: Result<u32, &str> = Ok(1);
     let _ = opt.map_or(None, rewrap);
+
+    // A non-Some `f` closure where the argument is not used as the
+    // return should not emit the lint
+    let opt: Result<u32, &str> = Ok(1);
+    opt.map_or(None, |_x| Some(1));
 }
diff --git a/tests/ui/result_map_or_into_option.rs b/tests/ui/result_map_or_into_option.rs
index d097c19e44b..3058480e2ad 100644
--- a/tests/ui/result_map_or_into_option.rs
+++ b/tests/ui/result_map_or_into_option.rs
@@ -11,4 +11,9 @@ fn main() {
     // A non-Some `f` arg should not emit the lint
     let opt: Result<u32, &str> = Ok(1);
     let _ = opt.map_or(None, rewrap);
+
+    // A non-Some `f` closure where the argument is not used as the
+    // return should not emit the lint
+    let opt: Result<u32, &str> = Ok(1);
+    opt.map_or(None, |_x| Some(1));
 }