rust-lang / rust-lang/rust-analyzer

Warn about missing features in workspace crates.

Open
#16,187 3 comments 1 reaction 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

Repro

https://github.com/LouisGariepy/workspace_crate_missing_features.

Story

User creates a project with crate A the requires dependency D with feature foo.

Later, the user creates crate B, which also needs D, but they forget to add feature foo. Due to the way features are resolved in workspaces, they can still use items gated behind foo (because of crate A's enabling foo).

If the user tries to build crate B standalone (cargo build -p B), then Cargo will report missing items. Same if they decide to move crate B out of the workspace.

Resolution

R-A could give a warning about missing features in workspace crate where a feature is enabled only by other crates. This avoid pitfalls over rebuilding a single crate in a workspace, or moving a crate out of a workspace.

I don't know of feasible that is though, knowing which features are provided by other workspace crates but not declared locally seems difficult.

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 reproduction project at https://github.com/LouisGariepy/workspace_crate_missing_features and compare the workspace build with cargo build -p B standalone. Investigate how workspace feature resolution distinguishes features enabled by other crates from features declared locally. Done means a warning reliably identifies missing local features without producing false positives.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.