Skip to content

give a better error when rustdoc exits with a non-zero exit code #13386

Closed
@jyn514

Description

@jyn514

Problem

currently, the error message when rustdoc errors looks like this:

; RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --document-private-items --message-format short -q
src/main.rs:1:11: error: unclosed HTML tag `usize`
error: could not document `example`

Caused by:
  process didn't exit successfully: `/Users/jyn/.local/lib/rustup/toolchains/nightly-aarch64-apple-darwin/bin/rustdoc --edition=2021 --crate-type bin --crate-name example src/main.rs -o /Users/jyn/.local/lib/cargo/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat,diagnostic-short --diagnostic-width=186 --document-private-items '-Arustdoc::private-intra-doc-links' -C metadata=a59e1929dfc569b0 -L dependency=/Users/jyn/.local/lib/cargo/target/debug/deps --extern bitflags=/Users/jyn/.local/lib/cargo/target/debug/deps/libbitflags-d34f162dfbd7ed32.rmeta --extern inner=/Users/jyn/.local/lib/cargo/target/debug/deps/libinner-a5a332b9f54b66cc.rmeta -Dwarnings --crate-version 0.1.0` (exit status: 1)

this is already kind of long, and it gets much worse as you add more dependencies.

Steps

  1. add some docs that will warn, e.g. //! Option<usize> at the root of the crate
  2. RUSTDOCFLAGS=-Dwarnings cargo doc

Possible Solution(s)

it would be nice to make it consistent with the error for rustc:

; cargo c -q --message-format short
src/main.rs:10:12: error[E0038]: the trait `Bar` cannot be made into an object
src/main.rs:10:32: error[E0038]: the trait `Bar` cannot be made into an object
error: could not compile `example` (bin "example") due to 2 previous errors

Notes

No response

Version

cargo 1.77.0-nightly (ac6bbb332 2023-12-26)
release: 1.77.0-nightly
commit-hash: ac6bbb33293d8d424c17ecdb42af3aac25fb7295
commit-date: 2023-12-26
host: aarch64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.4.0 (sys:0.4.70+curl-8.5.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 14.3.0 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-console-outputArea: Terminal output, colors, progress bar, etc.C-bugCategory: bugCommand-docS-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions