]> git.lizzy.rs Git - rust.git/commitdiff
Add additional test
authorLeSeulArtichaut <leseulartichaut@gmail.com>
Thu, 25 Mar 2021 20:53:56 +0000 (21:53 +0100)
committerLeSeulArtichaut <leseulartichaut@gmail.com>
Fri, 2 Apr 2021 10:42:48 +0000 (12:42 +0200)
Co-authored-by: Camelid <camelidcamel@gmail.com>
src/test/ui/deref-suggestion.rs
src/test/ui/deref-suggestion.stderr

index e62e8467bd28a1dc96b96196022ca341218f8ef6..4fd695585ba06d8190a0b28c008842412d12b123 100644 (file)
@@ -63,4 +63,12 @@ fn main() {
         b
         //~^ ERROR mismatched types
     };
+    let val = if true {
+        *a
+    } else if true {
+    //~^ ERROR incompatible types
+        b
+    } else {
+        &0
+    };
 }
index 0de125695e60b1ec57651b0c9a96fbf70828108e..1720421c7f60e72b79aa1750925841b5be2cc554 100644 (file)
@@ -107,6 +107,35 @@ LL |         b
    |         expected `i32`, found `&{integer}`
    |         help: consider dereferencing the borrow: `*b`
 
-error: aborting due to 12 previous errors
+error[E0308]: `if` and `else` have incompatible types
+  --> $DIR/deref-suggestion.rs:68:12
+   |
+LL |        let val = if true {
+   |   _______________-
+LL |  |         *a
+   |  |         -- expected because of this
+LL |  |     } else if true {
+   |  |____________^
+LL | ||
+LL | ||         b
+LL | ||     } else {
+LL | ||         &0
+LL | ||     };
+   | ||     ^
+   | ||_____|
+   | |______`if` and `else` have incompatible types
+   |        expected `i32`, found `&{integer}`
+   |
+help: consider dereferencing the borrow
+   |
+LL |     } else *if true {
+LL |
+LL |         b
+LL |     } else {
+LL |         &0
+LL |     };
+   |
+
+error: aborting due to 13 previous errors
 
 For more information about this error, try `rustc --explain E0308`.