Rust-analyzer and the standard library workspace

Rust moved its standard library into a workspace about 13 months ago. I've experienced a weird condition in offline installations of rust-analyzer and VSCode where I lose the prelude. E.g., I have to import Some from core in order for RA to deduce the type of Some(1_i32). This problem goes away if I remove the Cargo.toml from the workspace root of the standard library (rust/library/Cargo.toml). I have seen this as recently as with Rust 1.89.0 and 0.4.2609 using the RA installed by rustup.

This seems like a "me" problem and not a bug. What can I do to debug this and get more introspection into how rust-analyzer is failing?

1 Like

Have you followed the setup instructions for rustc/std development using rust-analyzer?

I'm not trying to extend rustc or the standard library.

Set the environment variable RA_LOG=project_model=debug. You can do that by setting rust-analyzer.server.extraEnv on VSCode, other editors may have other ways. Then post rust-analyzer's logs here (in VSCode they're in Output -> rust-analyzer Language Server).

Thanks, the debug logs pointed out what was wrong. I have a weird development environment on this machine and I needed a dependency of std.

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.