Skip to content

Conversation

@asukaminato0721
Copy link
Contributor

@asukaminato0721 asukaminato0721 commented Dec 20, 2025

fix #19103

Added a has_compile_fail flag to RunnableKind::DocTest so we remember when a runnable’s docs include compile-fail snippets; the doc parser now scans every fenced block (handling indentation and both comma/whitespace separators) to capture that metadata while still allowing edition tags such as 2024.

When building Cargo commands we drop the default --nocapture argument for doc tests that have compile‑fail snippets, preventing cargo test output from showing expected compiler errors as if the test failed.

Added a regression test that confirms compile‑fail doctests are still exposed as runnables and that the new flag is set.

@asukaminato0721 asukaminato0721 marked this pull request as ready for review December 20, 2025 04:50
Copilot AI review requested due to automatic review settings December 20, 2025 04:50
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 20, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issue #19103 where "Run Doctest" lens shows up on compile_fail tests. The fix adds tracking of compile_fail attributes in doc test blocks to prevent confusing compiler error output when running doctests with the default --nocapture flag.

Key Changes:

  • Added has_compile_fail boolean field to RunnableKind::DocTest to track whether any compile_fail blocks exist in the docstring
  • Refactored doc test parsing to scan all fenced code blocks and detect compile_fail attributes while maintaining support for edition tags
  • Modified cargo command builder to filter out --nocapture flag when compile_fail blocks are present

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/ide/src/runnables.rs Added has_compile_fail field to RunnableKind::DocTest, refactored has_runnable_doc_test to runnable_doc_test_info with enhanced parsing logic that handles both comma and whitespace-separated attributes, added regression test
crates/rust-analyzer/src/target_spec.rs Made extra_test_binary_args mutable and added logic to filter --nocapture flag for doctests with compile_fail blocks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cargo_args.push("--doc".to_owned());
executable_args.push(test_id.to_string());
if *has_compile_fail {
extra_test_binary_args.retain(|arg| arg != "--nocapture");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this here is a good solution for the issue? At least, reading through it the problem is that vscode recognizes the successful failure as a failure when it shouldn't due to the problem matchers. Unsure how we can make this work though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Run Doctest" lens shows up on compile_fail tests

3 participants