rust-lang / rust-lang/rust

rustdoc-json: primitive type's associated constants have inconsistent crate id

Open
#160,665 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-rustdoc-json C-bug T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

//! [`i32::MAX`]
$ rustdoc +nightly-2026-08-05 foo.rs --output-format json -Z unstable-options

I expected to see this happen: std::i32::MAX has the same crate_id as std::i32.

Instead, this happened: they have different crate_ids.

The paths start with std, but the crate_id of std::i32::MAX is 2 (core).

$ jq '.paths | with_entries(select(.value.path[0:2] == ["std", "i32"]))' < doc/foo.json
{
  "0": {
    "crate_id": 2,
    "path": [
      "std",
      "i32",
      "MAX"
    ],
    "kind": "assoc_const"
  },
  "644": {
    "crate_id": 1,
    "path": [
      "std",
      "i32"
    ],
    "kind": "primitive"
  }
}
$ jq '{ "1": .external_crates["1"], "2": .external_crates["2"]}' < doc/foo.json
{
  "1": {
    "name": "std",
    "html_root_url": "https://doc.rust-lang.org/nightly/",
    "path": "/home/nksm/.rustup/toolchains/nightly-2026-08-05-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-2f7e17dbfe663611.rmeta"
  },
  "2": {
    "name": "core",
    "html_root_url": "https://doc.rust-lang.org/nightly/",
    "path": "/home/nksm/.rustup/toolchains/nightly-2026-08-05-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-12f52b5fd4389540.rmeta"
  }
}
Meta

rustdoc +nightly-2026-08-05 --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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with foo.rs using the rustdoc JSON command, then inspect doc/foo.json with the jq queries shown in the report. Trace how the paths for std::i32 and std::i32::MAX receive their crate_id values; done means the associated constant and primitive have consistent crate identity in the JSON output.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.