-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Formatting with rustfmt no longer works in rustc repository #10209
Comments
Just to avoid an obvious issue, does it behave the same if you put in an absolute path? Can you strace/dtrace the language server to see if it spawns something? |
Yeah that does not seem to make a difference.
I have no idea how to do that.^^ The entire language server business is a total black box to me. |
Well, on Linux you find the PID of the language server (I don't think you have proc macros enabled on rustc, but take the parent process if there's two of them), then run |
How do I do that? I know nothing about how RA works, and Your suggested
|
When I add
And then something starts reading rustfmt configuration, so I guess it did launch something?
|
I managed to set RA_LOG=info and found this in the output:
That is a wrong assumption, the file parses just fine. Silently dropping non-zero exit codes like this also does not seem very robust... |
When I run rustfmt manually on the given file, I get this output:
So I guess RA is right after all, this is a parse error... but it shouldn't be, rustc parses fine, just rustfmt does not. I'll report this with rustfmt, but this was a lot harder to debug than I think it has to be. Anyway, thanks for your help! One proposal that would make this easier to debug: could the "Rust Analyzer Language Server" output just always print the rustfmt output when there was a rustfmt error (even without setting any env var or so)? That way at least there'd be a slightly more discoverable way to get to this error message, without having to figure out a nice UI to expose this this with in the regular editor. |
Oh, maybe there actually is a RA bug here: @ehuss points out that with Now, I don't know if RA sees the same rustfmt error that I see in my manual invocation, so maybe this is all a red herring. Sadly the RA_LOG output neither prints the full rustfmt command that is executed nor the output it got back (as far as I could see). |
Yes, indeed that was it. :) This fixes the problem:
I guess so far I was just lucky that rustfmt in the rustc tree worked even with the 2015 edition? Thought it might make sense if RA added that flag even with |
Yeah, sorry for that, it was
It does, but it's shortened:
The But yeah, we could log the |
That is not RA_LOG output, that is strace output you quoted, which is a lot harder to get by.
extraArgs doesn't help when you want to use a different rustfmt binary but still let RA control the flag passed to rustfmt. |
Exactly. I guess the idea is that you might have a completely different formatter (not rustfmt). But fixing the rustc dev guide should help. |
Log rustfmt parsing errors as warnings We unconditionally pass an edition parameter to rustfmt, for some crates this might fail rustfmt so instead of swallowing the error, at least Log it on a level that is logged by default so users won't be completely confused about it. See for context #10209 Closes #10209
We unconditionally pass an edition parameter to rustfmt, for some crates this might fail rustfmt so instead of swallowing the error, at least Log it on a level that is logged by default so users won't be completely confused about it. See for context rust-lang#10209 Closes rust-lang#10209
We unconditionally pass an edition parameter to rustfmt, for some crates this might fail rustfmt so instead of swallowing the error, at least Log it on a level that is logged by default so users won't be completely confused about it. See for context rust-lang#10209 Closes rust-lang#10209
It used to be the case that formatting worked even inside the rustc repo, but something seems to have broken since I last tried that (a few weeks ago). Now, when I ask RA to format a file in the rustc repo, nothing at all happens -- I see no error or other kind of feedback, and nothing gets formatted. (So there are at least 2 bugs here: formatting doesn't work, and error reporting also doesn't work.)
My workspace config is:
I verified that
./build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt
still exists. I can't see any rustfmt-related messages in the various "output" categories.I updated vscode (v.1.60.0 now), which did not help. It says there are no extension updates available. RA has version v0.2.735.
The text was updated successfully, but these errors were encountered: