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:
authorLaurențiu Nicola <lnicola@users.noreply.github.com>2024-12-23 10:12:23 +0000
committerGitHub <noreply@github.com>2024-12-23 10:12:23 +0000
commit8dbdcc03ebfd5d3c21671d8a021669dc79d93038 (patch)
treee61d058d30fdd35c4a306fde5be669b08092a4fd /tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs
parent63a3c394617b114a8fa6e54401700b3adee65a7d (diff)
parent0180d2d16f5f5d60384a594568a98a6e6f8eea59 (diff)
downloadrust-8dbdcc03ebfd5d3c21671d8a021669dc79d93038.tar.gz
rust-8dbdcc03ebfd5d3c21671d8a021669dc79d93038.zip
Merge pull request #18746 from lnicola/sync-from-rust
minor: Sync from downstream
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
+    }
+}