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 Initialization: item_brace_style AlwaysNextLine #2105

Open
rickvanprim opened this issue Nov 1, 2017 · 5 comments
Open

Struct Initialization: item_brace_style AlwaysNextLine #2105

rickvanprim opened this issue Nov 1, 2017 · 5 comments
Labels
only-with-option requires a non-default option value to reproduce poor-formatting

Comments

@rickvanprim
Copy link

With item_brace_style = "AlwaysNextLine":

Expected

let foo = Foo
{
  a = 1,
  b = 2,
};

Actual

let foo = Foo {
  a = 1,
  b = 2,
};
@nrc nrc added only-with-option requires a non-default option value to reproduce poor-formatting labels Nov 1, 2017
@topecongiro
Copy link
Contributor

Should item_brace_style change the brace position of struct literal? It is an expression, not an item (at least in theory).

@nrc
Copy link
Member

nrc commented Nov 5, 2017

It is an expression, not an item

Good point! I'm not really sure. Probably not, since items and expressions are sometimes formatted differently. OTOH, I don't really want to add another option for this and I think a person who likes the 'brace on its own line' style might expect both items and expressions to be formatted the same way.

@rickvanprim
Copy link
Author

Any new thoughts on this?

@ytmimi
Copy link
Contributor

ytmimi commented Jul 20, 2022

@calebcartwright is this a bug or intended behavior? Also item_brace_style no longer exists. To simulate the original issue we can set brace_style=AlwaysNextLine and struct_lit_single_line=false

input

fn main() {
    let foo = Foo {
        a: 1,
        b: 2,
    };
}

output

fn main()
{
    let foo = Foo {
        a: 1,
        b: 2,
    };
}

@ytmimi
Copy link
Contributor

ytmimi commented Jul 20, 2022

Linking tracking issue for brace_style (#3376). Although struct_lit_single_line (#3357) doesn't cause any issues i'm go to link it just in case since I feel like we'd need to figure out what to do about the interaction between brace_style=AlwaysNextLine and struct_lit_single_line=true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
only-with-option requires a non-default option value to reproduce poor-formatting
Projects
None yet
Development

No branches or pull requests

4 participants