rust-lang / rust-lang/rustfmt

FR: make disabling `format_generated_files` work with stdin input

Open
#6,620 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

Currently, rustfmt formats generated files if they are passed via stdin, even if format_generated_files=false. I think it's nice to have an issue tracking this problem specifically.

See https://github.com/rust-lang/rustfmt/issues/5080#issuecomment-1500232131 for an overview with a few more details, and https://github.com/rust-lang/rustfmt/issues/5172 for the reason for the current behavior.

IMO, if format_generated_files=false, rustfmt should act like cat on generated files passed via stdin. I'm unsure whether there are any issues with such a plan. This is already what happens when disable_all_formatting=true.


I'll link to https://github.com/rust-lang/rustfmt/issues/5137 which I think is spiritually related; if that were fixed, it would be a workaround for this issue as well (and vice-versa, as far as generated files are concerned, which is currently my main use-case for #5137).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing rustfmt's stdin handling and the interaction between format_generated_files=false and generated-file detection. Read the linked discussions in issues 5080, 5172, and 5137 for the current behavior and constraints; done means generated files received through stdin are passed through unchanged when formatting is disabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.