Skip to content

Feature request: Specify priority of small heuristics / line-breaking rules #6057

Open
@BTOdell

Description

@BTOdell

I have noticed that rustfmt seems to prioritize breaking chains before it'll break on function arguments.

For example:

let value =
    obj.func(&long_struct.arg1, long_struct.arg2, long_struct.arg3, true);

is preferred instead of:

let value = obj.func(
    &long_struct.arg1,
    long_struct.arg2,
    long_struct.arg3,
    true,
);

I have tried so hard to find configuration settings that will prefer the second style when a line is too long (according to max_width, chain_width, or fn_call_width). A quick way to see this behavior is to set all 3 of these config values to the same number (80).

Could a new config option be introduced (perhaps called small_heuristics_priority) that takes an array of the names of the other options in the order that they should be applied to fix the line?

small_heuristics_priority = [ "fn_call_width", "chain_width" ]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions