]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/option_if_let_else.fixed
Merge remote-tracking branch 'upstream/master' into rustup
[rust.git] / tests / ui / option_if_let_else.fixed
index 695a460cc4edfda0a16871c1aa0b3f1498359271..47e7460fa7a44d4a11f38119d9c2a118d7075d0f 100644 (file)
@@ -1,5 +1,7 @@
 // run-rustfix
 #![warn(clippy::option_if_let_else)]
+#![allow(clippy::redundant_closure)]
+#![allow(clippy::ref_option_ref)]
 
 fn bad1(string: Option<&str>) -> (bool, &str) {
     string.map_or((false, "hello"), |x| (true, x))
@@ -36,6 +38,14 @@ fn longer_body(arg: Option<u32>) -> u32 {
     })
 }
 
+fn impure_else(arg: Option<i32>) {
+    let side_effect = || {
+        println!("return 1");
+        1
+    };
+    let _ = arg.map_or_else(|| side_effect(), |x| x);
+}
+
 fn test_map_or_else(arg: Option<u32>) {
     let _ = arg.map_or_else(|| {
         let mut y = 1;
@@ -71,4 +81,5 @@ fn main() {
     let _ = longer_body(None);
     test_map_or_else(None);
     let _ = negative_tests(None);
+    let _ = impure_else(None);
 }