Skip to content

doctest line number is incorrect if used with #![doc = include_str!()] #127893

Open
@ProfFan

Description

@ProfFan

I tried this code:

#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]

/// ```no_run << line 23
///  panic!("nooo");
///  ```
pub struct XXXXYYYY<A, B> {
...
}

I expected to see this happen: the included doctests show the line number of the include statement.

Instead, this happened:

running 2 tests
test src/lib.rs - XXXXYYYY (line 23) - compile ... ok
test src/lib.rs - (line 23) ... FAILED

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (032be6f7b 2024-07-16)
binary: rustc
commit-hash: 032be6f7bbe091c7dfa29f115e94b9cc9bae1758
commit-date: 2024-07-16
host: aarch64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7
Backtrace

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsArea: Documentation tests, run by rustdocC-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

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions