rust-analyzer: `#![no_std]` can't find crate for `test` in vs code
Hi,
Same issue as #3297 but the solution there (for vim) does not seem to work for vs code on windows unfortunately.
Here is my setup:
.cargo\config file:
[build]
target = "thumbv7m-none-eabi"
.vscode\settings.json file:
{
"rust.target": "thumbv7m-none-eabi",
"rust.all_targets": false
}
src\main.rs file:
#![no_std]
#![no_main]
#[entry]
fn main() -> ! {
loop {}
}
rust-analyzer version: 0.2.108 vs code version: 1.43.2 operating system: Windows 10 rustc 1.42.0 (b8cedc004 2020-03-09) stable
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 46 (8 by maintainers)
Commits related to this issue
- Add proper cargo/rust-analyzer scan settings for vscode, solves https://github.com/rust-analyzer/rust-analyzer/issues/3801#issuecomment-681923193 for me — committed to brainstorm/bbtrackball-rs by brainstorm 4 years ago
- fix #![no_std] can't find crate for test in vs code https://github.com/rust-analyzer/rust-analyzer/issues/3801 — committed to Wazzaps/bold by Raz-B 3 years ago
- Fix a problem with VSCode rust-analyzer extension You need to specify the target platform or you get some errors. https://github.com/rust-lang/rust-analyzer/issues/3801 — committed to dcaponi/raw-dog by bcr 2 years ago
Thanks for the update @lnicola. Yes it broke but your new settings work, cheers!
Looks like these keys keep changing. In the latest rust analyzer, it is this one for me
Thank you @lnicola, that worked! Here is the required settings file if anyone else comes across this post:
.vscode\settings.json file:
Please reopen issue
Not working for me either. Config:
I was having the same issue and after a little poking around I don’t think this is an issue with the rust-analyzer extension, but actually the
panicbit.cargoextension. It appears to runcargo checkon its own, which is running into issues with not properly knowing the target (I think), so it complains about not being able to find thetestcrate. If you’re having the same problem but the fixes here aren’t working, I’d check if that extension is installed, try disabling it, and see if the error persists.I am getting this error again. Is anyone else? I didn’t use to get it with
Well, it’s in the manual: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/manual.adoc#vs-code.
Thanks ❤️ ,
rustup updatefixed it ! It sure feels like a hack though…ok, sounds like the issue is now resolved, at least there’s a documentation trail for this here now 😃
Well done all of the above and checked the global settings config and can’t spot anything obviously wrong so I’ll just keep it broken.
below is my global vscode settings file.
I cloned your repo and got the error message to go away by adding a .vscode/settings.json file in your project root with
VS Code needed a restart for rust-analyzer to pick it up.
So the file structure is (I’ve included the important files):
You were missing the settings.json file.
It seems to not be working for me.
still results in the test error in vscode.