about summary refs log tree commit diff
path: root/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs')
-rw-r--r--tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs b/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs
new file mode 100644
index 00000000000..225891e390f
--- /dev/null
+++ b/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs
@@ -0,0 +1,21 @@
+struct Website {
+    url: String,
+    title: Option<String>,
+}
+
+fn main() {
+    let website = Website {
+        url: "http://www.example.com".into(),
+        title: Some("Example Domain".into()),
+    };
+
+    if let Website { url, Some(title) } = website { //~ ERROR expected `,`
+        //~^ NOTE while parsing the fields for this pattern
+        println!("[{}]({})", title, url); // we hide the errors for `title` and `url`
+    }
+
+    if let Website { url, .. } = website { //~ NOTE this pattern
+        println!("[{}]({})", title, url); //~ ERROR cannot find value `title` in this scope
+        //~^ NOTE not found in this scope
+    }
+}