-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix "Run Doctest" lens shows up on compile_fail tests #19103 #21305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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_failboolean field toRunnableKind::DocTestto 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
--nocaptureflag 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.
d639195 to
9f34417
Compare
| 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"); |
There was a problem hiding this comment.
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
9f34417 to
7bfa62e
Compare
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.