I use cross to develop for different targets. The
cross command essentially replaces
cargo with the same arguments.
There is an extra extension to make it possible to easily control targets for rust analyzer:
I also configure my check command to be
clippy. But there is a problem: The check command always run
cargo <whatever my check sub command is> and I would like it to instead run
cross interchanging like this, there is unfortunately a bug (or limitation) that the incremental build functionality stops working and the entire project is rebuilt every time.
A solution would be to always use
cross. But I can't find such a setting in Rust Analyzer extension? Is there a way to get around this?
A really hacky way to work around this would be to create a shell script called
cargo that just calls into
cross, then make sure the script is on your
$PATH (e.g. by overriding
did you try the
[[rust-analyzer.check.overrideCommand]]rust-analyzer.check.overrideCommand (default: `null`)::
Override the command rust-analyzer uses instead of `cargo check` for
diagnostics on save. The command is required to output json and
should therefore include `--message-format=json` or a similar option
(if your client supports the `colorDiagnosticOutput` experimental
capability, you can use `--message-format=json-diagnostic-rendered-ansi`).
If you're changing this because you're using some tool wrapping
Cargo, you might also want to change
If there are multiple linked projects, this command is invoked for
each of them, with the working directory being the project root
(i.e., the folder containing the `Cargo.toml`).
An example command would be:
For some reason I missed this when trying to find a solution.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.