9

RLS is giving the following error message when working on a project with an ARM target:

E0463: can't find crate for test can'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.

puritii
  • 1,069
  • 1
  • 7
  • 18
  • Issues with running RLS in no_std projects is what pushed me to switch over to Rust Analyzer. I also want to note that RLS isn't being actively developed and is poised to be superceded by RA. – Ivan C Jan 14 '21 at 16:21
  • 3
    @IvanC I am getting the same error with rust-analyzer. – puritii Jan 14 '21 at 16:41
  • I checked and I also have to add ```[unstable] build-std = ["core"]``` to .cargo/config. – Ivan C Jan 14 '21 at 17:42
  • @IvanC Does this mean you have to use unstable? – puritii Jan 14 '21 at 17:51
  • 1
    In general you have to use nightly if you want to cross-compile. – Ivan C Jan 14 '21 at 17:55
  • Unfortunately I'm getting this with rust-analyzer despite using the `build-std = ["core"]` as well as nightly, and in fact despite including the `checkOnSave.allTargets=false` setting. Sigh. – Peter Hansen Sep 30 '22 at 02:58
  • Update: it was failing because I wasn't modifying languages.toml properly. Adding a `.helix/languages.toml` in my project root, with a `[language.config]` section inside `[[language]] name="rust" ` with just that setting fixed it. – Peter Hansen Sep 30 '22 at 04:00

2 Answers2

0

Found this in a github issue:

In the file .vscode/settings.json:

{
    "rust-analyzer.check.allTargets": false,
    "rust-analyzer.check.extraArgs": [
        "--target",
        "<your target architecture>"
    ]
}

Replace <your target architecture> with the right target.

Boiethios
  • 38,438
  • 19
  • 134
  • 183
0

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.

N8-W
  • 1