Skip to content

Commit f0b15e2

Browse files
bors[bot]dozzman
andauthored
Merge #10157
10157: Add section on configuring compilation errors when using `rust-project.json` r=matklad a=dozzman When using `rust-project.json` to specify the project workspace, flychecks are disabled. It is not mentioned that they can be re-enabled by specifying a custom checking command using the `checkOnSave.overrideCommand` configuration. This additional section makes it clear that using `rust-project.json` disables flychecks and how to enable them either using `cargo check` (as an example) or (more likely) a custom command which emits json error messages. Further information can be found at this forum thread: https://users.rust-lang.org/t/rust-analyzer-doesnt-show-cargo-check-compilation-errors-warnings-when-using-rust-project-json/64412 Co-authored-by: Dorian Peake <[email protected]>
2 parents 0bc8e2a + a2bc57c commit f0b15e2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/user/manual.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,15 @@ See https://github.com/rust-analyzer/rust-project.json-example for a small examp
616616

617617
You can set `RA_LOG` environmental variable to `rust_analyzer=info` to inspect how rust-analyzer handles config and project loading.
618618

619+
Note that calls to `cargo check` are disabled when using `rust-project.json` by default, so compilation errors and warnings will no longer be sent to your LSP client. To enable these compilation errors you will need to specify explicitly what command rust-analyzer should run to perform the checks using the `checkOnSave.overrideCommand` configuration. As an example, the following configuration explicitly sets `cargo check` as the `checkOnSave` command.
620+
621+
[source,json]
622+
----
623+
{ "rust-analyzer.checkOnSave.overrideCommand": ["cargo", "check", "--message-format=json"] }
624+
----
625+
626+
The `checkOnSave.overrideCommand` requires the command specified to output json error messages for rust-analyzer to consume. The `--message-format=json` flag does this for `cargo check` so whichever command you use must also output errors in this format. See the <<Configuration>> section for more information.
627+
619628
== Security
620629

621630
At the moment, rust-analyzer assumes that all code is trusted.

0 commit comments

Comments
 (0)