Skip to content

rustdoc cannot emit dep-info alongside JSON output #158869

Description

@weihanglo

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 rust-lang/cargo#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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-jsonArea: Rustdoc JSON backendC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions