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:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-01-08 18:21:02 +0100
committerGitHub <noreply@github.com>2025-01-08 18:21:02 +0100
commit748effd71acd1ce614aebd8bb305b608ef9645d4 (patch)
tree35aef3f5e3a3cff513504220b883ebbcd2a2169d /tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs
parentb87a00488f254acaf943022f4bb958dcb50be9f6 (diff)
parent592f2c90da6a6e1b25b3b9c2f13a2e0cfb83dcfc (diff)
downloadrust-748effd71acd1ce614aebd8bb305b608ef9645d4.tar.gz
rust-748effd71acd1ce614aebd8bb305b608ef9645d4.zip
Rollup merge of #135222 - estebank:issue-135209, r=compiler-errors
Ensure that we don't try to access fields on a non-struct pattern type

Fix #135209.
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.rs9
1 files changed, 9 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
index 225891e390f..39f9f5a2c02 100644
--- a/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs
+++ b/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs
@@ -3,6 +3,10 @@ struct Website {
     title: Option<String>,
 }
 
+enum Foo {
+    Bar { a: i32 },
+}
+
 fn main() {
     let website = Website {
         url: "http://www.example.com".into(),
@@ -18,4 +22,9 @@ fn main() {
         println!("[{}]({})", title, url); //~ ERROR cannot find value `title` in this scope
         //~^ NOTE not found in this scope
     }
+
+    let x = Foo::Bar { a: 1 };
+    if let Foo::Bar { .. } = x { //~ NOTE this pattern
+        println!("{a}"); //~ ERROR cannot find value `a` in this scope
+    }
 }