Skip to content
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

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

Open
ehuss opened this issue Mar 28, 2025 · 0 comments
Open

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

ehuss opened this issue Mar 28, 2025 · 0 comments
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
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
Status: No status
Development

No branches or pull requests

4 participants