FR: make disabling `format_generated_files` work with stdin input
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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