rust-lang / rust-lang/rust-analyzer

proc macro very slow and eventually broken when use `cargo workspace` instead of `rust-analyzer.linkedProjects`

Open
#15,839 0 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 version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

0.3.1713-standalone

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

rustc 1.73.0

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


Prev
  • use cargo workspace

https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html

  • use "rust-analyzer.rust.analyzerTargetDir": "/path/to/gittop/build/RA" To prevent RA pollute real build cache

https://github.com/rust-lang/rust-analyzer/issues/15057#issuecomment-1777062345

I found

  • RA very very unacceptably slow

after RA very long spinning

  • cannot click to jump to source code of proc macro source

  • code generated by proc macro does not show up in completion

  • complain generated method does not exists

Cur
  • remove cargo workspace

  • use rust-analyzer.linkedProjects with array of literal path, because when use array of glob path

[ERROR rust_analyzer::main_loop] FetchWorkspaceError:
rust-analyzer failed to load workspace: Failed to load the project at /path/to/repo/packages/**/*/Cargo.toml: Failed to query rust toolchain version at /path/to/repo/packages/**/*, is your toolchain setup correctly?: cd "/path/to/repo/packages/**/*" && "cargo" "--version" failed: No such file or directory (os error 2)
  • keep "rust-analyzer.rust.analyzerTargetDir": "/path/to/gittop/build/RA"

I found

  • RA acceptable

  • proc macro works correctly

  • completion works correctly

Suggestion
  • or "rust-analyzer.disable-cargo-workspace-and-only-use-its-glob-result-as-linkedProjects-input": true

  • or rust-analyzer.rust.analyzerTargetDir accept glob string as input

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 by reproducing the reported behavior with a Cargo workspace, rust-analyzer.linkedProjects using literal and glob paths, and rust-analyzer.rust.analyzerTargetDir. Compare workspace loading time, proc-macro navigation, completion, and generated-method diagnostics; done means the workspace configuration no longer causes the reported failures.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.