Given (as brought up in #63693 (comment) CC @Centril):
pub fn main() {
struct Foo { x: isize }
let mut Foo { x: x } = Foo { x: 3 };
}
We currently emit a parse error:
error: expected one of `:`, `;`, `=`, or `@`, found `{`
--> src/main.rs:3:17
|
3 | let mut Foo { x: x } = Foo { x: 3 };
| ^ expected one of `:`, `;`, `=`, or `@` here
It should instead parse as if it were let Foo { x: mut x } = Foo { x: 3 }; (medium priority), silence any complaints that mut is unnecessary (lower priority) and emit a custom error explaining that mut cannot lead a pattern with subpatterns (must have), and suggest the appropriate mut placement in the sub-bindings (nice to have):
error: incorrect `mut` pattern
--> src/main.rs:3:17
|
3 | let mut Foo { x: x } = Foo { x: 3 };
| ^^^ patterns with sub-bindings can't be marked as `mut`
help: mark the individual sub-bindings as `mut` instead
3 | let Foo { x: mut x } = Foo { x: 3 };
| -- ^^^
Given (as brought up in #63693 (comment) CC @Centril):
We currently emit a parse error:
It should instead parse as if it were
let Foo { x: mut x } = Foo { x: 3 };(medium priority), silence any complaints thatmutis unnecessary (lower priority) and emit a custom error explaining thatmutcannot lead a pattern with subpatterns (must have), and suggest the appropriatemutplacement in the sub-bindings (nice to have):