Skip to content

ICE with rustdoc JSON backend and duplicated exports #89834

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
sunshowers opened this issue Oct 12, 2021 · 2 comments
Closed

ICE with rustdoc JSON backend and duplicated exports #89834

sunshowers opened this issue Oct 12, 2021 · 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

@sunshowers
Copy link
Contributor

Hi there --

Looks like the rustdoc json output seems to have an issue with duplicated exports. I hit this issue with https://docs.rs/ansi_term/0.12.1/ansi_term/index.html, which exports both Color and Colour as the same type.

Code

Minimized example:

mod inner {
    pub struct Public;
}
pub use inner::Public as NewName1;
pub use inner::Public as NewName2;

Reproduces with the following command:

RUSTDOCFLAGS='--output-format json' cargo +nightly doc

Meta

rustc --version --verbose:

rustc 1.57.0-nightly (5b210643e 2021-10-11)
binary: rustc
commit-hash: 5b210643ebf2485aafdf2494de8cf41941a64e95
commit-date: 2021-10-11
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `Item { id: Id("0:4"), crate_id: 0, name: Some("NewName1"), span: Some(Span { filename: "src/lib.rs", begin: (2, 4), end: (2, 22) }), visibility: Public, docs: None, links: {}, attrs: [], deprecation: None, inner: Struct(Struct { struct_type: Unit, generics: Generics { params: [], where_predicates: [] }, fields_stripped: false, fields: [], impls: [Id("a:2:2989-0:4"), Id("a:2:3001-0:4"), Id("a:2:3030-0:4"), Id("a:2:8303-0:4"), Id("a:2:8304-0:4"), Id("b:2:2922-0:4"), Id("b:2:2918-0:4"), Id("b:2:2933-0:4"), Id("b:2:2928-0:4"), Id("b:2:2594-0:4"), Id("b:2:2597-0:4"), Id("b:2:3652-0:4")] }) }`,
 right: `Item { id: Id("0:4"), crate_id: 0, name: Some("NewName2"), span: Some(Span { filename: "src/lib.rs", begin: (2, 4), end: (2, 22) }), visibility: Public, docs: None, links: {}, attrs: [], deprecation: None, inner: Struct(Struct { struct_type: Unit, generics: Generics { params: [], where_predicates: [] }, fields_stripped: false, fields: [], impls: [Id("a:2:2989-0:4"), Id("a:2:3001-0:4"), Id("a:2:3030-0:4"), Id("a:2:8303-0:4"), Id("a:2:8304-0:4"), Id("b:2:2922-0:4"), Id("b:2:2918-0:4"), Id("b:2:2933-0:4"), Id("b:2:2928-0:4"), Id("b:2:2594-0:4"), Id("b:2:2597-0:4"), Id("b:2:3652-0:4")] }) }`', src/librustdoc/json/mod.rs:195:17

Backtrace

   0: rust_begin_unwind
             at /rustc/5b210643ebf2485aafdf2494de8cf41941a64e95/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/5b210643ebf2485aafdf2494de8cf41941a64e95/library/core/src/panicking.rs:100:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
   4: <rustdoc::json::JsonRenderer as rustdoc::formats::renderer::FormatRenderer>::item
   5: <rustdoc::json::JsonRenderer as rustdoc::formats::renderer::FormatRenderer>::item
   6: rustdoc::formats::renderer::run_format
   7: rustc_session::utils::<impl rustc_session::session::Session>::time
   8: rustc_interface::passes::QueryContext::enter
   9: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  10: rustc_span::with_source_map
  11: rustc_interface::interface::create_compiler_and_run
  12: rustdoc::main_options
  13: scoped_tls::ScopedKey<T>::set

I spent a little time looking at this, and it looks like changing mod inner to pub mod inner also fails with jsondocck:

thread 'main' panicked at 'Name collision: import_id is duplicated', src/tools/jsondocck/src/main.rs:274:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

so it's likely that the handling of duplicate public re-exports is also broken.

@sunshowers sunshowers 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 Oct 12, 2021
@sunshowers
Copy link
Contributor Author

This might be related to #89097 though it seems different at first glance.

@jyn514 jyn514 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 Oct 13, 2021
@jyn514
Copy link
Member

jyn514 commented Oct 13, 2021

Duplicate of #83720.

@jyn514 jyn514 closed this as completed Oct 13, 2021
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

2 participants