about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2022-11-03 14:35:15 +0000
committerDeadbeef <ent3rm4n@gmail.com>2022-11-05 15:33:25 +0000
commitb1994ce80662c6cdebdf42cb64e87572f0ab8839 (patch)
tree42809283d50101090ba951beda4f564cb20e02d5 /src
parent160b19429523ea44c4c3b7cad4233b2a35f58b8f (diff)
downloadrust-b1994ce80662c6cdebdf42cb64e87572f0ab8839.tar.gz
rust-b1994ce80662c6cdebdf42cb64e87572f0ab8839.zip
Do not make typo suggestions when suggesting pattern matching
Fixes #103909.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/did_you_mean/issue-103909.rs9
-rw-r--r--src/test/ui/did_you_mean/issue-103909.stderr21
2 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/did_you_mean/issue-103909.rs b/src/test/ui/did_you_mean/issue-103909.rs
new file mode 100644
index 00000000000..20b67cd102d
--- /dev/null
+++ b/src/test/ui/did_you_mean/issue-103909.rs
@@ -0,0 +1,9 @@
+#![allow(unused_variables)]
+use std::fs::File;
+
+fn main() {
+    if Err(err) = File::open("hello.txt") {
+        //~^ ERROR: cannot find value `err` in this scope
+        //~| ERROR: mismatched types
+    }
+}
diff --git a/src/test/ui/did_you_mean/issue-103909.stderr b/src/test/ui/did_you_mean/issue-103909.stderr
new file mode 100644
index 00000000000..a28914051b9
--- /dev/null
+++ b/src/test/ui/did_you_mean/issue-103909.stderr
@@ -0,0 +1,21 @@
+error[E0425]: cannot find value `err` in this scope
+  --> $DIR/issue-103909.rs:5:12
+   |
+LL |     if Err(err) = File::open("hello.txt") {
+   |            ^^^ not found in this scope
+   |
+help: you might have meant to use pattern matching
+   |
+LL |     if let Err(err) = File::open("hello.txt") {
+   |        +++
+
+error[E0308]: mismatched types
+  --> $DIR/issue-103909.rs:5:8
+   |
+LL |     if Err(err) = File::open("hello.txt") {
+   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0308, E0425.
+For more information about an error, try `rustc --explain E0308`.