custom inner attributes remove source view for module
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
When a procedural macro is used as an inner attribute (via #![feature(custom_inner_attributes)]), rustdoc omits that module's source file from the HTML source browser view. When clicking the source view of that module, it jumps to the mod module; declaration. The json output also reports the wrong definition span (the one for the mod module;).
Here's a minimal reproducer:
- In
macros/src/lib.rs:// In macros/src/lib.rs #[proc_macro_attribute] pub fn identity(_args: TokenStream, input: TokenStream) -> TokenStream { input } - In
src/lib.rs(of course withmacros.path = "./macros"in[dependencies]):#![feature(custom_inner_attributes, proc_macro_hygiene)] pub mod demo; - In
src/demo.rs:#![macros::identity] //! This is the demo module!
Expected Outcome
- When clicking on the
sourcebutton inside the docs of thereproducer::demomodule, I expected to be brought to the file view ofsrc/demo.rs, but it instead showssrc/lib.rs. - The source view sidebar does not contain
src/demo.rsat all. - The json output reports that the span of
reproducer::demois inside ofsrc/lib.rs
When the inner attribute macro is removed, all of these behave correctly again.
Actual Output
cat target/doc/reproducer.json | jq '.index'
{
"0": {
"id": 0,
"crate_id": 0,
"name": "demo",
"span": {
"filename": "src/lib.rs",
"begin": [
2,
1
],
"end": [
2,
14
]
},
"visibility": "public",
"docs": "This is the demo module!",
"links": {},
"attrs": [],
"deprecation": null,
"inner": {
"module": {
"is_crate": false,
"items": [],
"is_stripped": false
}
}
},
"1": {
"id": 1,
"crate_id": 0,
"name": "reproducer",
"span": {
"filename": "src/lib.rs",
"begin": [
1,
1
],
"end": [
2,
14
]
},
"visibility": "public",
"docs": null,
"links": {},
"attrs": [
{
"other": "#[attr = Feature([custom_inner_attributes#0, proc_macro_hygiene#0])]"
}
],
"deprecation": null,
"inner": {
"module": {
"is_crate": true,
"items": [
0
],
"is_stripped": false
}
}
}
}
Version
rustdoc 1.98.0-nightly (f428d123a 2026-06-19)
@rustbot label +F-custom_inner_attributes
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
Reproduce the issue with macros/src/lib.rs, src/lib.rs, and src/demo.rs, then inspect rustdoc's generated source view and JSON output for the demo module. Done means src/demo.rs appears in the source sidebar, the source link opens that file, and the JSON span points to it rather than src/lib.rs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100