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 ICE - 'expected a const, but found another kind' #119529

Closed
tomBoddaert opened this issue Jan 2, 2024 · 0 comments · Fixed by #119769
Closed

Rustdoc ICE - 'expected a const, but found another kind' #119529

tomBoddaert opened this issue Jan 2, 2024 · 0 comments · Fixed by #119769
Assignees
Labels
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

@tomBoddaert
Copy link

Code

use std::cmp::PartialEq;

type Dyn<Rhs> = dyn PartialEq<Rhs>;

Meta

rustc --version --verbose:

rustc 1.77.0-nightly (e51e98dde 2023-12-31)
binary: rustc
commit-hash: e51e98dde6a60637b6a71b8105245b629ac3fe77
commit-date: 2023-12-31
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/generic_args.rs:184:43: expected a const, but found another kind
Backtrace

thread 'rustc' panicked at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/compiler/rustc_errors/src/lib.rs:1068:30:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic_builder::BugAbort as rustc_errors::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
   2: <rustc_errors::DiagCtxt>::bug::<alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::bug_fmt
   7: <rustc_middle::ty::generic_args::GenericArg>::expect_const
   8: rustdoc::clean::utils::ty_args_to_args
   9: rustdoc::clean::utils::external_path
  10: rustdoc::clean::clean_middle_ty
  11: rustdoc::clean::clean_maybe_renamed_item::{closure#1}
  12: rustdoc::clean::clean_doc_module
  13: rustdoc::core::run_global_ctxt
  14: rustdoc::main_args::{closure#1}::{closure#0}::{closure#0}
  15: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustdoc::main_args::{closure#1}>::{closure#0}

rustc-ice file

thread 'rustc' panicked at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/compiler/rustc_errors/src/lib.rs:1068:30:
Box<dyn Any>
stack backtrace:
   0:     0x7ff635fe7d2e - std::backtrace_rs::backtrace::libunwind::trace::h44f4ca7c442c0986
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7ff635fe7d2e - std::backtrace_rs::backtrace::trace_unsynchronized::h08d378a2031b5c5b
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff635fe7d2e - std::backtrace::Backtrace::create::hf208879ddad61a5f
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/backtrace.rs:331:13
   3:     0x7ff635fe7c70 - std::backtrace::Backtrace::force_capture::h5b9c5cc42433e60b
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/backtrace.rs:312:9
   4:     0x7ff632d66afc - std[59bbd359e4a0812d]::panicking::update_hook::<alloc[9e8bbef5278c9f16]::boxed::Box<rustc_driver_impl[f5f02e8ab7f89dcf]::install_ice_hook::{closure#0}>>::{closure#0}
   5:     0x7ff636003c06 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h0ebdda5c503ff158
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/alloc/src/boxed.rs:2029:9
   6:     0x7ff636003c06 - std::panicking::rust_panic_with_hook::h4f38919015b1c60f
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/panicking.rs:783:13
   7:     0x7ff632d9f1b4 - std[59bbd359e4a0812d]::panicking::begin_panic::<rustc_errors[b2b45e62fb4172dd]::ExplicitBug>::{closure#0}
   8:     0x7ff632d9b5b6 - std[59bbd359e4a0812d]::sys_common::backtrace::__rust_end_short_backtrace::<std[59bbd359e4a0812d]::panicking::begin_panic<rustc_errors[b2b45e62fb4172dd]::ExplicitBug>::{closure#0}, !>
   9:     0x7ff632d96856 - std[59bbd359e4a0812d]::panicking::begin_panic::<rustc_errors[b2b45e62fb4172dd]::ExplicitBug>
  10:     0x7ff632daa101 - <rustc_errors[b2b45e62fb4172dd]::diagnostic_builder::BugAbort as rustc_errors[b2b45e62fb4172dd]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7ff633171ece - <rustc_errors[b2b45e62fb4172dd]::DiagCtxt>::bug::<alloc[9e8bbef5278c9f16]::string::String>
  12:     0x7ff63320e02b - rustc_middle[7d80ff9c88f366f3]::util::bug::opt_span_bug_fmt::<rustc_span[44814e3eac9e4a35]::span_encoding::Span>::{closure#0}
  13:     0x7ff6331f690a - rustc_middle[7d80ff9c88f366f3]::ty::context::tls::with_opt::<rustc_middle[7d80ff9c88f366f3]::util::bug::opt_span_bug_fmt<rustc_span[44814e3eac9e4a35]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7ff6331f67a8 - rustc_middle[7d80ff9c88f366f3]::ty::context::tls::with_context_opt::<rustc_middle[7d80ff9c88f366f3]::ty::context::tls::with_opt<rustc_middle[7d80ff9c88f366f3]::util::bug::opt_span_bug_fmt<rustc_span[44814e3eac9e4a35]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7ff631188960 - rustc_middle[7d80ff9c88f366f3]::util::bug::bug_fmt
  16:     0x7ff633200086 - <rustc_middle[7d80ff9c88f366f3]::ty::generic_args::GenericArg>::expect_const
  17:     0x55f51eac189a - rustdoc[60b03d8a22a2fa25]::clean::utils::ty_args_to_args
  18:     0x55f51eac1c4b - rustdoc[60b03d8a22a2fa25]::clean::utils::external_path
  19:     0x55f51ec1441b - rustdoc[60b03d8a22a2fa25]::clean::clean_middle_ty
  20:     0x55f51eae37c9 - rustdoc[60b03d8a22a2fa25]::clean::clean_maybe_renamed_item::{closure#1}
  21:     0x55f51eac9d5d - rustdoc[60b03d8a22a2fa25]::clean::clean_doc_module
  22:     0x55f51eaf4a79 - rustdoc[60b03d8a22a2fa25]::core::run_global_ctxt
  23:     0x55f51ec07666 - rustdoc[60b03d8a22a2fa25]::main_args::{closure#1}::{closure#0}::{closure#0}
  24:     0x55f51e9fe41d - rustc_interface[8dea96efab884454]::interface::run_compiler::<core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>, rustdoc[60b03d8a22a2fa25]::main_args::{closure#1}>::{closure#0}
  25:     0x55f51e9c13a0 - std[59bbd359e4a0812d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[8dea96efab884454]::util::run_in_thread_with_globals<rustc_interface[8dea96efab884454]::util::run_in_thread_pool_with_globals<rustc_interface[8dea96efab884454]::interface::run_compiler<core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>, rustdoc[60b03d8a22a2fa25]::main_args::{closure#1}>::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>
  26:     0x55f51ea0998e - <<std[59bbd359e4a0812d]::thread::Builder>::spawn_unchecked_<rustc_interface[8dea96efab884454]::util::run_in_thread_with_globals<rustc_interface[8dea96efab884454]::util::run_in_thread_pool_with_globals<rustc_interface[8dea96efab884454]::interface::run_compiler<core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>, rustdoc[60b03d8a22a2fa25]::main_args::{closure#1}>::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>::{closure#1} as core[f50a4b4ddb6878bb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7ff63600db35 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfced58be344e2c05
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/alloc/src/boxed.rs:2015:9
  28:     0x7ff63600db35 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7842a7154462ae57
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/alloc/src/boxed.rs:2015:9
  29:     0x7ff63600db35 - std::sys::unix::thread::Thread::new::thread_start::ha365c5d9b9d0ac99
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/sys/unix/thread.rs:108:17
  30:     0x7ff62fdbd9eb - <unknown>
  31:     0x7ff62fe417cc - <unknown>
  32:                0x0 - <unknown>


rustc version: 1.77.0-nightly (e51e98dde 2023-12-31)
platform: x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

This ICE only occurs when running cargo doc or rustdoc src/main.rs with nightly. Defining the PartialEq trait manually did not trigger this, only the PartialEq in std/alloc/core.
Running a quick search on nightly versions, nightly-2023-12-11 (d86d65bbc 2023-12-10) works and nightly-2023-12-12 (21cce21d8 2023-12-11) fails with a similar backtrace (some items have been renamed / moved).

@tomBoddaert tomBoddaert 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 Jan 2, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 2, 2024
@fmease fmease added 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. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 2, 2024
@fmease fmease self-assigned this Jan 2, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 8, 2024
@bors bors closed this as completed in 7c378d0 Jan 10, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 10, 2024
Rollup merge of rust-lang#119769 - fmease:rustdoc-off-by-one-dyn-trait-def-gen-args, r=GuillaumeGomez

rustdoc: offset generic args of cross-crate trait object types when cleaning

Fixes rust-lang#119529.

This PR contains several refactorings apart from the bug fix.
Best reviewed commit by commit.
r? GuillaumeGomez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
3 participants