Skip to content

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

Closed
@akriegman

Description

@akriegman

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.com-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.com-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.com-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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-jsonArea: Rustdoc JSON backendC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions