rust-lang/rust · error

no resolutions for a doc link

Error message

no resolutions for a doc link

What it means

Fires in `get_doc_link_resolutions` (decoder.rs:1924). Rustdoc encodes, per definition, the resolution of intra-doc links so downstream doc builds can reuse them; the decoder `.expect()`s an entry in the `doc_link_resolutions` table. A missing entry means a definition was queried for doc-link resolutions that never had them encoded.

Source

Thrown at compiler/rustc_metadata/src/rmeta/decoder.rs:1924

                }
            })
            .clone()
    }

    fn get_attr_flags(&self, index: DefIndex) -> AttrFlags {
        self.root.tables.attr_flags.get(self, index)
    }

    fn get_intrinsic(&self, tcx: TyCtxt<'_>, index: DefIndex) -> Option<ty::IntrinsicDef> {
        self.root.tables.intrinsic.get(self, index).map(|d| d.decode((self, tcx)))
    }

    fn get_doc_link_resolutions(&self, tcx: TyCtxt<'_>, index: DefIndex) -> DocLinkResMap {
        self.root
            .tables
            .doc_link_resolutions
            .get(self, index)
            .expect("no resolutions for a doc link")
            .decode((self, tcx))
    }

    fn get_doc_link_traits_in_scope(
        &self,
        tcx: TyCtxt<'_>,
        index: DefIndex,
    ) -> impl Iterator<Item = DefId> {
        self.root
            .tables
            .doc_link_traits_in_scope
            .get(self, index)
            .expect("no traits in scope for a doc link")
            .decode((self, tcx))
    }
}

impl CrateMetadata {

View on GitHub (pinned to 7088e4b63a)

Solutions

  1. `cargo clean` and run `cargo doc` from scratch so doc metadata is encoded consistently.
  2. Build dependencies with doc metadata enabled (avoid `--no-deps` for the crates you document).
  3. Align toolchain versions across the doc build graph.
  4. Clean-build doc ICE -> file against rustdoc with the crate that triggers the link resolution query.
Defensive patterns

Strategy: validation

Validate before calling

# Ensure dependencies carry doc metadata before running cargo doc
cargo clean
cargo doc --document-private-items   # builds deps with doc metadata

Try / catch

cargo doc || { cargo clean && cargo doc; }

Prevention

When it happens

Trigger: Running `cargo doc` on a crate whose dependency was compiled without doc metadata (`--no-deps`, or built as a non-doc rlib) but is now being asked for doc-link resolutions; cross-version reuse where the doc-link table layout changed; querying resolutions for a definition that is not a doc-link target.

Common situations: Mixing `cargo build` artifacts with `cargo doc` runs in a shared `target/`; dependency built without `--cfg docsrs` / doc metadata; toolchain drift.

Related errors


AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10). Data as JSON: /api/errors/1c63776742d7bc50. Report an issue: GitHub.