VScode error detection doesn't work with #[no_std] for OSdev

Hello !

I am trying to follow phil's tutorial on making an OS in rust.
This will not be my first one but it will be the first one I made in rust.

The problem is that VScode (my IDE) say

when I'm trying to redefine the panic_handler (witch I must do since I can't use the std library)

This must be a error from the language checker since the program compile very well.
I use the rust-analyser module from VScode.
I'm on windows 64bit, and I use the nightly release of rust.

I tried using this .vscode/settings.json file:

    "rust.all_targets": false,
    "rust-analyzer.cargo-watch.allTargets": false,
    "rust-analyzer.cargo-watch.arguments": [
    "rust-analyzer.checkOnSave.overrideCommand": [

The commands I use to build the project (just as stated in the tutoriel)
cargo build --target thumbv7em-none-eabihf

My program (in case, we never know, but it's the same as the tutoriel)


use core::panic::PanicInfo;

/// This function is called on panic.
fn panic(_info: &PanicInfo) -> ! {
    loop {}

pub extern "C" fn _start() -> ! {
    loop {}

Lastly, I don't know if it is useful, but the result of the rustc --version --verbose command :

rustc 1.48.0-nightly (8876ffc92 2020-10-02)
binary: rustc
commit-hash: 8876ffc9235dade728e1fbc4be4c85415fdd0bcd
commit-date: 2020-10-02
host: x86_64-pc-windows-msvc
release: 1.48.0-nightly
LLVM version: 11.0

How can I correct this please ?

PS: This is my first post, let me know if I miss anything.


rust-analyzer.cargo-watch doesn't exist anymore. Try using the following config:

    "rust-analyzer.cargo.allTargets": false,
    "rust-analyzer.checkOnSave.allTargets": true, // not sure if this one is needed
    "rust-analyzer.checkOnSave.overrideCommand": [

I got a lot of other problems with the RLS. For exemple, my cargo.toml file behing underline with red and this error message:

build failed
error: could not compile `spin`

To learn more, run the command again with --verbose.

While my cargo.toml file is totally valid.

When I remove the dependency from my cargo.toml file there is another error :

can't find crate for `core`

can't find crate

note: the `x86_64-genos-12501628466901653157` target may not be installed

While I got a custom target in my project (here's .cargo/config.toml)

build-std = ["core", "compiler_builtins"]
build-std-features = ["compiler-builtins-mem"]

target = "targets/x86_64-genos.json"

So I couldn't test your settings :no_mouth:

Everything is compiling right. Should I change IDE for this project (thinking of Atom) or should I remove rls / rust-language support from VScode for this project ?

At the end, I just change to using Atom for this project, witch is a better idea since I can use custom build and test command more easely now.

Thank you anyway !

Hey !

So, I just re-tried the rust-analyser package from VScode and it worked (on the same project).
Maybe it was an update, maybe I did it wrong the first time, but the thing is that it is now working !

Thank you for your answer @bjorn3.

Solved !

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.