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

C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEE-help-wantedCall for participation: help is requested to fix this issueP-lowLow prioritygood first issueIssues up for grabs, also good candidates for new rustfmt contributorsonly-with-optionRequires a non-default option value to reproduce

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions