Skip to content

Tracking issue: check write mode follow-up #2536

Closed
@nrc

Description

@nrc

Described in #1977 (comment) This would be used mainly by CI and would emit exit code 0 if no formatting was necessary and 1 if formatting is necessary. The output to stdout would be the same as diff mode.

Mentoring instructions:

Implementation

  • add check to the rustfmt bin options
  • implement check like diff mode, but with different exit codes (will require refactoring or exit code handling, I think)
  • document check mode
  • add a test - I think this would have to be an ad hoc unit test in the binary.

Follow ups

  • change exit codes as described in Audit exit codes #1977 (comment) (it might be easier to do this whilst refactoring the exit code handling, since I think it will lead to some code being removed).
  • make the newline character in diffs optional (i.e., it requires a command line arg)
  • use check mode for our tests (I'm not sure if this is possible, but might work)
  • use check mode in the CI for an official Rust project - one of the RLS helper crates might be a good place to start. Document what is necessary in the Rustfmt repo.
  • align cargo fmt exit codes with rustfmt ones (this might be trivial once this issue is fixed)
  • implement/verify other parts of the proposal in Audit exit codes #1977 (comment)

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