about summary refs log tree commit diff
path: root/src/test/ui/pattern
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-30 07:27:56 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-12-30 13:50:20 +0100
commit960acb044bcefc46520cee263b6877160fd296ca (patch)
treeb0f7a946f127e0e9fdac7bb74a5d8c10470e41ef /src/test/ui/pattern
parentab050d6a83a9bdc5856a20402b6ea440d474638c (diff)
downloadrust-960acb044bcefc46520cee263b6877160fd296ca.tar.gz
rust-960acb044bcefc46520cee263b6877160fd296ca.zip
Show scrutinee expr type for struct fields.
TODO: The type is wrong and will be fixed in later commits.
Diffstat (limited to 'src/test/ui/pattern')
-rw-r--r--src/test/ui/pattern/pat-struct-field-expr-has-type.rs9
-rw-r--r--src/test/ui/pattern/pat-struct-field-expr-has-type.stderr14
2 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/pattern/pat-struct-field-expr-has-type.rs b/src/test/ui/pattern/pat-struct-field-expr-has-type.rs
new file mode 100644
index 00000000000..1d18214de7f
--- /dev/null
+++ b/src/test/ui/pattern/pat-struct-field-expr-has-type.rs
@@ -0,0 +1,9 @@
+struct S {
+    f: u8,
+}
+
+fn main() {
+    match (S { f: 42 }) {
+        S { f: Ok(_) } => {} //~ ERROR mismatched types
+    }
+}
diff --git a/src/test/ui/pattern/pat-struct-field-expr-has-type.stderr b/src/test/ui/pattern/pat-struct-field-expr-has-type.stderr
new file mode 100644
index 00000000000..7962c376a92
--- /dev/null
+++ b/src/test/ui/pattern/pat-struct-field-expr-has-type.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+  --> $DIR/pat-struct-field-expr-has-type.rs:7:16
+   |
+LL |     match (S { f: 42 }) {
+   |           ------------- this expression has type `u8`
+LL |         S { f: Ok(_) } => {}
+   |                ^^^^^ expected `u8`, found enum `std::result::Result`
+   |
+   = note: expected type `u8`
+              found enum `std::result::Result<_, _>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.