Skip to content

Doctests confuse multi-paragraph footnote with indented code block #139064

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

Closed
ehuss opened this issue Mar 28, 2025 · 0 comments · Fixed by #139592
Closed

Doctests confuse multi-paragraph footnote with indented code block #139064

ehuss opened this issue Mar 28, 2025 · 0 comments · Fixed by #139592
Assignees
Labels
A-doctests Area: Documentation tests, run by rustdoc A-markdown-parsing Area: Markdown parsing for doc-comments C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ehuss
Copy link
Contributor

ehuss commented Mar 28, 2025

I tried this code:

/// Example
///
/// Footnote with multiple paragraphs[^multiple]
///
/// [^multiple]:
///     One
///
///     Two
///
///     Three
pub fn add(left: u64, right: u64) -> u64 {
    left + right
}

This is a footnote with multiple paragraphs. It renders correctly in the documentation:

Image

However, running as a doctest fails:

running 1 test
test src/lib.rs - add (line 8) ... FAILED

failures:

---- src/lib.rs - add (line 8) stdout ----
error: expected `;`, found `Three`
 --> src/lib.rs:9:4
  |
3 | Two
  |    ^ help: add `;` here
4 |
5 | Three
  | ----- unexpected token

error[E0425]: cannot find value `Three` in this scope
 --> src/lib.rs:11:1
  |
5 | Three
  | ^^^^^ not found in this scope

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0425`.
Couldn't compile the test.

failures:
    src/lib.rs - add (line 8)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.03s

Somehow the doctest collector seems to not understand that there are footnotes. I would expect this to be ignored.

Meta

rustdoc 1.87.0-nightly (a2e63569f 2025-03-26)
@ehuss ehuss added the C-bug Category: This is a bug. label Mar 28, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 28, 2025
@ehuss ehuss added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-doctests Area: Documentation tests, run by rustdoc and removed C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 28, 2025
@ehuss ehuss added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 28, 2025
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 28, 2025
@fmease fmease added the A-markdown-parsing Area: Markdown parsing for doc-comments label Mar 30, 2025
@camelid camelid self-assigned this Apr 9, 2025
camelid added a commit to camelid/rust that referenced this issue Apr 9, 2025
We should enable these to avoid misinterpreting uses of the extended
syntax as code blocks. This happens in practice with multi-paragraph
footnotes, as discovered in rust-lang#139064.
camelid added a commit to camelid/rust that referenced this issue Apr 9, 2025
We should enable these to avoid misinterpreting uses of the extended
syntax as code blocks. This happens in practice with multi-paragraph
footnotes, as discovered in rust-lang#139064.
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 10, 2025
rustdoc: Enable Markdown extensions when looking for doctests

Fixes rust-lang#139064.

We should enable these to avoid misinterpreting uses of the extended
syntax as code blocks. This happens in practice with multi-paragraph
footnotes, as discovered in rust-lang#139064.
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 10, 2025
rustdoc: Enable Markdown extensions when looking for doctests

Fixes rust-lang#139064.

We should enable these to avoid misinterpreting uses of the extended
syntax as code blocks. This happens in practice with multi-paragraph
footnotes, as discovered in rust-lang#139064.
@bors bors closed this as completed in d7171bc Apr 10, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 10, 2025
Rollup merge of rust-lang#139592 - camelid:doctest-md-opts, r=notriddle

rustdoc: Enable Markdown extensions when looking for doctests

Fixes rust-lang#139064.

We should enable these to avoid misinterpreting uses of the extended
syntax as code blocks. This happens in practice with multi-paragraph
footnotes, as discovered in rust-lang#139064.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc A-markdown-parsing Area: Markdown parsing for doc-comments C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
Development

Successfully merging a pull request may close this issue.

5 participants