Rust-analyzer stops working with build-std - Solved

Hi, hope this is the correct place for this:

I'm trying to a work on a project that requires a custom platform; thus build-std is required. Once I put

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

into .cargo/config.toml and reload VS Code, rust-analyzer fails during/after 'Indexing' and the VS Code button for rust-analyzer in the status bar goes faded-yellow with a small warning symbol, and the mouse-over dialogue says

Click to reload.

Static analysis would not work while rust-analyzer was in this state (type annotations would be displayed though in some instances).

I was able to reproduce this bug consistently by creating a new folder, cargo init-ing it, add the config file, and launch VS Code in the project dir.

I am using Windows 10, with rust nightly (for the build-std support). I haven't found anything online though and I presume a bug like this would be noticed quickly thus I presume their may be something else awry, if any more information is needed, ask away.

Just to be clear, does everything else work? E.g. running cargo check?

In any case, you can probably get more detailed error information by going to View -> Output and selecting "Rust Analyzer Language Server" from the drop down list.


Hi, thanks for the quick response!

cargo check turned up nothing unexpected, however, viewing the output of RALS did indicate the problem:

[ERROR rust_analyzer::reload] failed to switch build data: rust-analyzer failed to run build scripts:
error: -Zbuild-std requires --target

I added this to my config file and it worked:

target = "x86_64-unknown-uefi.json"

Thank you very much, I was unaware I could access output from VS Code extensions.
Have a good day further.

Edit: should I mark this as the solution?

1 Like


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.