rust-lang / rust-lang/rust-analyzer

rust-analyzer.cargo.allTargets = true doesn't include "test = false" integration test targets

Open
#19,395 8 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

I'm finding that rust-analyzer doesn't run in and provide diagnostics/completes/etc for non-default integration test targets (see code snippet below for what exactly I mean by that). I would expect it do do so when the allTargets setting in the title is enabled, but even beyond that, I can't seem to find any way to instruct it to explicitly inspect such targets (which would be a good option to have too). I have these targets use test = false because I don't want them to run with my normal unit tests as part of cargo test. Instead, I have a small wrapper binary that I call via an alias that passes the right --features and --test flags to cargo test in order to explicitly run it (it also spawns a server process my integration tests depend on).

So:

  1. Should allTargets include these? If so, currently that seems to be bugged, if no, why not?
  2. Is there some existing setting to tell rust-analyzer to include this target? If not, can one be added?

I can confirm that if I remove test = false from the [[test]] section in my Cargo.toml for this test that rust-analyzer starts working as expected.

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

rust-analyzer 1.85.0 (4d91de4 2025-02-17)

rustc version: (eg. output of rustc -V)
rustc 1.85.0 (4d91de4e4 2025-02-17)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)

Zed

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

repository link (if public, optional): (eg. rust-analyzer)
https://github.com/temporalio/sdk-core -- specifically here

code snippet to reproduce:

[[test]]
name = "some_integ_test"
path = "tests/some_integ_test.rs"
test = false
required-features = ["some-non-default-feature"]

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 [[test]] entry in temporalio/sdk-core's core/Cargo.toml, with test = false and required-features, and compare it with tests/some_integ_test.rs when test = true. Then trace rust-analyzer's Cargo target handling for the allTargets setting. Done means the target receives diagnostics and completions through allTargets, or an explicit supported setting is defined and documented.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.