Skip to content

Confusing spread of width configurations #1984

Closed
@alexheretic

Description

@alexheretic

It is great that rustfmt is configurable, however I found the amount of width configurations & defaults initially confusing. I expected the fmt rules to work on a single max width, so all wrapping logic would work against that.

I actually avoided using rustfmt for a while, as I mistakenly thought it couldn't handle one-line struct patterns etc. Now I realise it can, but has a separate width to keep to. Silly me. But perhaps this can be simpler?

After grepping through the docs I now have, for my personal projects

array_width = 100
chain_one_line_max = 100
comment_width = 100
max_width = 100
fn_call_width = 100
single_line_if_else_max_width = 100
struct_lit_width = 100
struct_variant_width = 100
# other rules

Which seems to work for now, so thank you. However, this also seems a little fragile & ugly. I'd really prefer to declare it once, perhaps having all rules match max_width unless explicitly configured otherwise.

Or some new rule:

max_width_that_applies_to_everything_and_causes_errors_if_you_try_to_use_the_other_ones = 100

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions