Fix rustfmt during builds by reading edition from manifest#1533
Fix rustfmt during builds by reading edition from manifest#1533Xanewok merged 3 commits intorust-lang:masterfrom
Conversation
Xanewok
left a comment
There was a problem hiding this comment.
Thanks for the PR!
I have to admit that fixing the formatting was high on my to-do list. I believe #1513 already addresses most of the pain points, however input file detection should be pushed further back to parsing if possible. Right now we can't do it inside after_parsing due to internal rustc bits (disambiguator calculation, which we need, happens after).
A best effort fallback like the one here will be good for the users so that's a 👍 from me
| } | ||
|
|
||
| /// Read edition from the manifest | ||
| fn edition_from_manifest<P: AsRef<Path>>(manifest_path: P) -> Option<Edition> { |
There was a problem hiding this comment.
I'm not thrilled about placement of this function here but maybe it's self-contained enough that it's not a problem.
There was a problem hiding this comment.
It's a private function that's only used here so it seems ok to me. I'd imagine it won't be hard to move or replace later. But if you can think of a better place to put it, along with the test, then sure.
Co-Authored-By: Igor Matuszewski <Xanewok@gmail.com>
|
Thank you! |
Update RLS Most importantly this includes: * Collect file -> edition mapping after AST expansion ([#1513](rust-lang/rls#1513)) (enabled by #62679) * Fix rustfmt during builds by reading edition from manifest ([#1533](rust-lang/rls#1533)) Which fixes the annoying problem where users couldn't format via RLS while `cargo fmt` worked. The beta cut-off is drawing near and I'd like to make sure this lands before then.
Not being able to run rustfmt when code is building has been getting on my nerves a bit.
This pr adds a fallback to cover cases where
files_to_cratesis empty causing format requests to fail as we can't currently determine the edition to use. In these cases the manifest is read directly to determine edition.Fixes #1148