rust-lang / rust-lang/rust

rustdoc cannot emit dep-info alongside JSON output

Open
#158,869 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Code

// lib.rs
pub fn f() {}

Reproduction Steps

$ rustdoc --crate-name lib -Zunstable-options --output-format=json --emit=dep-info=lib.d lib.rs -o out
$ echo $?
0
$ ls lib.d
lib.d
$ ls out/lib.json
ls: out/lib.json: No such file or directory

Related cases:

$ rustdoc --crate-name lib -Zunstable-options --output-format=json --emit=html-static-files,dep-info=lib.d lib.rs -o out
error: the `--emit=html-static-files` flag is not supported with `--output-format=json`

$ rustdoc --crate-name lib -Zunstable-options --output-format=json --emit=json-files lib.rs -o out
error: unrecognized emission type: json-files

Expected Outcome

A way to request the dep-info file and the JSON doc output in one invocation.
For example, making the json-files emission type nameable on CLI
(I knew #155679 made it non-nameable), like hte following:

$ rustdoc --output-format=json --emit=json-files,dep-info=lib.d lib.rs -o out
$ ls out/lib.json lib.d
out/lib.json  lib.d

This was found in https://github.com/rust-lang/cargo/pull/17020
that Cargo wants a better rebuild detection also for JSON output.

At minimum,
an explicit --emit in JSON mode that omits the JSON output
should not exit 0 while silently skipping the primary artifact

Actual Output

$ rustdoc --output-format=json --emit=dep-info=lib.d lib.rs -o out
# exit=0
# no out/lib.json produced
# dep-info was produced

Version

rustdoc 1.99.0-nightly (3659db0d3 2026-07-05)

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

Start by reproducing the rustdoc commands in the issue and tracing how --output-format=json and --emit are handled. Check the existing emission-type validation and JSON output path. Done means one invocation produces both out/lib.json and lib.d, while explicitly omitting the primary JSON artifact no longer exits successfully without warning.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.