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

rustdoc: cargo +nightly doc panics when documenting a library that re-export std #99221

Closed
celinval opened this issue Jul 13, 2022 · 7 comments · Fixed by #99344
Closed

rustdoc: cargo +nightly doc panics when documenting a library that re-export std #99221

celinval opened this issue Jul 13, 2022 · 7 comments · Fixed by #99344
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Milestone

Comments

@celinval
Copy link
Contributor

I tried to create a minimum example from an issue we've seen in our project (https://github.com/model-checking/kani). I tried running:

cargo +nightly doc

On the following crate:

[package]
name = "std-override"
version = "0.0.1"
edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]

src/lib.rs:

// re-export all std symbols
pub use std::*;

#[macro_export]
macro_rules! print {
    ($($x:tt)*) =>  { };
}

#[macro_export]
macro_rules! eprint {
    ($($x:tt)*) =>  { };
}

#[macro_export]
macro_rules! println {
    ($($x:tt)*) =>  { };
}

#[macro_export]
macro_rules! eprintln {
    ($($x:tt)*) =>  { };
}

#[macro_export]
macro_rules! unreachable {
    ($($x:tt)*) =>  { };
}

#[macro_export]
macro_rules! panic {
    ($($x:tt)*) =>  { };
}

I expected to see this happen: The command should succeed.

Instead, this happened: It crashed with an ICE

Meta

rustc +nightly --version --verbose:

rustc 1.64.0-nightly (1c7b36d4d 2022-07-12)
binary: rustc
commit-hash: 1c7b36d4db582cb47513a6c7176baaec1c3346ab
commit-date: 2022-07-12
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6
Backtrace

 Documenting std-override v0.0.1 (/tmp/doc-bug)
thread 'rustc' panicked at 'no entry found for key', src/librustdoc/passes/collect_intra_doc_links.rs:777:16
stack backtrace:
   0:     0x7fbeaa8ca7c0 - std::backtrace_rs::backtrace::libunwind::trace::hf2d478307f174bf8
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7fbeaa8ca7c0 - std::backtrace_rs::backtrace::trace_unsynchronized::h711075c80b4b15c0
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fbeaa8ca7c0 - std::sys_common::backtrace::_print_fmt::hebeecd7b360baf82
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fbeaa8ca7c0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h136680251e065964
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fbeaa923d9c - core::fmt::write::h21802877aced75ae
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/core/src/fmt/mod.rs:1198:17
   5:     0x7fbeaa8bbf85 - std::io::Write::write_fmt::hfcde2a3cccecf969
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/io/mod.rs:1672:15
   6:     0x7fbeaa8cd451 - std::sys_common::backtrace::_print::h54991e5c3bc938cb
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fbeaa8cd451 - std::sys_common::backtrace::print::h9ca61c0ed4272627
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fbeaa8cd451 - std::panicking::default_hook::{{closure}}::h26c10b5c3b2bea64
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/panicking.rs:295:22
   9:     0x7fbeaa8cd123 - std::panicking::default_hook::hb3cbebc52bbac72e
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/panicking.rs:314:9
  10:     0x7fbeab0f2a84 - rustc_driver[9f14ed6a3a961535]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fbeaa8cdc26 - std::panicking::rust_panic_with_hook::h0d09718c1ae4132d
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/panicking.rs:702:17
  12:     0x7fbeaa8cda77 - std::panicking::begin_panic_handler::{{closure}}::h1010bf1f46fb8722
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/panicking.rs:588:13
  13:     0x7fbeaa8caca4 - std::sys_common::backtrace::__rust_end_short_backtrace::h60da120d1ee80789
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7fbeaa8cd7a2 - rust_begin_unwind
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/panicking.rs:584:5
  15:     0x7fbeaa891ae3 - core::panicking::panic_fmt::h7c2f25a656c170f4
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/core/src/panicking.rs:142:14
  16:     0x7fbeaa9209c1 - core::panicking::panic_display::hf66b1e5852f4956b
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/core/src/panicking.rs:72:5
  17:     0x7fbeaa92096b - core::panicking::panic_str::hc22b70c63809db11
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/core/src/panicking.rs:56:5
  18:     0x7fbeaa891956 - core::option::expect_failed::h477c4e9e6d80605f
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/core/src/option.rs:1874:5
  19:     0x5650a910bf71 - rustdoc[482f73a88d1d5c19]::passes::collect_intra_doc_links::resolve_associated_trait_item
  20:     0x5650a910ad2e - <rustdoc[482f73a88d1d5c19]::passes::collect_intra_doc_links::LinkCollector>::resolve_associated_item
  21:     0x5650a9108e71 - <rustdoc[482f73a88d1d5c19]::passes::collect_intra_doc_links::LinkCollector>::resolve
  22:     0x5650a910dc0f - <rustdoc[482f73a88d1d5c19]::passes::collect_intra_doc_links::LinkCollector as rustdoc[482f73a88d1d5c19]::visit::DocVisitor>::visit_item
  23:     0x5650a9119eca - <rustdoc[482f73a88d1d5c19]::passes::collect_intra_doc_links::LinkCollector as rustdoc[482f73a88d1d5c19]::visit::DocVisitor>::visit_inner_recur
  24:     0x5650a9110cfe - <rustdoc[482f73a88d1d5c19]::passes::collect_intra_doc_links::LinkCollector as rustdoc[482f73a88d1d5c19]::visit::DocVisitor>::visit_item
  25:     0x5650a910789c - rustdoc[482f73a88d1d5c19]::passes::collect_intra_doc_links::collect_intra_doc_links
  26:     0x5650a91ef064 - <rustc_session[26041ce061f99353]::session::Session>::time::<rustdoc[482f73a88d1d5c19]::clean::types::Crate, rustdoc[482f73a88d1d5c19]::core::run_global_ctxt::{closure#8}>
  27:     0x5650a9098e5e - rustdoc[482f73a88d1d5c19]::core::run_global_ctxt
  28:     0x5650a91ef4bf - <rustc_session[26041ce061f99353]::session::Session>::time::<(rustdoc[482f73a88d1d5c19]::clean::types::Crate, rustdoc[482f73a88d1d5c19]::config::RenderOptions, rustdoc[482f73a88d1d5c19]::formats::cache::Cache), rustdoc[482f73a88d1d5c19]::main_options::{closure#0}::{closure#0}::{closure#1}::{closure#0}>
  29:     0x5650a912812c - <rustc_interface[dc3158545dad61e1]::passes::QueryContext>::enter::<rustdoc[482f73a88d1d5c19]::main_options::{closure#0}::{closure#0}::{closure#1}, core[b41f5196d70b7330]::result::Result<(), rustc_errors[b51a8ee25e0d94c9]::ErrorGuaranteed>>
  30:     0x5650a90ab53a - <rustc_interface[dc3158545dad61e1]::interface::Compiler>::enter::<rustdoc[482f73a88d1d5c19]::main_options::{closure#0}::{closure#0}, core[b41f5196d70b7330]::result::Result<(), rustc_errors[b51a8ee25e0d94c9]::ErrorGuaranteed>>
  31:     0x5650a9284c63 - rustc_span[b540c10ca4ad3e15]::with_source_map::<core[b41f5196d70b7330]::result::Result<(), rustc_errors[b51a8ee25e0d94c9]::ErrorGuaranteed>, rustc_interface[dc3158545dad61e1]::interface::create_compiler_and_run<core[b41f5196d70b7330]::result::Result<(), rustc_errors[b51a8ee25e0d94c9]::ErrorGuaranteed>, rustdoc[482f73a88d1d5c19]::main_options::{closure#0}>::{closure#1}>
  32:     0x5650a90d898b - rustc_interface[dc3158545dad61e1]::interface::create_compiler_and_run::<core[b41f5196d70b7330]::result::Result<(), rustc_errors[b51a8ee25e0d94c9]::ErrorGuaranteed>, rustdoc[482f73a88d1d5c19]::main_options::{closure#0}>
  33:     0x5650a90a9dd2 - rustdoc[482f73a88d1d5c19]::main_options
  34:     0x5650a9125d6b - <scoped_tls[69c5c7af7bad0e11]::ScopedKey<rustc_span[b540c10ca4ad3e15]::SessionGlobals>>::set::<rustdoc[482f73a88d1d5c19]::main_args::{closure#0}, core[b41f5196d70b7330]::result::Result<(), rustc_errors[b51a8ee25e0d94c9]::ErrorGuaranteed>>
  35:     0x5650a92034ef - std[aea08c340574f8b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[dc3158545dad61e1]::util::run_in_thread_pool_with_globals<rustdoc[482f73a88d1d5c19]::main_args::{closure#0}, core[b41f5196d70b7330]::result::Result<(), rustc_errors[b51a8ee25e0d94c9]::ErrorGuaranteed>>::{closure#0}, core[b41f5196d70b7330]::result::Result<(), rustc_errors[b51a8ee25e0d94c9]::ErrorGuaranteed>>
  36:     0x5650a913a939 - <<std[aea08c340574f8b]::thread::Builder>::spawn_unchecked_<rustc_interface[dc3158545dad61e1]::util::run_in_thread_pool_with_globals<rustdoc[482f73a88d1d5c19]::main_args::{closure#0}, core[b41f5196d70b7330]::result::Result<(), rustc_errors[b51a8ee25e0d94c9]::ErrorGuaranteed>>::{closure#0}, core[b41f5196d70b7330]::result::Result<(), rustc_errors[b51a8ee25e0d94c9]::ErrorGuaranteed>>::{closure#1} as core[b41f5196d70b7330]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7fbeaa8d7673 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h304119b3abe2df49
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/alloc/src/boxed.rs:1934:9
  38:     0x7fbeaa8d7673 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2a0513e129c0d255
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/alloc/src/boxed.rs:1934:9
  39:     0x7fbeaa8d7673 - std::sys::unix::thread::Thread::new::thread_start::h004b08da95a1ac4a
                               at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/std/src/sys/unix/thread.rs:108:17
  40:     0x7fbea9fec6db - start_thread
                               at /build/glibc-CVJwZb/glibc-2.27/nptl/pthread_create.c:463
  41:     0x7fbea997761f - clone
                               at /build/glibc-CVJwZb/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  42:                0x0 - <unknown>

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.64.0-nightly (1c7b36d4d 2022-07-12) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

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

query stack during panic:
end of query stack
error: could not document `std-override`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2021 --crate-type lib --crate-name std_override src/lib.rs -o /tmp/doc-bug/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat -C metadata=a2ed46871ef5d396 -L dependency=/tmp/doc-bug/target/debug/deps --crate-version 0.0.1` (exit status: 101)

@celinval celinval added the C-bug Category: This is a bug. label Jul 13, 2022
@celinval
Copy link
Contributor Author

This issue may be related to #98032, however I can only reproduce it on the nightly build. On the stable channel, rustdoc succeeds.

$ cargo doc
 Documenting std-override v0.0.1 (/tmp/doc-bug)
    Finished dev [unoptimized + debuginfo] target(s) in 4.76s
$ rustc --version --verbose
rustc 1.62.0 (a8314ef7d 2022-06-27)
binary: rustc
commit-hash: a8314ef7d0ec7b75c336af2c9857bfaf43002bfc
commit-date: 2022-06-27
host: x86_64-unknown-linux-gnu
release: 1.62.0
LLVM version: 14.0.5

@jyn514
Copy link
Member

jyn514 commented Jul 15, 2022

cc @petrochenkov

@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Jul 15, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jul 15, 2022
@jyn514
Copy link
Member

jyn514 commented Jul 15, 2022

@celinval does this reproduce on beta?

@notriddle
Copy link
Contributor

@jyn514

I know I'm not celinval, but I've been able to reduce this to a test case, and yeah, it reproduces on beta.

@notriddle notriddle added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Jul 16, 2022
@jyn514 jyn514 added this to the 1.63.0 milestone Jul 17, 2022
@jyn514 jyn514 removed the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Jul 17, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jul 18, 2022
…rules-w-same-name, r=GuillaumeGomez

rustdoc: avoid inlining items with duplicate `(type, name)`

Fixes rust-lang#99221
@bors bors closed this as completed in c822183 Jul 18, 2022
@celinval
Copy link
Contributor Author

That was quick. Thank you!

@inquisitivecrystal inquisitivecrystal removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jul 19, 2022
@Mark-Simulacrum
Copy link
Member

Reopening to track beta breakage.

@inquisitivecrystal inquisitivecrystal added beta-nominated Nominated for backporting to the compiler in the beta channel. and removed beta-nominated Nominated for backporting to the compiler in the beta channel. labels Jul 19, 2022
@inquisitivecrystal
Copy link
Contributor

I was silly and nominated even though the PR has already been nominated, and that's really the thing that's supposed to be. Please ignore, and sorry for the noise.

ehuss pushed a commit to ehuss/rust that referenced this issue Jul 22, 2022
…rules-w-same-name, r=GuillaumeGomez

rustdoc: avoid inlining items with duplicate `(type, name)`

Fixes rust-lang#99221
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants