`struct_field_align_threshold` doesn't apply when using `..Default::default()`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
I have been using the struct_field_align_threshold option to align struct fields and it is great, however one issue I have noticed whilst using it is that the formatting isn't applied when using ..Default::default(). For example, formatting the follow struct has no impact:
StandardMaterial {
base_color_texture: Some(asset_server.load("textures/card_back.png")),
cull_mode: Some(Face::Front),
fog_enabled: false,
unlit: true,
alpha_mode: AlphaMode::Blend,
..Default::default()
}
I would expect:
StandardMaterial {
base_color_texture: Some(asset_server.load("textures/card_back.png")),
cull_mode: Some(Face::Front),
fog_enabled: false,
unlit: true,
alpha_mode: AlphaMode::Blend,
..Default::default()
}
If I remove the ..Default::default() line, rustfmt will align the fields as expected:
StandardMaterial {
base_color_texture: Some(asset_server.load("textures/card_back.png")),
cull_mode: Some(Face::Front),
fog_enabled: false,
unlit: true,
alpha_mode: AlphaMode::Blend,
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided struct formatting example in rustfmt and tracing the struct-field alignment handling for expressions using ..Default::default(). Done means the configured struct_field_align_threshold aligns the explicit fields in this case, with a regression test covering the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100