rust-lang / rust-lang/rust-analyzer

Explicitly select members in a workspace

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

Nobody has claimed this yet.

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

Description

If there is a workspace with multiple members (crate1, crate2) which use the same crate dependency (crate3) but crate1 uses a feature feature_a and crate2 doesn't, then rust-analyzer won't Identify code under #[cfg(not(feature = "feature_a"))], even though crate2 might use such code.

In order to solve this straightforwardly, it would be nice to have the option to either

  1. Make rust-analyzer discover only members in default-members.
  2. Define explicit members for rust-analyzer to discover, similar to the rust-analyzer.linkedProjects setting.

Example Cargo.toml:

[workspace]
resolver = "2"
members = [
    "crate1",
    "crate2",
]

default-members = [
    "crate2"
]

[workspace.dependencies]
crate3 = { path = "crate3", default-features = false }

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 workspace shown in the issue and inspect rust-analyzer's workspace-member discovery and Cargo configuration handling. The work is complete when rust-analyzer can explicitly select discovered members, including the proposed default-members behavior, and cfg analysis reflects the selected members.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.