about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-09-27 18:58:56 -0700
committerEsteban Küber <esteban@kuber.com.ar>2020-10-25 15:21:14 -0700
commitcabf6d052329c8ba5f23c7fc4873e9db64874997 (patch)
tree4392ba2faab1fe90cd71f186fea5175be40b32cf /src/test
parent07a63e6d1fabf3560e8e1e17c1d56b10a06152d9 (diff)
Tweak `if let` suggestion to be more liberal with suggestion and to not ICE
Fix #77218. Fix #77238.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/issues/issue-77218.rs7
-rw-r--r--src/test/ui/issues/issue-77218.stderr14
-rw-r--r--src/test/ui/suggestions/if-let-typo.rs1
-rw-r--r--src/test/ui/suggestions/if-let-typo.stderr18
4 files changed, 28 insertions, 12 deletions
diff --git a/src/test/ui/issues/issue-77218.rs b/src/test/ui/issues/issue-77218.rs
new file mode 100644
index 00000000000..bc992c21dca
--- /dev/null
+++ b/src/test/ui/issues/issue-77218.rs
@@ -0,0 +1,7 @@
+fn main() {
+    let value = [7u8];
+    while Some(0) = value.get(0) { //~ ERROR mismatched types
+        //~^ NOTE expected `bool`, found `()`
+        //~| HELP you might have meant to use pattern matching
+    }
+}
diff --git a/src/test/ui/issues/issue-77218.stderr b/src/test/ui/issues/issue-77218.stderr
new file mode 100644
index 00000000000..eca44725eb2
--- /dev/null
+++ b/src/test/ui/issues/issue-77218.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-77218.rs:3:11
+   |
+LL |     while Some(0) = value.get(0) {
+   |           ^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
+   |
+help: you might have meant to use pattern matching
+   |
+LL |     while let Some(0) = value.get(0) {
+   |           ^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/suggestions/if-let-typo.rs b/src/test/ui/suggestions/if-let-typo.rs
index c1e417b97f6..87def13c476 100644
--- a/src/test/ui/suggestions/if-let-typo.rs
+++ b/src/test/ui/suggestions/if-let-typo.rs
@@ -4,6 +4,5 @@ fn main() {
     if Some(x) = foo {} //~ ERROR cannot find value `x` in this scope
     if Some(foo) = bar {} //~ ERROR mismatched types
     if 3 = foo {} //~ ERROR mismatched types
-    //~^ ERROR mismatched types
     if Some(3) = foo {} //~ ERROR mismatched types
 }
diff --git a/src/test/ui/suggestions/if-let-typo.stderr b/src/test/ui/suggestions/if-let-typo.stderr
index bb2ea8cb477..d8e50cae55a 100644
--- a/src/test/ui/suggestions/if-let-typo.stderr
+++ b/src/test/ui/suggestions/if-let-typo.stderr
@@ -25,22 +25,18 @@ LL |     if Some(foo) == bar {}
    |                  ^^
 
 error[E0308]: mismatched types
-  --> $DIR/if-let-typo.rs:6:12
-   |
-LL |     if 3 = foo {}
-   |            ^^^ expected integer, found enum `Option`
-   |
-   = note: expected type `{integer}`
-              found enum `Option<{integer}>`
-
-error[E0308]: mismatched types
   --> $DIR/if-let-typo.rs:6:8
    |
 LL |     if 3 = foo {}
    |        ^^^^^^^ expected `bool`, found `()`
+   |
+help: you might have meant to use pattern matching
+   |
+LL |     if let 3 = foo {}
+   |        ^^^
 
 error[E0308]: mismatched types
-  --> $DIR/if-let-typo.rs:8:8
+  --> $DIR/if-let-typo.rs:7:8
    |
 LL |     if Some(3) = foo {}
    |        ^^^^^^^^^^^^^ expected `bool`, found `()`
@@ -54,7 +50,7 @@ help: you might have meant to compare for equality
 LL |     if Some(3) == foo {}
    |                ^^
 
-error: aborting due to 5 previous errors
+error: aborting due to 4 previous errors
 
 Some errors have detailed explanations: E0308, E0425.
 For more information about an error, try `rustc --explain E0308`.