about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/type/type-check/assignment-in-if.rs9
-rw-r--r--src/test/ui/type/type-check/assignment-in-if.stderr23
2 files changed, 26 insertions, 6 deletions
diff --git a/src/test/ui/type/type-check/assignment-in-if.rs b/src/test/ui/type/type-check/assignment-in-if.rs
index 232b0a00b30..77b122b0a79 100644
--- a/src/test/ui/type/type-check/assignment-in-if.rs
+++ b/src/test/ui/type/type-check/assignment-in-if.rs
@@ -31,8 +31,13 @@ fn main() {
         //~^ ERROR mismatched types
         println!("{}", x);
     }
-    if (if true { x = 4 } else { x = 5 }) {
-        //~^ ERROR mismatched types
+    if (
+        if true {
+            x = 4 //~ ERROR mismatched types
+        } else {
+            x = 5 //~ ERROR mismatched types
+        }
+    ) {
         println!("{}", x);
     }
 }
diff --git a/src/test/ui/type/type-check/assignment-in-if.stderr b/src/test/ui/type/type-check/assignment-in-if.stderr
index 403f7b4f7ae..87b8d17c21b 100644
--- a/src/test/ui/type/type-check/assignment-in-if.stderr
+++ b/src/test/ui/type/type-check/assignment-in-if.stderr
@@ -47,14 +47,29 @@ LL |     if 3 = x {
               found type `()`
 
 error[E0308]: mismatched types
-  --> $DIR/assignment-in-if.rs:34:8
+  --> $DIR/assignment-in-if.rs:36:13
    |
-LL |     if (if true { x = 4 } else { x = 5 }) {
-   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected bool, found ()
+LL |             x = 4
+   |             ^^^^^
+   |             |
+   |             expected bool, found ()
+   |             help: try comparing for equality: `x == 4`
    |
    = note: expected type `bool`
               found type `()`
 
-error: aborting due to 5 previous errors
+error[E0308]: mismatched types
+  --> $DIR/assignment-in-if.rs:38:13
+   |
+LL |             x = 5
+   |             ^^^^^
+   |             |
+   |             expected bool, found ()
+   |             help: try comparing for equality: `x == 5`
+   |
+   = note: expected type `bool`
+              found type `()`
+
+error: aborting due to 6 previous errors
 
 For more information about this error, try `rustc --explain E0308`.