Skip to content

Suboptimal formatting of let-bound chains of || with == inside them. #4492

Open
@RalfJung

Description

@RalfJung

Input

                    let assign_to_field =
                        context == PlaceContext::MutatingUse(MutatingUseContext::Store)
                        || context == PlaceContext::MutatingUse(MutatingUseContext::Drop)
                        || context == PlaceContext::MutatingUse(MutatingUseContext::AsmOutput);

Output

                    let assign_to_field = context
                        == PlaceContext::MutatingUse(MutatingUseContext::Store)
                        || context == PlaceContext::MutatingUse(MutatingUseContext::Drop)
                        || context == PlaceContext::MutatingUse(MutatingUseContext::AsmOutput);

Expected output

                    let assign_to_field =
                        context == PlaceContext::MutatingUse(MutatingUseContext::Store)
                        || context == PlaceContext::MutatingUse(MutatingUseContext::Drop)
                        || context == PlaceContext::MutatingUse(MutatingUseContext::AsmOutput);

The reformatting actually makes the code look worse (linebreak in the middle of one of the comparisons) without a need (such as a line being too long).

Meta

  • This is via ./x.py fmt in current rustc

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