diff options
| author | Pavel Grigorenko <GrigorenkoPV@ya.ru> | 2024-09-23 02:12:53 +0300 |
|---|---|---|
| committer | Pavel Grigorenko <GrigorenkoPV@ya.ru> | 2024-09-23 02:12:53 +0300 |
| commit | 9cd668beed38a8e98933733854a224c70998bf16 (patch) | |
| tree | 0ac8ea5f3c8b8839224855bac9725e19c323137f /tests/ui/pattern/at-in-struct-patterns.rs | |
| parent | 8ed95d1d9e149b5242316c91b3849c58f8320470 (diff) | |
| download | rust-9cd668beed38a8e98933733854a224c70998bf16.tar.gz rust-9cd668beed38a8e98933733854a224c70998bf16.zip | |
Parser: better error messages for `@` in struct patterns
Diffstat (limited to 'tests/ui/pattern/at-in-struct-patterns.rs')
| -rw-r--r-- | tests/ui/pattern/at-in-struct-patterns.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/pattern/at-in-struct-patterns.rs b/tests/ui/pattern/at-in-struct-patterns.rs new file mode 100644 index 00000000000..e8fad61f317 --- /dev/null +++ b/tests/ui/pattern/at-in-struct-patterns.rs @@ -0,0 +1,14 @@ +struct Foo { + field1: u8, + field2: u8, +} + +fn main() { + let foo = Foo { field1: 1, field2: 2 }; + let Foo { var @ field1, .. } = foo; //~ ERROR Unexpected `@` in struct pattern + dbg!(var); //~ ERROR cannot find value `var` in this scope + let Foo { field1: _, bar @ .. } = foo; //~ ERROR `@ ..` is not supported in struct patterns + let Foo { bar @ .. } = foo; //~ ERROR `@ ..` is not supported in struct patterns + let Foo { @ } = foo; //~ ERROR expected identifier, found `@` + let Foo { @ .. } = foo; //~ ERROR expected identifier, found `@` +} |
