rust-lang / rust-lang/rust-analyzer

Does features in [dependencies] in the Cargo.toml will be enabled by RA?

Open
#17,230 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The following toml settings is part of a rust project. Note that it specify the features in the vm-memory dependency.

[package]
name = "vmm"
version = "0.1.0"
authors = ["Amazon Firecracker team <firecracker-devel@amazon.com>"]
edition = "2021"
license = "Apache-2.0"

[dependencies]
vm-memory = { version = "0.13.1", features = ["backend-mmap", "backend-bitmap"] }

I have set the rust-analyzer.cargo.features to default value (i.e. []) and DO NOT enable allFeatures.

When I edit the .rs source code files in the project directory, everything works fine, and the RA seems to recognize the features in Cargo.toml, i.e., it enables the "backend-mmap" and "backend-bitmap".

But when I jump into the source code files in the dependency crate (e.g., files in ~/.cargo/registry/src/......), which is outside the project directory, the RA DO NOT enable "backend-mmap" and "backend-bitmap". RA seems use the rust-analyzer.cargo.features for those files outside the project directory, instead of using that in [dependencies] section in Cargo.toml.

My questions are:

  1. Why features in [dependencies] not enable when I jump into source code in the dependency crate? Is there something I missed?
  2. Because I do not want to enable all features in the dependencies (which means I do not want to enable rust-analyzer.cargo.allFeatures), how can RA only enables the features in the [dependencies] section in Cargo.toml when I jump into the source code files in that crate?

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

Reproduce the behavior using the provided Cargo.toml dependency features and the rust-analyzer.cargo.features and rust-analyzer.cargo.allFeatures settings. Compare feature resolution for project files with files under ~/.cargo/registry/src, then determine whether the observed dependency behavior is expected. Done means documenting the resolution or identifying a focused change needed to make dependency features behave as requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience, tooling
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.