From e98d52408c908d52bc3466d1b59d167a9463512a Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Wed, 8 Jan 2025 00:10:16 +0000 Subject: Add check for missing fields in enum variant pattern (cherry picked from commit d44f021904e3d5b2870e3c835cbad5e1421e83ec) --- .../pattern/struct-pattern-with-missing-fields-resolve-error.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.rs') 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, } +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 + } } -- cgit 1.4.1-3-g733a5