diff options
| author | Jack Rickard <jack.rickard@outlook.com> | 2025-02-03 13:56:20 +0000 |
|---|---|---|
| committer | Jack Rickard <jack.rickard@outlook.com> | 2025-02-03 14:04:57 +0000 |
| commit | 3f09a2054921708ac8288ac9912885dbe66682ec (patch) | |
| tree | 829c9f235f96c8d669a20af4277f0463a15d0bad /tests/ui/parser/attribute | |
| parent | 01a26c026ddd9f0da0307468b07b003b8759fc4a (diff) | |
| download | rust-3f09a2054921708ac8288ac9912885dbe66682ec.tar.gz rust-3f09a2054921708ac8288ac9912885dbe66682ec.zip | |
Do not allow attributes on struct field rest patterns
This removes support for attributes on struct field rest patterns (the `..`) from the parser. Previously they were being parsed but dropped from the AST, so didn't work and were deleted by rustfmt.
Diffstat (limited to 'tests/ui/parser/attribute')
| -rw-r--r-- | tests/ui/parser/attribute/attr-pat-struct-rest.rs | 8 | ||||
| -rw-r--r-- | tests/ui/parser/attribute/attr-pat-struct-rest.stderr | 10 |
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/parser/attribute/attr-pat-struct-rest.rs b/tests/ui/parser/attribute/attr-pat-struct-rest.rs new file mode 100644 index 00000000000..b2bfcf82df8 --- /dev/null +++ b/tests/ui/parser/attribute/attr-pat-struct-rest.rs @@ -0,0 +1,8 @@ +// #81282: Attributes are not allowed on struct field rest patterns (the ..). + +struct S {} + +fn main() { + let S { #[cfg(any())] .. } = S {}; + //~^ ERROR expected identifier, found `..` +} diff --git a/tests/ui/parser/attribute/attr-pat-struct-rest.stderr b/tests/ui/parser/attribute/attr-pat-struct-rest.stderr new file mode 100644 index 00000000000..f72c54973fc --- /dev/null +++ b/tests/ui/parser/attribute/attr-pat-struct-rest.stderr @@ -0,0 +1,10 @@ +error: expected identifier, found `..` + --> $DIR/attr-pat-struct-rest.rs:6:27 + | +LL | let S { #[cfg(any())] .. } = S {}; + | - ^^ expected identifier + | | + | while parsing the fields for this pattern + +error: aborting due to 1 previous error + |
