Skip to content

struct patterns eagerly split across lines in the default configuration #2062

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

Closed
nikomatsakis opened this issue Oct 16, 2017 · 1 comment
Closed

Comments

@nikomatsakis
Copy link

nikomatsakis commented Oct 16, 2017

Unless struct patterns contain only shorthand variables, they seem to almost always split across multiple lines -- I find this a bit over-eager. For example:

fn foo() {
    let Answer { subst, ambiguous: _ } = some_struct;
}

formats to:

fn foo() {
    let Answer {
        subst,
        ambiguous: _,
    } = some_struct;
}

which seems unnecessary. I tend to use a lot of struct unpacking like that as a way to ensure that if new fields are added I will get compliation errors. Spreading things across multiple lines here makes my code quite spread out vertically.

Sorry if I'm duplicating things! I did a brief search over the issues and didn't find an obvious duplicate.

Version: 0.2.8-nightly ( )
Configuration: None

@nikomatsakis nikomatsakis changed the title struct patterns are awfully eager to split across lines in the default configuration struct patterns eagerly split across lines in the default configuration Oct 16, 2017
@topecongiro
Copy link
Contributor

Whether to put struct/variant literals and patterns in a single line is controlled by struct_lit_width and struct_variant_width. Their default values are 18 and 35. You could set higher values to allow longer patterns to stay on the same line. We probably should make the default larger, and that is likely to be discussed in #1974.

@nrc nrc closed this as completed Nov 2, 2017
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

3 participants