Skip to content

Support --assume-filename to resolve .rustfmt.toml for stdin files #5792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
afq984 opened this issue Jun 20, 2023 · 1 comment
Closed

Support --assume-filename to resolve .rustfmt.toml for stdin files #5792

afq984 opened this issue Jun 20, 2023 · 1 comment

Comments

@afq984
Copy link

afq984 commented Jun 20, 2023

Support an --assume-filename-like option to let rustfmt resolve rustfmt.toml if the input is passed from stdin.

clang-format has a --assume-filename option which let it knows where to find the format config file when the payload is passed from stdin:

--assume-filename=<string>     - Set filename used to determine the language and to find
                                   .clang-format file.
                                   Only used when reading from stdin.

This would allow meta-formatters to pass file content that doesn't exist in the file system (for our use case: git history), while still letting rustfmt to figure out which format config to use.

Caveat: if the rustfmt.toml config file changes in history, this doesn't work, but I think it happens rarely enough.

@calebcartwright
Copy link
Member

Thanks for reaching out and sharing! This is something that's actually been requested previously, discussed, and partially implemented, so I'm going to close this one to minimize bifurcation of discussion.

However, I really like the specifics of the proposal, so I will also cross-link the details you've brought forward in those other threads

@calebcartwright calebcartwright closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants