This repository was archived by the owner on Dec 29, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
[regression] "code":-32603,"message":"Reformat failed to complete successfully" #1397
Copy link
Copy link
Closed
Description
This error is generally emitted when there is a typo in the code causing a compilation error but also happens on "clean" code in rare cases. rustfmt is able to deal with those typos and format the code correctly, while RLS fails.
Minor errors (ie typo in ident) should not cause formatting to fail. Those errors are common during refactoring while one needs to keep the code tidy and formatted to be able to reason about it.
rustfmt run from the command line does work in these cases.
This behaviour was introduced in a recent update and has heavily disrupted my workflow. Error was not present in rls 1.34.0 (0d6f53e 2019-02-14)
If this is deemed a feature, please introduce a config option to disable it.
Trivial repro:
Cargo.toml
[package]
name = "test_format"
version = "0.1.0"
authors = ["Nicola Orrù <nigu.orru@gmail.com>"]
[dependencies]
src\main.rs
fn main() {
const i: i32 = 0.5;
println!("Hello, world!");
}
[t=1555338926023] LSP4E to org.eclipse.corrosion.rls:
{"jsonrpc":"2.0","id":"60","method":"textDocument/formatting","params":{"textDocument":{"uri":"file:[...]src/main.rs"},"options":{"tabSize":4,"insertSpaces":false}}}
[t=1555338926023] org.eclipse.corrosion.rls to LSP4E:
{"jsonrpc":"2.0","error":{"code":-32603,"message":"Reformat failed to complete successfully"},"id":"60"}
$ rls --cli
Initializing (look for `progress[done:true]` message)...
> 1: InitializeResult {
capabilities: ServerCapabilities {
text_document_sync: Some(
Kind(
Incremental,
),
),
hover_provider: Some(
true,
),
completion_provider: Some(
CompletionOptions {
resolve_provider: Some(
true,
),
trigger_characters: Some(
[
".",
":",
],
),
},
),
signature_help_provider: None,
definition_provider: Some(
true,
),
type_definition_provider: None,
implementation_provider: Some(
Simple(
true,
),
),
references_provider: Some(
true,
),
document_highlight_provider: Some(
true,
),
document_symbol_provider: Some(
true,
),
workspace_symbol_provider: Some(
true,
),
code_action_provider: Some(
Simple(
true,
),
),
code_lens_provider: Some(
CodeLensOptions {
resolve_provider: Some(
false,
),
},
),
document_formatting_provider: Some(
true,
),
document_range_formatting_provider: Some(
false,
),
document_on_type_formatting_provider: None,
rename_provider: Some(
Simple(
true,
),
),
color_provider: None,
folding_range_provider: None,
execute_command_provider: Some(
ExecuteCommandOptions {
commands: [
"rls.applySuggestion-21192",
"rls.deglobImports-21192",
],
},
),
workspace: None,
},
}
{"jsonrpc":"2.0","method":"window/progress","params":{"id":"progress_1","title":"Building"}}
{"jsonrpc":"2.0","method":"window/progress","params":{"id":"progress_1","message":"test_format cfg(test)","title":"Building"}}
{"jsonrpc":"2.0","method":"window/progress","params":{"id":"progress_1","message":"test_format","title":"Building"}}
{"jsonrpc":"2.0","method":"window/progress","params":{"done":true,"id":"progress_1","title":"Building"}}
{"jsonrpc":"2.0","method":"window/progress","params":{"id":"progress_0","title":"Indexing"}}
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"E0308","message":"mismatched types\n\nexpected i32, found floating-point number\n\nnote: expected type `i32`\n found type `{float}`","range":{"end":{"character":23,"line":1},"start":{"character":20,"line":1}},"severity":1,"source":"rustc"}],"uri":"file:///home/norru/Projects/ivt/test_format/src/main.rs"}}
{"jsonrpc":"2.0","method":"window/progress","params":{"done":true,"id":"progress_0","title":"Indexing"}}
> format src/main.rs
{"jsonrpc":"2.0","error":{"code":-32603,"message":"Reformat failed to complete successfully"},"id":2}
>
Reacted by Emil Lauridsen, Diana, Ronan Jouchet, Maël Naccache Tüfekçi, EFanZh, Akira Nitta, Sakti Dwi Cahyono and Mick Dekkers
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]test[/-][+]Minor errors cause formatting to fail in cases where `rustfmt` would succeed[/+]Xanewok commentedon Mar 17, 2019
Thanks for the report! Could you provide a small code example if possible, please?
norru commentedon Mar 17, 2019
I'll see what I can do. Unfortunately, I cannot share the actual project.
EDIT: added simple repro case to description.
norru commentedon Mar 18, 2019
It is however very easy to reproduce:
norru commentedon Mar 28, 2019
Unable to reproduce for technical reasons (not verified fixed!)
norru commentedon Mar 28, 2019
rls 1.34.0 (0d6f53e 2019-02-14)because it predates the regressionrls 1.35.0 (90f7ab0 2019-03-17)because of [regression]can't find cratewhen crate is referred to via relative path (in a workspace) #1409nightlybecause ofbstaletic commentedon Mar 30, 2019
I can consistently reproduce this problem.
Cargo.toml:src/main.rs:Issuing
textDocument/formattingfails with-32603error code and this is in the log:But if line 11 (the one that only says
build_and thus contains the error) is removed from themain.rs, thetextDocument/formattingrequest succeeds.main.rs:norru commentedon Mar 30, 2019
@bstaletic Thanks for the repro, doesn't seem to be exactly the same issue as I see though.
Does it work if you
cargo fmtorrustfmtthe project?bstaletic commentedon Mar 30, 2019
In that case, sorry for the noise. Should I open a new issue?
Both of those commands worked correctly.
norru commentedon Mar 30, 2019
@bstaletic. If it is the case, then it's fine - If
rlsfails formatting whenrustfmtworks then it's the same bug. Thanks!norru commentedon Apr 15, 2019
This is still open as for
nightly-2019-04-14norru commentedon Apr 15, 2019
On
nightly-2019-04-14The minimal example is astonishingly trivial. I find hard to believe nobody has managed to reproduce this.
Cargo.toml
src\main.rs
[-]Minor errors cause formatting to fail in cases where `rustfmt` would succeed[/-][+]"code":-32603,"message":"Reformat failed to complete successfully"[/+][-]"code":-32603,"message":"Reformat failed to complete successfully"[/-][+][regression] "code":-32603,"message":"Reformat failed to complete successfully"[/+]norru commentedon May 16, 2019
After updating to
rustc 1.36.0-nightly (7158ed9cb 2019-05-15)+rls 1.36.0 (5b8e99b 2019-05-01)this is now a 100% failure meaning that it is no longer possible to format within the Corrosion IDE andcargo fmtis the only way to do it.Running
cargo cleanin the affected projects and restarting the IDE makes the problem not 100% again (basically back to the initial report).nox commentedon Jun 10, 2019
I can confirm that this happens.
Barugon commentedon Jul 10, 2019
This is happening to me in vscode. Specifically, I was doing the Amethyst pong tutorial and when I got to the step that adds
systems/paddle.rsto the project, I wasn't able to format that file. Up until then, I had no problem.mredaelli commentedon Jul 11, 2019
Same here in vim using coc.nvim
norru commentedon Jul 15, 2019
Still open in
rls 1.37.0 (124483d 2019-07-01)Xanewok commentedon Jul 15, 2019
This will be alleviated by #1513
norru commentedon Sep 6, 2019
Fixed by #1533 and #1513