]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/clippy/tests/ui/unnecessary_wraps.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / tools / clippy / tests / ui / unnecessary_wraps.rs
index a4570098d7167da8393f6c4933d20cf277be8962..54f22e3ee6a4acab5cc6d94444eb4c8b082c0d8d 100644 (file)
@@ -22,29 +22,17 @@ fn func2(a: bool, b: bool) -> Option<i32> {
     if a && b {
         return Some(10);
     }
-    if a {
-        Some(20)
-    } else {
-        Some(30)
-    }
+    if a { Some(20) } else { Some(30) }
 }
 
 // public fns should not be linted
 pub fn func3(a: bool) -> Option<i32> {
-    if a {
-        Some(1)
-    } else {
-        Some(1)
-    }
+    if a { Some(1) } else { Some(1) }
 }
 
 // should not be linted
 fn func4(a: bool) -> Option<i32> {
-    if a {
-        Some(1)
-    } else {
-        None
-    }
+    if a { Some(1) } else { None }
 }
 
 // should be linted
@@ -64,11 +52,7 @@ fn func7() -> Result<i32, ()> {
 
 // should not be linted
 fn func8(a: bool) -> Result<i32, ()> {
-    if a {
-        Ok(1)
-    } else {
-        Err(())
-    }
+    if a { Ok(1) } else { Err(()) }
 }
 
 // should not be linted
@@ -116,8 +100,45 @@ fn issue_6384(s: &str) -> Option<&str> {
     })
 }
 
+// should be linted
+fn issue_6640_1(a: bool, b: bool) -> Option<()> {
+    if a && b {
+        return Some(());
+    }
+    if a {
+        Some(());
+        Some(())
+    } else {
+        return Some(());
+    }
+}
+
+// should be linted
+fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> {
+    if a && b {
+        return Ok(());
+    }
+    if a {
+        Ok(())
+    } else {
+        return Ok(());
+    }
+}
+
+// should not be linted
+fn issue_6640_3() -> Option<()> {
+    if true { Some(()) } else { None }
+}
+
+// should not be linted
+fn issue_6640_4() -> Result<(), ()> {
+    if true { Ok(()) } else { Err(()) }
+}
+
 fn main() {
     // method calls are not linted
     func1(true, true);
     func2(true, true);
+    issue_6640_1(true, true);
+    issue_6640_2(true, true);
 }