Attributes on struct rest patterns are ignored #136108
Labels
A-attributes
Area: Attributes (`#[…]`, `#![…]`)
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Attributes on struct field rest patterns are entirely ignored by the compiler, in fact they're dropped by the parser, so they can't generate any errors (beyond parse errors) but are accepted by the parser.
Specifically, this bit of the AST doesn't store the attributes:
rust/compiler/rustc_ast/src/ast.rs
Lines 845 to 854 in 01a26c0
The parser drops them on the floor here.
This means that the following code doesn't produce any errors:
And entertainingly the attribute is deleted by rustfmt...I assume that's because it's not represented in the AST.
Now, as far as I know there aren't any attributes that would be reasonable to use in this position, which is probably why the bug still exists.
The text was updated successfully, but these errors were encountered: