Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Confusing error message when rustfmt cannot format otherwise valid code #433

@NoraCodes

Description

@NoraCodes

I have Format On Save on in VSCode, and it is a reflex of mine to save a lot. Often, when I do, I get output like the following. Output from the tool automatically switches my bottom Toolbox view away from the Terminal or Problems tab, and is thus is quite annoying.

Request textDocument/formatting failed.
  Message: Reformat failed to complete successfully
  Code: -32603 

Previously reported (in error?) as a bug on rustfmt at rust-lang/rustfmt#1851

Some further poking shows that this is likely a bug in RLS, as rustfmt fails to format the code:

$ rustfmt src/lexer/mod.rs; echo $?
Rustfmt failed at /home/leo/Projects/relox/src/lexer/mod.rs:1: line exceeded maximum length (maximum: 100, found: 138) (sorry)
Rustfmt failed at /home/leo/Projects/relox/src/lexer/lexerror.rs:57: line exceeded maximum length (maximum: 100, found: 104) (sorry)
Rustfmt failed at /home/leo/Projects/relox/src/lexer/datatypes.rs:7: line exceeded maximum length (maximum: 100, found: 110) (sorry)
Rustfmt failed at /home/leo/Projects/relox/src/lexer/datatypes.rs:31: line exceeded maximum length (maximum: 100, found: 117) (sorry)
Rustfmt failed at /home/leo/Projects/relox/src/lexer/datatypes.rs:75: line exceeded maximum length (maximum: 100, found: 122) (sorry)

3  # 3 = Code is valid, but it is impossible to format it properly

Perhaps RLS could report these errors better?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions