rust-lang / rust-lang/rust-analyzer

`buildBeforeRestart` does not trigger rebuild of project in tests

Open
#18,763 1 comment 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

rust-analyzer version: rust-analyzer version: 0.3.2228-standalone (fa4a40bbe8 2024-12-22)

rustc version: rustc 1.83.0 (90b35a623 2024-11-26)

editor or extension: VSCode

relevant settings:

{
    "rust-analyzer.debug.buildBeforeRestart": true
}

code snippet to reproduce:

// Run Test | Debug
#[test]
fn my_test() {
   ...
}

Description of the Issue:

When debugging a Rust test in VSCode by clicking the "Debug" button above the test function, and then subsequently hitting the "Restart" button in the debug controls, rust-analyzer does not appear to recompile the code. This means that if changes have been made to the code since the initial debug launch, those changes are not reflected when the debug session is restarted.

The rust-analyzer.debug.buildBeforeRestart setting is set to true, which according to the documentation, should trigger a rebuild before restarting a debug session. However, this is not the observed behavior.

Steps to Reproduce:

  1. Have a Rust project with a test function like the example provided.
  2. Ensure "rust-analyzer.debug.buildBeforeRestart": true is set in your VSCode settings (preferably workspace settings).
  3. Click the "Debug" button above the test function to start a debug session.
  4. Make a change to the code that would affect the test's execution
  5. Click the "Restart" button in the debug controls.
  6. Observe that the debug session starts without recompiling the code, and the changes made in step 4 are not reflected in the restarted debug session.

Expected Behavior:

When the "Restart" button is clicked during a debug session, and rust-analyzer.debug.buildBeforeRestart is set to true, rust-analyzer should trigger a recompilation of the project before starting the new debug session, ensuring that the latest code changes are included.

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 VSCode test-debugging flow with rust-analyzer.debug.buildBeforeRestart enabled, then trace the setting's handling through the debug restart path. Done means restarting a debug session recompiles the project and uses changes made after the initial launch.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools, testing-qa
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.