Skip to content

use_field_init_shorthand option breaks numbered struct field initialization #5488

@foxcob

Description

@foxcob

If I have a struct type with an implicit field such as

struct MyStruct(u64);

And I attempt to initialize it to 0

let instance = MyStruct { 0: 0 };

With the option "use_field_init_shorthand = true", rustfmt will incorrectly shorten the initialization to:

let instance = MyStruct { 0 };

This code will no longer compile after running rustfmt.

Metadata

Metadata

Assignees

Labels

bugPanic, non-idempotency, invalid code, etc.good first issueIssues up for grabs, also good candidates for new rustfmt contributorshelp wantedonly-with-optionrequires a non-default option value to reproducep-low

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions