Skip to content

Automatic cargo fmt after cargo fix #12608

Open
@kpreid

Description

@kpreid

Problem

In a project which uses rustfmt, running cargo fix sometimes leaves the source files with non-canonical formatting (e.g. around removed imports), which can be surprising (especially if one is using editor format-on-save) and is an extra step to fix.

Proposed Solution

Add a configurable setting which causes cargo fix to also have the effect of cargo fmt after applying fixes.

This should be a setting, not solely a command-line flag, so that it is automatic and convenient for projects which choose to use rustfmt — contributors won't have to remember to type it.

It might make sense to frame the setting as a general “autoformat” rather than specific to cargo fix, in case any future commands also edit source code and should have the same behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-fixS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions