How to activate unstable feature restricted_std in rust-analyzer?

Moderators’ note:
This question was also asked on stack overflow. Keep an eye out for additional discussions or solutions posted over there.

I'm trying to compile for esp32c6 (riscv32imac-unknown-none-elf). Actually, cargo build runs, but when I save the file rust analyzer checks it ans complains:

error[E0658]: use of unstable library feature 'restricted_std'
   --> /home/lz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/formatters/
225 |     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> ::std::fmt::Result {
    |                                                       ^^^^^^^^^^^^^^^^^^
    = help: add `#![feature(restricted_std)]` to the crate attributes to enable

As you see, it's complaining about a feature in the std lib, which is strange. I added #![feature(restricted_std)] to but the error is in the standard library where I cannot add this feature.

I also tried

    "rust-analyzer.cargo.cfgs": {
        "build-std": ["core", "std", "alloc", "panic_abort"],
        "restricted_std": true
    "rust-analyzer.check.allTargets": false,
    "": "riscv32imac-unknown-none-elf",

and other variations without success. Also tried


in rust-analyzer.toml.


~/project1$ rustup toolchain install riscv32imac-unknown-none-elf
error: invalid toolchain name: 'riscv32imac-unknown-none-elf'

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.