Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct_field_align_threshold doesn't apply when using ..Default::default() #6080

Open
theon opened this issue Feb 18, 2024 · 2 comments
Open

Comments

@theon
Copy link

theon commented Feb 18, 2024

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,
}
@ytmimi
Copy link
Contributor

ytmimi commented Feb 18, 2024

@theon thanks for the report. For reference, what value are you setting struct_field_align_threshold to?

@theon
Copy link
Author

theon commented Feb 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants