Rustdoc standalone attribute
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
According to
//! ```standalone_crate
//! let location = std::panic::Location::caller();
//! assert_eq!(location.line(), 4);
//! ```
not sure where 4 comes from its always 3 for me, however i propose it should be 1
This example can be solved without a standalone crate by using include!
inc.rs
{
let location = std::panic::Location::caller();
assert_eq!(location.line(), 3);
}
{let location = std::panic::Location::caller();
assert_eq!(location.line(), 1);}
fn main() {
include!("inc.rs")
}
Running this passes since it seems that the include! macro forwards panic info to the right file.
Version
rustdoc 1.88.0 (6b00bc388 2025-06-23)
binary: rustdoc
commit-hash: 6b00bc3880198600130e1cf62b8f8a93494488cc
commit-date: 2025-06-23
host: x86_64-unknown-linux-gnu
release: 1.88.0
LLVM version: 20.1.5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the standalone_crate example from the rustdoc documentation-tests page with the reported Rust 1.88.0 toolchain, then compare its panic line with the include! example. Inspect rustdoc's standalone_crate handling and determine whether the implementation or the documented expected line is wrong. Done means the behavior and documentation agree, with a regression test covering the reported case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100