Open aleksanderd opened 5 years ago
I just started learning Rust with VSCode and rls-vscode plugin and got the same error. To check what is the error message, click View > Open View and write Output (panel) then press Enter. Running Ubuntu Budgie 18.04.2 LTS rustc 1.33.0 (2aa4c46cf 2019-02-28) rustfmt 1.0.1-stable (be13559 2018-12-10) cargo 1.33.0 (f099fe94b 2019-02-12) rustup 1.17.0 (069c88ed6 2019-03-05)
Unfortunately, this is an issue with RLS itself. That's high on the list so hopefully this will be soon resolved
Is the upstream issue https://github.com/rust-lang/rls/issues/1397?
Any update about this issue?
I don't get an error, but I format does nothing on my end either
I got the same error.
Hi there
Issue a "cargo fmt" from within your project dir. This will give more information why formatting can not be used. In my case my toolchain missed the cargo-fmt.exe. after that it worked from commandline and from within vscode
I have the same issue and "cargo fmt" works fine, no error when I run from the command line. It used to work until very recently within VSCode too, now I get the error reported above every time.
Same here, cargo fmt
works but running Format Document
gives me this error:
[Error - 4:45:32 PM] Request textDocument/formatting failed.
Message: Reformat failed to complete successfully
Code: -32603
I am using
rustc 1.37.0 (eae3437df 2019-08-13)
rustfmt 1.3.0-stable (d3345024 2019-06-09)
cargo 1.37.0 (9edd08916 2019-08-02)
I also noticed that the RLS [building]
spinner in vscode's status bar never changes and there is no output except the above error when I save.
I have one machine running VS Code 1.37 that works properly, and another running 1.38.1 that does not work, so it looks like it was a regression from the earlier issue.
A simple warning for the fellow newbies who are just starting to learn Rust like me. It seems that you need a Cargo.toml file in your project so that rls-vscode
formats your code.
It seems that you need a Cargo.toml file in your project
Not working for me even with a Cargo.toml
file :( I'm using VS Code 1.40.2 on macOS 10.15 - not getting any output displayed or logged when I run format, though nothing is happening, and using rustfmt
from the command line works fine.
Edit: working after all - Prettier was being used incorrectly due to being set as the default formatter in my VS Code settings
I get the same error when rustfmt fails. In my case this seems to be related to this issue from rustfmt. In particular this code cause rustfmt to fail:
match var.name{
name if
//BAD COMMENT causes fmt error
name.contains("smth")
// other comment
| name.contains("smth else") => {true}
_ => false,
}
The caused rls error is quite silent. Initially I checked the settings and updated rust with rustup (which was of no help). Manualy formating with rustfmt leads to this error (hence the link to the rustfmt issue):
rustfmt /path/to/file.rs
error[internal]: left behind trailing whitespace
--> /path/to/file.rs:157:157:19
|
157 | name if
| ^
|
warning: rustfmt has failed to format. See previous 1 errors.
Since I do no longer expect this to get fixed, I propose to install statiolake.vscode-rustfmt
. So far, I have no compatibility issues with the official rust extension, and get format on save :)
Using rust-analyzer (the stand-alone extension) should also work.
If your rust-analyzer does not work try adding this to your settings.json
"[rust]": { "editor.defaultFormatter": "rust-lang.rust-analyzer" },
Hi!
I can not get vscode to format code, the error is:
rustftm via cmd formats same file ok.
what to check or configure?
thank you!
rustc 1.33.0 (2aa4c46cf 2019-02-28) rustfmt 1.0.1-stable (be13559 2018-12-10) cargo 1.33.0 (f099fe94b 2019-02-12) rustup 1.17.0 (069c88ed6 2019-03-05)