rustdoc-json: linked required trait methods are missing in `index` field
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
rustdoc generates different URLs for required trait methods (trait.Trait.html#tymethod.method) and provided trait methods (trait.Trait.html#method.method).
For a CLI like cargo-sync-rdme that emulates rustdoc's intra-doc link resolution, it is important to determine whether the linked method is required or provided.
When using the rustdoc JSON output, this can be determined from .index[id].inner.function.has_body (true for provided methods, false for required methods).
However, some items referenced by intra-doc links do not have corresponding .index[id] entry.
I tried this code:
//! [`Iterator::next`]
$ rustdoc +nightly-2026-08-05 foo.rs --output-format json -Z unstable-options
$ jq < doc/foo.json | head -51
I expected to see this happen: The JSON output contains a .index["0"] entry.
Instead, this happened: The JSON output does not contain a .index["0"] entry.
{
"root": 1,
"crate_version": null,
"includes_private": false,
"index": {
"1": {
"id": 1,
"crate_id": 0,
"name": "foo",
"span": {
"filename": "foo.rs",
"begin": [
1,
1
],
"end": [
1,
23
]
},
"visibility": "public",
"docs": "[`Iterator::next`]",
"links": {
"`Iterator::next`": 0
},
"attrs": [],
"deprecation": null,
"stability": null,
"const_stability": null,
"inner": {
"module": {
"is_crate": true,
"items": [],
"is_stripped": false
}
}
}
},
"paths": {
"0": {
"crate_id": 2,
"path": [
"core",
"iter",
"traits",
"iterator",
"Iterator",
"next"
],
"kind": "function"
},
Without the corresponding .index entry, there is no way to determine whether the method is required or provided using the rustdoc JSON output alone.
Meta
rustc --version --verbose:
rustdoc 1.99.0-nightly (1ed2df61a 2026-08-04)
binary: rustdoc
commit-hash: 1ed2df61a19042f231709eb05d032ae9e2cb2084
commit-date: 2026-08-04
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8
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 the provided foo.rs snippet and the rustdoc nightly command, then inspect how the JSON index and paths entries represent the linked Iterator::next method. Trace rustdoc's JSON generation for intra-doc links and verify the output can distinguish required from provided trait methods. Done means the relevant linked method has enough JSON data to determine whether it is required or provided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100