Skip to content

Make sure we don't lose default struct value when formatting struct#134668

Merged
bors merged 1 commit intorust-lang:masterfrom
compiler-errors:default-struct-value-fmt
Dec 23, 2024
Merged

Make sure we don't lose default struct value when formatting struct#134668
bors merged 1 commit intorust-lang:masterfrom
compiler-errors:default-struct-value-fmt

Conversation

@compiler-errors
Copy link
Copy Markdown
Contributor

The reason why rust-lang/rustfmt#6424 broke when #129514 landed is because the parser now successfully parses default struct values. That means that where we used to fail in rewrite_macro_inner:

let ParsedMacroArgs {
args: arg_vec,
vec_with_semi,
trailing_comma,
} = match parse_macro_args(context, ts, style, is_forced_bracket) {

... we now succeed, and we now proceed to format the inner struct as a macro arg. Since formatting was never implemented for default struct values, this means that we’ll always rewrite the struct to exclude the default value.

This PR makes it so that we simply don’t rewrite struct fields if they have a default value.

r? @ytmimi

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants