Skip to content

Failed to build json docs with rustdoc -w json #99879

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

Closed
akriegman opened this issue Jul 29, 2022 · 2 comments
Closed

Failed to build json docs with rustdoc -w json #99879

akriegman opened this issue Jul 29, 2022 · 2 comments
Labels
A-rustdoc-json Area: Rustdoc JSON backend C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@akriegman
Copy link

I'm trying to use the rustdoc -w json option, but it crashes with a difficult to understand error, and suggests reporting it here.

Code

$ RUSTDOCFLAGS='-w json -Z unstable-options' cargo +nightly doc

Cargo.toml:

...
[dependencies]
anyhow = "1.0.58"
ethers = { version = "0.14.0", features = ["ws"] }
futures = "0.3.21"
tap = "1.0.1"
tokio = { version = "1.20.1", features = ["full"] }
tracing-subscriber = "0.3.15"
warp = "0.3.2"

Meta

$ rustc --version --verbose
rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: x86_64-unknown-linux-gnu
release: 1.61.0
LLVM version: 14.0.0

$ cargo +nightly rustc --lib -- --version --verbose
...
rustc 1.63.0-nightly (1f34da9ec 2022-06-14)
binary: rustc
commit-hash: 1f34da9ec8a85b6f86c5fa1c121ab6f88f2f4966
commit-date: 2022-06-14
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.5

Error output

...
 Documenting libc v0.2.126
 Documenting typenum v1.15.0
 Documenting memchr v2.5.0
 Documenting log v0.4.17
 Documenting futures-core v0.3.21
 Documenting crunchy v0.2.2
 Documenting radium v0.7.0
 Documenting httparse v1.7.1
 Documenting futures-task v0.3.21
 Documenting rustversion v1.0.8
 Documenting encoding_rs v0.8.31
 Documenting eyre v0.6.8
 Documenting hashers v1.0.1
 Documenting anyhow v1.0.58
 Documenting spki v0.6.0
thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `Item { id: Id("0:444:165"), crate_id: 0, name: Some("Output"), span: Some(Span { filename: "/home/aaron/.cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/typenum-1.15.0/src/int.rs", begin: (621, 4), end: (621, 29) }), visibility: Default, docs: None, links: {}, attrs: [], deprecation: None, inner: Typedef(Typedef { type_: QualifiedPath { name: "Output", args: AngleBracketed { args: [], bindings: [] }, self_type: Generic("M"), trait_: ResolvedPath { name: "Div", id: Id("1:3260:1791"), args: Some(AngleBracketed { args: [Type(Generic("N"))], bindings: [] }), param_names: [] } }, generics: Generics { params: [], where_predicates: [] } }) }`,
 right: `Item { id: Id("0:444:165"), crate_id: 0, name: Some("Output"), span: Some(Span { filename: "/home/aaron/.cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/typenum-1.15.0/src/int.rs", begin: (621, 4), end: (621, 29) }), visibility: Default, docs: None, links: {}, attrs: [], deprecation: None, inner: Typedef(Typedef { type_: ResolvedPath { name: "Quot", id: Id("0:843:1861"), args: Some(AngleBracketed { args: [Type(Generic("M")), Type(Generic("N"))], bindings: [] }), param_names: [] }, generics: Generics { params: [], where_predicates: [] } }) }`', src/librustdoc/json/mod.rs:202:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/1f34da9ec8a85b6f86c5fa1c121ab6f88f2f4966/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/1f34da9ec8a85b6f86c5fa1c121ab6f88f2f4966/library/core/src/panicking.rs:142:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed::<rustdoc_json_types::Item, rustdoc_json_types::Item>
   4: <rustdoc::json::JsonRenderer as rustdoc::formats::renderer::FormatRenderer>::item
   5: <rustdoc::json::JsonRenderer as rustdoc::formats::renderer::FormatRenderer>::item
   6: <core::iter::adapters::map::Map<core::slice::iter::Iter<rustdoc::formats::Impl>, <rustdoc::json::JsonRenderer>::get_trait_implementors::{closure#0}::{closure#0}> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::traits::iterator::Iterator::for_each::call<rustdoc_json_types::Id, <alloc::vec::Vec<rustdoc_json_types::Id> as alloc::vec::spec_extend::SpecExtend<rustdoc_json_types::Id, core::iter::adapters::map::Map<core::slice::iter::Iter<rustdoc::formats::Impl>, <rustdoc::json::JsonRenderer>::get_trait_implementors::{closure#0}::{closure#0}>>>::spec_extend::{closure#0}>::{closure#0}>
   7: <alloc::vec::Vec<rustdoc_json_types::Id> as alloc::vec::spec_from_iter::SpecFromIter<rustdoc_json_types::Id, core::iter::adapters::map::Map<core::slice::iter::Iter<rustdoc::formats::Impl>, <rustdoc::json::JsonRenderer>::get_trait_implementors::{closure#0}::{closure#0}>>>::from_iter
   8: <rustdoc::json::JsonRenderer as rustdoc::formats::renderer::FormatRenderer>::item
   9: <rustdoc::json::JsonRenderer as rustdoc::formats::renderer::FormatRenderer>::item
  10: <rustdoc::json::JsonRenderer as rustdoc::formats::renderer::FormatRenderer>::item
  11: rustdoc::formats::renderer::run_format::<rustdoc::json::JsonRenderer>
  12: rustdoc::run_renderer::<rustdoc::json::JsonRenderer>
  13: <rustc_session::session::Session>::time::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustdoc::main_options::{closure#0}::{closure#0}::{closure#1}::{closure#2}>
  14: <rustc_interface::passes::QueryContext>::enter::<rustdoc::main_options::{closure#0}::{closure#0}::{closure#1}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  15: <rustc_interface::interface::Compiler>::enter::<rustdoc::main_options::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  16: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustdoc::main_options::{closure#0}>::{closure#1}>
  17: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustdoc::main_options::{closure#0}>
  18: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustdoc::main_args::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.63.0-nightly (1f34da9ec 2022-06-14) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z unstable-options

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not document `typenum`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name typenum /home/aaron/.cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/typenum-1.15.0/src/lib.rs --cap-lints allow -o /home/aaron/scp/moonport/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat -C metadata=fa5adaf555b55ba1 -L dependency=/home/aaron/scp/moonport/target/debug/deps -w json -Z unstable-options --crate-version 1.15.0` (exit status: 101)
warning: build failed, waiting for other jobs to finish...

Backtrace

<backtrace>

@akriegman akriegman added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 29, 2022
@Enselic
Copy link
Member

Enselic commented Jul 29, 2022

Thanks for reporting! Looks like one of several known bugs that has been fixed. Can you try the latest nightly please? 2022-06-14 is pretty old

@rustbot label +A-rustdoc-json -T-compiler +T-rustdoc

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 29, 2022
@Enselic
Copy link
Member

Enselic commented Aug 19, 2022

I can reproduce with nightly-2022-06-28 but not with nightly-2022-06-29. The ICE line is line 621 here:

 617   │ impl<M, N> PartialDiv<N> for M
 618   │ where
 619   │     M: Integer + Div<N> + Rem<N, Output = Z0>,
 620   │ {
 621   │     type Output = Quot<M, N>;
 622   │     #[inline]
 623   │     fn partial_div(self, rhs: N) -> Self::Output {
 624   │         self / rhs
 625   │     }
 626   │ }

so this must have been fixed by #98577.

To reproduce I copy-paste the following to a terminal:

crate=typenum
version=1.15.0

cd /tmp
curl -L https://crates.io/api/v1/crates/${crate}/${version}/download | tar -xz
cd ${crate}-${version}
cargo +nightly-2022-06-28 rustdoc --lib -- -Z unstable-options --output-format json

@jyn514 jyn514 closed this as completed Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants