Repository navigation
fix(rust): scan doctest code in doc comments for inputs - #230
Merged
Merged
Conversation
FredApps
marked this pull request as ready for review
November 17, 2026 17:18
I, FredApps <[email protected]>, hereby add my Signed-off-by to this commit: 4c0e634 Signed-off-by: FredApps <[email protected]>
…xed list rustSourceInputs listed the flags it ORs. DiffCI#250 (also in DiffCI#258) adds runsPrograms to rustInputs; merged after this PR, the doctests' value would have been dropped and typecheck would fail, with no textual conflict to warn about. Combining the flags by key keeps both PRs correct in either order. Signed-off-by: FredApps <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #222
Doc comments (
///,//!,/** */,/*! */) are now scanned for code that rustdoc runs as doctests, and that code goes through the same input scan as ordinary code. A doctest thatinclude_str!s or reads another crate's file now becomes an edge or a fallback, exactly as it would in a#[test].docCommentsfinds doc comments while skipping strings, character literals and plain comments, so a"/**"glob isn't mistaken for one.doctestCodekeeps fenced blocks that rustdoc treats as Rust: no language,rust, or only doctest attributes. It also keeps indented blocks, and removes the hidden-line#prefix.rustSourceInputsmerges both scans. InanalyzeRustMetadata, only the one call site changes.The new test covers line, inner and block doc comments, an indented block, an
include_str!and a computedinclude!in doctests. It also checks that prose,text/tomlblocks and plain//comments name no inputs.Effect on real code: I ran it over 56,314
.rsfiles from 1,815 registry crates. 11 files newly fall back, most of them for real reasons (computed includes in doctests). Three aretyped-path'sbr"\"doctests, which #220 fixes. Scanning is still linear: about 300 ms for a 2 MB file, end to end.Validation (Linux, Node 22, Cargo 1.100):
npm run typecheckand the Rust test files (tests/repo/rust-*.test.ts,tests/planner/rust-command.test.ts) pass. The new test fails onmainand passes here.Hidden conflict with #250 / #258 (fixed here): #250 adds a
runsProgramsflag torustInputs. The oldrustSourceInputslisted its flags by name, so merging #250 after this PR would have failed typecheck with no textual conflict.rustSourceInputsnow ORs every boolean flag of the code and doctest scans by key, so the two merge in either order. Checked: typecheck and the Rust tests pass on this branch alone and merged with #258.