]> git.lizzy.rs Git - rust.git/commitdiff
Add if let test
authorEsteban Küber <esteban@kuber.com.ar>
Tue, 30 Apr 2019 03:58:29 +0000 (20:58 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Tue, 30 Apr 2019 03:58:29 +0000 (20:58 -0700)
src/test/ui/suggestions/match-ergonomics.rs
src/test/ui/suggestions/match-ergonomics.stderr

index d75f8363cd22169e0728d878d59f9e83ce91abe5..c4fc01469bf65ec4c41432a4719b8ed33c3a68f1 100644 (file)
@@ -37,4 +37,5 @@ fn main() {
         v => {},
         _ => {},
     }
+    if let [&v] = &x[..] {} //~ ERROR mismatched types
 }
index a064e2485ffe806a7b3e0a6722165e2a5bd1086c..9915eeb34fac1896cef86f3910adb9df84c2f4e0 100644 (file)
@@ -35,7 +35,19 @@ help: you can rely on match ergonomics and remove the explicit borrow
 LL |         v => {},
    |         ^
 
-error: aborting due to 4 previous errors
+error[E0308]: mismatched types
+  --> $DIR/match-ergonomics.rs:40:13
+   |
+LL |     if let [&v] = &x[..] {}
+   |             ^^
+   |             |
+   |             expected i32, found reference
+   |             help: you can probably remove the explicit borrow: `v`
+   |
+   = note: expected type `i32`
+              found type `&_`
+
+error: aborting due to 5 previous errors
 
 Some errors have detailed explanations: E0308, E0529.
 For more information about an error, try `rustc --explain E0308`.