rust-lang / rust-lang/rust-analyzer

Make `cargo.features` a crate-level config

Open
#18,114 8 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

workspace
|-crate1
|-crate2
|-crate3
|_crate4

crate 2 and 4 have a feature called "example_feature" that i want to enable for RA,
so using a workspace setting is a no go, because RA will complain that crates 1 and 3 don't have this feature
creating rust-analyzer.toml in crate 2 and 4's root and adding cargo.features = ["example_feature"] has no effect,
however if i replace it with rust-analyzer.cargo.features = ["example_feature"], RA will complain that this is an invalid key that doesn't exist. So it reads the file but when it reads a correct key it doesn't apply that? I have no machine-wide or workspace or user overrides (using VSC right now but same happens in Vim).

Originally posted by @vaqxai in https://github.com/rust-lang/rust-analyzer/issues/13529#issuecomment-2345668435

What the title indicates is just a way to resolve this issue although making such a change is not wanted. This issue is just to discuss and shed a light on what we can do

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 behavior described for crate-level rust-analyzer.toml files in crates 2 and 4, comparing cargo.features with rust-analyzer.cargo.features in VS Code or Vim. Done means determining and documenting a supported way to apply a feature only to selected workspace crates without invalid-key errors or affecting crates that lack the feature.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.