You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use --config-path instead of changing working directory when calling rustfmt #23412
In the past, rustfmt didn't implement proper directory walking semantics with the --config-path=<dir> parameter. So the following hack of changing the working directory of the rustfmt subprocess is used instead:
let current_dir = match text_document.uri.to_file_path(){
Ok(mut path) => {
// pop off file name
if path.pop() && path.is_dir(){ path }else{ std::env::current_dir()? }
}
However, the above hack is preventing me from doing the following IDE-specific --config-path override in the rustup repo, because the resolution of --config-path is always relative to the working directory:
After fixing rustfmt so that it has the correct directory walking semantics in rust-lang/rustfmt#7115, I'd love to offer a patch here regarding the above rust-analyzer logic, by replacing the hack with a properly-constructed --config-path= parameter if one doesn't exist already.
Concerns
The replacement should be in theory quite simple but it potentially involves rust-analyzer working with a sufficiently old rustfmt where that parameter was flawed.
Please feel free to let me know if there are any compatibility concerns to be considered and/or any prior art I can look into.
Makes sense but I do wonder if it's not too early given this was only fixed a few days ago. I'd say, after this reaches stable we can use this after guarding on the Rust version.
Also note that there are several places we call rustfmt.
Activity
ChayimFriedman2 commentedon Sep 24, 2026
Makes sense but I do wonder if it's not too early given this was only fixed a few days ago. I'd say, after this reaches stable we can use this after guarding on the Rust version.
Also note that there are several places we call rustfmt.