Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jyn514 opened this issue Feb 2, 2024 · 2 comments · Fixed by #13387
Closed

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

jyn514 opened this issue Feb 2, 2024 · 2 comments · Fixed by #13387
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. C-bug Category: bug Command-doc S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

Comments

@jyn514
Copy link
Member

jyn514 commented Feb 2, 2024

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]
@jyn514 jyn514 added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Feb 2, 2024
@epage
Copy link
Contributor

epage commented Feb 2, 2024

The "Caused by" difference is definitely us. Unsure if the different in message format is us or rustdoc.

@epage epage added Command-doc A-console-output Area: Terminal output, colors, progress bar, etc. labels Feb 2, 2024
@jyn514
Copy link
Member Author

jyn514 commented Feb 2, 2024

the message format thing is because i used a bad example; rustdoc's error is a denied lint, which doesn't have an error code. i can change it to be more consistent with slightly different code:

; head -n3 src/main.rs
const foo: size = 1;
; cargo doc --no-deps --message-format short
src/main.rs:3:12: error[E0412]: cannot find type `size` in this scope

@epage epage added S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. and removed S-triage Status: This issue is waiting on initial triage. labels Feb 2, 2024
@bors bors closed this as completed in 258fa84 Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. C-bug Category: bug Command-doc S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants