RLS is giving the following error message when working on a project with an ARM target:
E0463: can't find crate for
testcan't find crate
Reproduction:
cargo new --bin app
cd app
mkdir .cargo
echo '[build]' > .cargo/config
echo 'target = "thumbv7m-none-eabi"' >> .cargo/config
echo '#![no_std]' > src/main.rs
rls --cli
I believe this is because there is no test crate for the ARM target.
Is there a way to avoid this error?
There are several other SO posts on E0463 but appears those are configuration errors. The above is purely an RLS question. It's causing my editor to display errors and not do code complete, etc.
This is because of Cargo trying to build test&benchs for your binary targets when you pass --all-targets(which is done by default by rust-analyzer)
To solve this, you can try rewrote your main target, disable it's tests by adding this to Cargo.toml:
[[bin]]
name = "your_crate_name"
path = "src/main.rs"
test = false
doctest = false
bench = false
If you include:
{
"rust-analyzer.cargo.target": "<your target architecture>",
"rust-analyzer.check.allTargets": false,
}
and you are still getting the can't find crate for 'test' error on vscode, see if you have the Cargo extension by panicbit installed (https://marketplace.visualstudio.com/items?itemName=panicbit.cargo). It also uses cargo check on save without regards to the target architecture.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With