]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/if_same_then_else.rs
Auto merge of #4478 - tsurai:master, r=flip1995
[rust.git] / tests / ui / if_same_then_else.rs
index 71f228c32bd459316d80dd46e471a77ff40c458a..ecdc5623ca585b75c9bbabfd098037fb7167f1d3 100644 (file)
@@ -215,10 +215,10 @@ fn if_same_then_else() -> Result<&'static str, ()> {
     };
 
     if true {
-        try!(Ok("foo"));
+        Ok("foo")?;
     } else {
         //~ ERROR same body as `if` block
-        try!(Ok("foo"));
+        Ok("foo")?;
     }
 
     if true {
@@ -232,7 +232,21 @@ fn if_same_then_else() -> Result<&'static str, ()> {
         return Ok(&foo[0..]);
     }
 
-    // false positive if_same_then_else, let(x,y) vs let(y,x), see #3559
+    if true {
+        let foo = "";
+        return Ok(&foo[0..]);
+    } else if false {
+        let foo = "bar";
+        return Ok(&foo[0..]);
+    } else if true {
+        let foo = "";
+        return Ok(&foo[0..]);
+    } else {
+        let foo = "";
+        return Ok(&foo[0..]);
+    }
+
+    // False positive `if_same_then_else`: `let (x, y)` vs. `let (y, x)`; see issue #3559.
     if true {
         let foo = "";
         let (x, y) = (1, 2);
@@ -244,7 +258,7 @@ fn if_same_then_else() -> Result<&'static str, ()> {
     }
 }
 
-// Issue #2423. This was causing an ICE
+// Issue #2423. This was causing an ICE.
 fn func() {
     if true {
         f(&[0; 62]);