rustfmt
rustfmt copied to clipboard
`struct_field_align_threshold` doesn't apply when using `..Default::default()`
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,
}
@theon thanks for the report. For reference, what value are you setting struct_field_align_threshold to?
I've got it set really high at 200 (I wanted fields to always be aligned). From my rustfmt.toml:
struct_field_align_threshold = 200