Skip to content

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

Closed
@ehuss

Description

@ehuss

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)

Metadata

Metadata

Assignees

Labels

A-doctestsArea: Documentation tests, run by rustdocA-markdown-parsingArea: Markdown parsing for doc-commentsC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions