-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Incorrect span used for doctests defined using #[doc(include)]
or #[doc = include_str!("...")]
#81070
Comments
#[doc = include_str("...")]
#[doc = include_str!("...")]
Hmm, this is especially interesting given that the error message has
However, this bug also occurs with old-school
I wonder if the reason the |
#[doc = include_str!("...")]
#[doc(include)]
or #[doc = include_str!("...")]
Ok, I've looked into this and found the underlying issue. Rustdoc actually uses environment variables as a side channel to tell rustc, but the code is really messy and the filename and line number seem to be obtained separately: rust/src/librustdoc/doctest.rs Lines 327 to 328 in 7d6f948
I'm still looking into ways to get the filename based on the span of the docs themselves rather than the attribute they're in. |
…eGomez rustdoc: Refactor doctest collection and running code This code previously had a quite confusing structure, mixing the collection, processing, and running of doctests with multiple layers of indirection. There are also many cases where tons of parameters are passed to functions with little typing information (e.g., booleans or strings are often used). As a result, the source of bugs is obfuscated (e.g. rust-lang#81070) and large changes (e.g. rust-lang#123974) become unnecessarily complicated. This PR is a first step to try to simplify the code and make it easier to follow and less bug-prone. r? `@GuillaumeGomez`
Given these two files:
ducks.rs
ducks.md
When I run
rustdoc --test ducks.rs
, I get an error:The error message is correct. However, the position (
ducks.rs:14:9
) is invalid. I would expect it to reference either the originalinclude_str!
call, or (preferred) the snippet in the Markdown file.Meta
rustc --version --verbose
:cc #78835
The text was updated successfully, but these errors were encountered: