rust-lang / rust-lang/rust-analyzer

rust analyzer handle multi target_arch incorrectly, and should provide reload config command

Open
#19,147 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

rust analyzer handle multi target_arch incorrectly

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

rust-analyzer version: 1.86.0-nightly (b3b368a 2025-01-05) [/home/vscode/.rustup/toolchains/nightly-2025-01-06-x86_64-unknown-linux-gnu/bin/rust-analyzer]

rustc version: (eg. output of rustc -V)

rustc 1.86.0-nightly (b3b368a18 2025-01-05)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)

VSCode

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

See below

repository link (if public, optional): (eg. rust-analyzer)

code snippet to reproduce:

Given code

core::arch::wasm32::unreachable();

Given layout and vscode config

        "rust-analyzer.linkedProjects": [
            "Cargo.toml",
            "path/to/wasm/crate/Cargo.toml"
        ],

When path/to/wasm/crate/.cargo/config.toml

target = [
    "wasm32-unknown-unknown",

Given code works fine.

core::arch::wasm32::unreachable();

When path/to/wasm/crate/.cargo/config.toml changed to

target = [
    "wasm32-unknown-unknown",
    "x86_64-unknown-linux-gnu",

After painfully slow full RA server restart, RA complain.

error[E0433]: failed to resolve: could not find `wasm32` in `arch`
  --> src/lib.rs:39:17
   |
39 |     core::arch::wasm32::unreachable();
   |                 ^^^^^^ could not find `wasm32` in `arch`


Change back to

target = [
    "wasm32-unknown-unknown",
    # "x86_64-unknown-linux-gnu"

After painfully slow full RA server restart, RA does not complain.

Given code works fine.

core::arch::wasm32::unreachable();

Conclusion

  • RA should handle multi target_arch correctly

  • RA should also provide reload config command, because fully restart server is painfully slow

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided linkedProjects setup and the wasm32/x86_64 target list in path/to/wasm/crate/.cargo/config.toml, reproducing the incorrect resolution after changing targets. Read the rust-analyzer configuration handling around project reloads; done means multi-target code resolves correctly and configuration changes no longer require a full server restart.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.