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

Funny indentation when destructuring a struct with cfg toggled fields #5920

Open
grahamc opened this issue Sep 20, 2023 · 1 comment
Open

Comments

@grahamc
Copy link

grahamc commented Sep 20, 2023

On rustfmt 1.6.0, I get surprising indentation when destructuring a struct where some fields are cfg-specific.

struct Demo {
    field_name_foo: (),
    field_name_bar: (),
    #[cfg(feature = "diagnostics")]
    field_name_baz: (),
    field_name_tux: (),
}

fn main() {
    let Demo {
        field_name_foo,
        #[cfg(feature = "diagnostics")]
            field_name_baz: _,
        field_name_bar,
        field_name_tux,
    } = Demo {
        field_name_foo: (),
        field_name_bar: (),
        #[cfg(feature = "diagnostics")]
        field_name_baz: (),
        field_name_tux: (),
    };
}
@ytmimi
Copy link
Contributor

ytmimi commented Sep 20, 2023

Thanks for reaching out. I also tested this with rustfmt 1.5.3-nightly (f4b80cac 2023-06-30) and reproduced the issue.

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

No branches or pull requests

2 participants