]> git.lizzy.rs Git - rust.git/commitdiff
result_map_or_into_option: add `opt.map_or(None, |_| Some(y))` test
authorNick Torres <nickrtorres@icloud.com>
Sat, 4 Apr 2020 21:02:45 +0000 (14:02 -0700)
committerNick Torres <nickrtorres@icloud.com>
Sat, 4 Apr 2020 21:16:26 +0000 (14:16 -0700)
tests/ui/result_map_or_into_option.fixed
tests/ui/result_map_or_into_option.rs

index 07daf19fa250fa8862f96d6e6461a357ccd665f6..331531b5165f61dce075c4d800d9d806a7dba3e3 100644 (file)
@@ -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));
 }
index d097c19e44b90a3fbb7af3e99d15c02eacd9b263..3058480e2ad3d935c114a144ea504e495d033f7f 100644 (file)
@@ -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));
 }