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

ICE: rustdoc: unexpected const parent in type_of() / Const::from_anon_const: couldn't lit_to_const TypeError #102467

Closed
matthiaskrgr opened this issue Sep 29, 2022 · 6 comments · Fixed by #116120
Assignees
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

./src/test/ui/associated-consts/issue-102335-const.rs

#![feature(associated_const_equality)]

trait T {
    type A: S<C<X = 0i32> = 34>;
    //~^ ERROR associated type bindings are not allowed here
}

trait S {
    const C: i32;
}

fn main() {}

Meta

rustc --version --verbose:

rustdoc 1.66.0-nightly (ce7f0f1aa 2022-09-28)
binary: rustdoc
commit-hash: ce7f0f1aa0f02c45cad0749e63f3086234b1f422
commit-date: 2022-09-28
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.0

Error output

rustdoc ./src/test/ui/associated-consts/issue-102335-const.rs

<output>
Backtrace

thread 'rustc' panicked at 'Error', src/librustdoc/clean/mod.rs:1737:25
stack backtrace:
   0:     0x7fe774570170 - std::backtrace_rs::backtrace::libunwind::trace::hac9b0f7f9661e748
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7fe774570170 - std::backtrace_rs::backtrace::trace_unsynchronized::hc44795987fc42d34
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe774570170 - std::sys_common::backtrace::_print_fmt::h11541e17c3fc86a7
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fe774570170 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc17ff1666cc882db
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fe7745cae2e - core::fmt::write::h55fcab10ae826150
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/core/src/fmt/mod.rs:1209:17
   5:     0x7fe774560db5 - std::io::Write::write_fmt::hf963d6d18d14f181
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/io/mod.rs:1679:15
   6:     0x7fe774572ef3 - std::sys_common::backtrace::_print::h994ce2c0e5b405c8
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fe774572ef3 - std::sys_common::backtrace::print::hcc56026dcd969e04
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fe774572ef3 - std::panicking::default_hook::{{closure}}::h88f2c5d855241086
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/panicking.rs:267:22
   9:     0x7fe774572bdf - std::panicking::default_hook::h8c95d81babfc3452
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/panicking.rs:286:9
  10:     0x7fe776da8801 - rustc_driver[b4131074c7377c18]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fe77457372b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h67c5cbe4132c274b
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/alloc/src/boxed.rs:1952:9
  12:     0x7fe77457372b - std::panicking::rust_panic_with_hook::h60207dae86acc93c
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/panicking.rs:673:13
  13:     0x7fe774573541 - std::panicking::begin_panic_handler::{{closure}}::h417b25e282e7bdd0
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/panicking.rs:558:13
  14:     0x7fe77457061c - std::sys_common::backtrace::__rust_end_short_backtrace::hed3dc7a8acb54b37
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:138:18
  15:     0x7fe7745732a2 - rust_begin_unwind
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/panicking.rs:556:5
  16:     0x7fe7745c7a03 - core::panicking::panic_fmt::h33353e845faa36b7
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/core/src/panicking.rs:142:14
  17:     0x564a50dd4edc - rustdoc[fd64ae257ec160cb]::clean::clean_middle_ty
  18:     0x564a50dcb112 - rustdoc[fd64ae257ec160cb]::clean::clean_middle_const
  19:     0x564a50dd5ac8 - rustdoc[fd64ae257ec160cb]::clean::clean_generic_args
  20:     0x564a50dd59a8 - rustdoc[fd64ae257ec160cb]::clean::clean_generic_args
  21:     0x564a50be9b8d - <alloc[c8bb264001a6b8ff]::vec::Vec<rustdoc[fd64ae257ec160cb]::clean::types::PathSegment> as alloc[c8bb264001a6b8ff]::vec::spec_from_iter::SpecFromIter<rustdoc[fd64ae257ec160cb]::clean::types::PathSegment, core[de81bf0691074480]::iter::adapters::map::Map<core[de81bf0691074480]::slice::iter::Iter<rustc_hir[d07a7723d7da46ee]::hir::PathSegment>, rustdoc[fd64ae257ec160cb]::clean::clean_path::{closure#0}>>>::from_iter
  22:     0x564a50dcf39e - rustdoc[fd64ae257ec160cb]::clean::clean_poly_trait_ref
  23:     0x564a50dca56b - rustdoc[fd64ae257ec160cb]::clean::clean_generic_bound
  24:     0x564a50bea67e - <alloc[c8bb264001a6b8ff]::vec::Vec<rustdoc[fd64ae257ec160cb]::clean::types::GenericBound> as alloc[c8bb264001a6b8ff]::vec::spec_from_iter::SpecFromIter<rustdoc[fd64ae257ec160cb]::clean::types::GenericBound, core[de81bf0691074480]::iter::adapters::filter_map::FilterMap<core[de81bf0691074480]::slice::iter::Iter<rustc_hir[d07a7723d7da46ee]::hir::GenericBound>, rustdoc[fd64ae257ec160cb]::clean::clean_trait_item::{closure#0}::{closure#2}>>>::from_iter
  25:     0x564a50cd1104 - <rustdoc[fd64ae257ec160cb]::core::DocContext>::with_param_env::<rustdoc[fd64ae257ec160cb]::clean::types::Item, rustdoc[fd64ae257ec160cb]::clean::clean_trait_item::{closure#0}>
  26:     0x564a50bef421 - <alloc[c8bb264001a6b8ff]::vec::Vec<rustdoc[fd64ae257ec160cb]::clean::types::Item> as alloc[c8bb264001a6b8ff]::vec::spec_from_iter::SpecFromIter<rustdoc[fd64ae257ec160cb]::clean::types::Item, core[de81bf0691074480]::iter::adapters::map::Map<core[de81bf0691074480]::slice::iter::Iter<rustc_hir[d07a7723d7da46ee]::hir::TraitItemRef>, rustdoc[fd64ae257ec160cb]::clean::clean_maybe_renamed_item::{closure#1}::{closure#5}>>>::from_iter
  27:     0x564a50ccef37 - <rustdoc[fd64ae257ec160cb]::core::DocContext>::with_param_env::<alloc[c8bb264001a6b8ff]::vec::Vec<rustdoc[fd64ae257ec160cb]::clean::types::Item>, rustdoc[fd64ae257ec160cb]::clean::clean_maybe_renamed_item::{closure#1}>
  28:     0x564a50dc8b5b - <&mut rustdoc[fd64ae257ec160cb]::clean::clean_doc_module::{closure#2} as core[de81bf0691074480]::ops::function::FnOnce<(&(&rustc_hir[d07a7723d7da46ee]::hir::Item, core[de81bf0691074480]::option::Option<rustc_span[a9093c78adc8a30e]::symbol::Symbol>),)>>::call_once
  29:     0x564a50be04aa - <alloc[c8bb264001a6b8ff]::vec::Vec<rustdoc[fd64ae257ec160cb]::clean::types::Item> as alloc[c8bb264001a6b8ff]::vec::spec_extend::SpecExtend<rustdoc[fd64ae257ec160cb]::clean::types::Item, core[de81bf0691074480]::iter::adapters::flatten::FlatMap<core[de81bf0691074480]::slice::iter::Iter<(&rustc_hir[d07a7723d7da46ee]::hir::Item, core[de81bf0691074480]::option::Option<rustc_span[a9093c78adc8a30e]::symbol::Symbol>)>, alloc[c8bb264001a6b8ff]::vec::Vec<rustdoc[fd64ae257ec160cb]::clean::types::Item>, rustdoc[fd64ae257ec160cb]::clean::clean_doc_module::{closure#2}>>>::spec_extend
  30:     0x564a50dca1a0 - rustdoc[fd64ae257ec160cb]::clean::clean_doc_module
  31:     0x564a50b9cdf4 - rustdoc[fd64ae257ec160cb]::clean::utils::krate
  32:     0x564a50dec964 - <rustc_session[d3255eaf8224a584]::session::Session>::time::<rustdoc[fd64ae257ec160cb]::clean::types::Crate, rustdoc[fd64ae257ec160cb]::core::run_global_ctxt::{closure#4}>
  33:     0x564a50cd6761 - rustdoc[fd64ae257ec160cb]::core::run_global_ctxt
  34:     0x564a50decd8f - <rustc_session[d3255eaf8224a584]::session::Session>::time::<(rustdoc[fd64ae257ec160cb]::clean::types::Crate, rustdoc[fd64ae257ec160cb]::config::RenderOptions, rustdoc[fd64ae257ec160cb]::formats::cache::Cache), rustdoc[fd64ae257ec160cb]::main_options::{closure#0}::{closure#0}::{closure#1}::{closure#0}>
  35:     0x564a50d3f381 - <rustc_interface[f0f2c906f605917e]::passes::QueryContext>::enter::<rustdoc[fd64ae257ec160cb]::main_options::{closure#0}::{closure#0}::{closure#1}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>
  36:     0x564a50c8f12b - <rustc_interface[f0f2c906f605917e]::interface::Compiler>::enter::<rustdoc[fd64ae257ec160cb]::main_options::{closure#0}::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>
  37:     0x564a50e63a80 - rustc_span[a9093c78adc8a30e]::with_source_map::<core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>, rustc_interface[f0f2c906f605917e]::interface::create_compiler_and_run<core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>, rustdoc[fd64ae257ec160cb]::main_options::{closure#0}>::{closure#1}>
  38:     0x564a50cbe51e - rustc_interface[f0f2c906f605917e]::interface::create_compiler_and_run::<core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>, rustdoc[fd64ae257ec160cb]::main_options::{closure#0}>
  39:     0x564a50b4bea0 - rustdoc[fd64ae257ec160cb]::main_options
  40:     0x564a50c9088b - <scoped_tls[77ed516bf348563d]::ScopedKey<rustc_span[a9093c78adc8a30e]::SessionGlobals>>::set::<rustdoc[fd64ae257ec160cb]::main_args::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>
  41:     0x564a50e028b0 - std[1bac5bf8d99344e6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f0f2c906f605917e]::util::run_in_thread_pool_with_globals<rustdoc[fd64ae257ec160cb]::main_args::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>
  42:     0x564a50cc2dec - <<std[1bac5bf8d99344e6]::thread::Builder>::spawn_unchecked_<rustc_interface[f0f2c906f605917e]::util::run_in_thread_pool_with_globals<rustdoc[fd64ae257ec160cb]::main_args::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>::{closure#1} as core[de81bf0691074480]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7fe77457d393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd5e3cab38cec9739
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/alloc/src/boxed.rs:1938:9
  44:     0x7fe77457d393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h970a034a5216df96
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/alloc/src/boxed.rs:1938:9
  45:     0x7fe77457d393 - std::sys::unix::thread::Thread::new::thread_start::h19f111f22a37ea01
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys/unix/thread.rs:108:17
  46:     0x7fe7742b578d - <unknown>
  47:     0x7fe7743368e4 - clone
  48:                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.66.0-nightly (ce7f0f1aa 2022-09-28) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: unexpected const parent in type_of(): TypeBinding(TypeBinding { hir_id: HirId { owner: OwnerId { def_id: DefId(0:4 ~ issue_102335_const[6795]::T::A) }, local_id: 3 }, ident: X#0, gen_args: GenericArgs { args: [], bindings: [], parenthesized: false, span_ext: no-location (#0) }, kind: Equality { term: Const(AnonConst { hir_id: HirId { owner: OwnerId { def_id: DefId(0:4 ~ issue_102335_const[6795]::T::A) }, local_id: 1 }, body: BodyId { hir_id: HirId { owner: OwnerId { def_id: DefId(0:4 ~ issue_102335_const[6795]::T::A) }, local_id: 2 } } }) }, span: ./src/test/ui/associated-consts/issue-102335-const.rs:4:17: 4:25 (#0) })
  |
  = note: delayed at compiler/rustc_hir_analysis/src/collect/type_of.rs:456:23

error: internal compiler error: Const::from_anon_const: couldn't lit_to_const TypeError
 --> ./src/test/ui/associated-consts/issue-102335-const.rs:4:21
  |
4 |     type A: S<C<X = 0i32> = 34>;
  |                     ^^^^
  |
  = note: delayed at compiler/rustc_middle/src/ty/consts.rs:122:30

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1530:13
stack backtrace:
   0:     0x7fe774570170 - std::backtrace_rs::backtrace::libunwind::trace::hac9b0f7f9661e748
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7fe774570170 - std::backtrace_rs::backtrace::trace_unsynchronized::hc44795987fc42d34
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe774570170 - std::sys_common::backtrace::_print_fmt::h11541e17c3fc86a7
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fe774570170 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc17ff1666cc882db
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fe7745cae2e - core::fmt::write::h55fcab10ae826150
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/core/src/fmt/mod.rs:1209:17
   5:     0x7fe774560db5 - std::io::Write::write_fmt::hf963d6d18d14f181
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/io/mod.rs:1679:15
   6:     0x7fe774572ef3 - std::sys_common::backtrace::_print::h994ce2c0e5b405c8
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fe774572ef3 - std::sys_common::backtrace::print::hcc56026dcd969e04
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fe774572ef3 - std::panicking::default_hook::{{closure}}::h88f2c5d855241086
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/panicking.rs:267:22
   9:     0x7fe774572bdf - std::panicking::default_hook::h8c95d81babfc3452
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/panicking.rs:286:9
  10:     0x7fe776da8801 - rustc_driver[b4131074c7377c18]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fe77457372b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h67c5cbe4132c274b
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/alloc/src/boxed.rs:1952:9
  12:     0x7fe77457372b - std::panicking::rust_panic_with_hook::h60207dae86acc93c
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/panicking.rs:673:13
  13:     0x7fe777ec1701 - std[1bac5bf8d99344e6]::panicking::begin_panic::<rustc_errors[6dd3b64aee5d90d7]::ExplicitBug>::{closure#0}
  14:     0x7fe777ec0026 - std[1bac5bf8d99344e6]::sys_common::backtrace::__rust_end_short_backtrace::<std[1bac5bf8d99344e6]::panicking::begin_panic<rustc_errors[6dd3b64aee5d90d7]::ExplicitBug>::{closure#0}, !>
  15:     0x7fe777eb9fb6 - std[1bac5bf8d99344e6]::panicking::begin_panic::<rustc_errors[6dd3b64aee5d90d7]::ExplicitBug>
  16:     0x7fe777ebc7d6 - std[1bac5bf8d99344e6]::panic::panic_any::<rustc_errors[6dd3b64aee5d90d7]::ExplicitBug>
  17:     0x7fe7769151c8 - <rustc_errors[6dd3b64aee5d90d7]::HandlerInner as core[de81bf0691074480]::ops::drop::Drop>::drop
  18:     0x564a50e54c78 - core[de81bf0691074480]::ptr::drop_in_place::<rustc_session[d3255eaf8224a584]::parse::ParseSess>
  19:     0x564a50e5e698 - <alloc[c8bb264001a6b8ff]::rc::Rc<rustc_session[d3255eaf8224a584]::session::Session> as core[de81bf0691074480]::ops::drop::Drop>::drop
  20:     0x564a50e79b2d - core[de81bf0691074480]::ptr::drop_in_place::<rustc_interface[f0f2c906f605917e]::interface::Compiler>
  21:     0x564a50e63c40 - rustc_span[a9093c78adc8a30e]::with_source_map::<core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>, rustc_interface[f0f2c906f605917e]::interface::create_compiler_and_run<core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>, rustdoc[fd64ae257ec160cb]::main_options::{closure#0}>::{closure#1}>
  22:     0x564a50cbe51e - rustc_interface[f0f2c906f605917e]::interface::create_compiler_and_run::<core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>, rustdoc[fd64ae257ec160cb]::main_options::{closure#0}>
  23:     0x564a50b4bea0 - rustdoc[fd64ae257ec160cb]::main_options
  24:     0x564a50c9088b - <scoped_tls[77ed516bf348563d]::ScopedKey<rustc_span[a9093c78adc8a30e]::SessionGlobals>>::set::<rustdoc[fd64ae257ec160cb]::main_args::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>
  25:     0x564a50e028b0 - std[1bac5bf8d99344e6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f0f2c906f605917e]::util::run_in_thread_pool_with_globals<rustdoc[fd64ae257ec160cb]::main_args::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>
  26:     0x564a50cc2dec - <<std[1bac5bf8d99344e6]::thread::Builder>::spawn_unchecked_<rustc_interface[f0f2c906f605917e]::util::run_in_thread_pool_with_globals<rustdoc[fd64ae257ec160cb]::main_args::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>::{closure#1} as core[de81bf0691074480]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7fe77457d393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd5e3cab38cec9739
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/alloc/src/boxed.rs:1938:9
  28:     0x7fe77457d393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h970a034a5216df96
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/alloc/src/boxed.rs:1938:9
  29:     0x7fe77457d393 - std::sys::unix::thread::Thread::new::thread_start::h19f111f22a37ea01
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys/unix/thread.rs:108:17
  30:     0x7fe7742b578d - <unknown>
  31:     0x7fe7743368e4 - clone
  32:                0x0 - <unknown>

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.66.0-nightly (ce7f0f1aa 2022-09-28) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
[1]    203826 IOT instruction (core dumped)  rustdoc ./src/test/ui/associated-consts/issue-102335-const.rs

@matthiaskrgr matthiaskrgr added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. labels Sep 29, 2022
@GuillaumeGomez
Copy link
Member

For an unknown reason, it doesn't fail before we're way into the clean part of rustdoc when calling from_anon_const.

@GuillaumeGomez
Copy link
Member

I tried this:

diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index 4d262ae0f5e..684c657620a 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -1011,6 +1011,16 @@ pub fn abort_if_errors(&self) {
         self.inner.borrow_mut().abort_if_errors()
     }
 
+    pub fn abort_if_errors_or_delayed_span_bugs(&self) {
+        self.abort_if_errors();
+        let mut inner = self.inner.borrow();
+        if inner.has_delayed_span_bugs() {
+            let bugs = inner.delayed_span_bugs.clone();
+            inner.flush_delayed(bugs, "no errors encountered even though `delay_span_bug` issued");
+            FatalError.raise();
+        }
+    }
+
     /// `true` if we haven't taught a diagnostic with this code already.
     /// The caller must then teach the user about such a diagnostic.
     ///
@@ -1414,7 +1424,10 @@ fn has_errors_or_lint_errors(&self) -> bool {
         self.has_errors() || self.lint_err_count > 0
     }
     fn has_errors_or_delayed_span_bugs(&self) -> bool {
-        self.has_errors() || !self.delayed_span_bugs.is_empty()
+        self.has_errors() || !self.has_delayed_span_bugs()
+    }
+    fn has_delayed_span_bugs(&self) -> bool {
+        !self.delayed_span_bugs.is_empty()
     }
     fn has_any_message(&self) -> bool {
         self.err_count() > 0 || self.lint_err_count > 0 || self.warn_count > 0
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs
index 0142e981766..0e4afbcf191 100644
--- a/compiler/rustc_session/src/session.rs
+++ b/compiler/rustc_session/src/session.rs
@@ -555,6 +555,9 @@ pub fn has_errors_or_delayed_span_bugs(&self) -> bool {
     pub fn abort_if_errors(&self) {
         self.diagnostic().abort_if_errors();
     }
+    pub fn abort_if_errors_or_delayed_span_bugs(&self) {
+        self.diagnostic().abort_if_errors_or_delayed_span_bugs();
+    }
     pub fn compile_status(&self) -> Result<(), ErrorGuaranteed> {
         if let Some(reported) = self.diagnostic().has_errors_or_lint_errors() {
             let _ = self.diagnostic().emit_stashed_diagnostics();
diff --git a/library/stdarch b/library/stdarch
--- a/library/stdarch
+++ b/library/stdarch
@@ -1 +1 @@
-Subproject commit 699c093a42283c07e9763b4c19439a900ae2d321
+Subproject commit 699c093a42283c07e9763b4c19439a900ae2d321-dirty
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 704292c1048..a75b0c592d3 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -381,7 +381,9 @@ fn clean_hir_term<'tcx>(term: &hir::Term<'tcx>, cx: &mut DocContext<'tcx>) -> Te
         hir::Term::Ty(ty) => Term::Type(clean_ty(ty, cx)),
         hir::Term::Const(c) => {
             let def_id = cx.tcx.hir().local_def_id(c.hir_id);
-            Term::Constant(clean_middle_const(ty::Const::from_anon_const(cx.tcx, def_id), cx))
+            let ty = ty::Const::from_anon_const(cx.tcx, def_id);
+            cx.tcx.sess.abort_if_errors_or_delayed_span_bugs();
+            Term::Constant(clean_middle_const(ty, cx))
         }
     }
 }

But unfortunately the result still looks bad:

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: unexpected const parent in type_of(): TypeBinding(TypeBinding { hir_id: HirId { owner: OwnerId { def_id: DefId(0:2 ~ foo[dca6]::T::A) }, local_id: 3 }, ident: X#0, gen_args: GenericArgs { args: [], bindings: [], parenthesized: false, span_ext: no-location (#0) }, kind: Equality { term: Const(AnonConst { hir_id: HirId { owner: OwnerId { def_id: DefId(0:2 ~ foo[dca6]::T::A) }, local_id: 1 }, body: BodyId { hir_id: HirId { owner: OwnerId { def_id: DefId(0:2 ~ foo[dca6]::T::A) }, local_id: 2 } } }) }, span: foo.rs:8:17: 8:25 (#0) })
  |
  = note: delayed at compiler/rustc_hir_analysis/src/collect/type_of.rs:456:23

error: internal compiler error: Const::from_anon_const: couldn't lit_to_const TypeError
 --> foo.rs:8:21
  |
8 |     type A: S<C<X = 0i32> = 34>;
  |                     ^^^^
  |
  = note: delayed at compiler/rustc_middle/src/ty/consts.rs:122:30

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1542:13
stack backtrace:
   0:     0x7fdf469a2090 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h69c219382a706de4
   1:     0x7fdf46a0f84e - core::fmt::write::hfaba6c7f5d324983
   2:     0x7fdf469716d5 - std::io::Write::write_fmt::he0f5763098f70719
   3:     0x7fdf46984e04 - std::panicking::default_hook::{{closure}}::hadd9f7be4096b7a1
   4:     0x7fdf46984a58 - std::panicking::default_hook::h7c40de63bd1ac842
   5:     0x7fdf4710b826 - rustc_driver[bf5b15a4efa2da32]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:     0x7fdf469855bd - std::panicking::rust_panic_with_hook::hd33806f1a523247b
   7:     0x7fdf49a967a3 - std[77418543e64ae431]::panicking::begin_panic::<rustc_errors[e621a6510cc517c5]::ExplicitBug>::{closure#0}
   8:     0x7fdf49a95cd6 - std[77418543e64ae431]::sys_common::backtrace::__rust_end_short_backtrace::<std[77418543e64ae431]::panicking::begin_panic<rustc_errors[e621a6510cc517c5]::ExplicitBug>::{closure#0}, !>
   9:     0x7fdf470e5496 - std[77418543e64ae431]::panicking::begin_panic::<rustc_errors[e621a6510cc517c5]::ExplicitBug>
  10:     0x7fdf49a8b096 - std[77418543e64ae431]::panic::panic_any::<rustc_errors[e621a6510cc517c5]::ExplicitBug>
  11:     0x7fdf49a93579 - <rustc_errors[e621a6510cc517c5]::HandlerInner>::flush_delayed::<alloc[344271dbb998174e]::vec::Vec<rustc_errors[e621a6510cc517c5]::diagnostic::Diagnostic>, &str>
  12:     0x7fdf49a91b6a - <rustc_errors[e621a6510cc517c5]::Handler>::abort_if_errors_or_delayed_span_bugs
  13:     0x55bf9d4f5f5e - rustdoc[3755b0600f342e0c]::clean::clean_generic_args
  14:     0x55bf9d4f5e38 - rustdoc[3755b0600f342e0c]::clean::clean_generic_args
  15:     0x55bf9d5f381d - <alloc[344271dbb998174e]::vec::Vec<rustdoc[3755b0600f342e0c]::clean::types::PathSegment> as alloc[344271dbb998174e]::vec::spec_from_iter::SpecFromIter<rustdoc[3755b0600f342e0c]::clean::types::PathSegment, core[d55ced6309a25c5f]::iter::adapters::map::Map<core[d55ced6309a25c5f]::slice::iter::Iter<rustc_hir[854dfe8484ba389]::hir::PathSegment>, rustdoc[3755b0600f342e0c]::clean::clean_path::{closure#0}>>>::from_iter
  16:     0x55bf9d4ef83e - rustdoc[3755b0600f342e0c]::clean::clean_poly_trait_ref
  17:     0x55bf9d4eaa0b - rustdoc[3755b0600f342e0c]::clean::clean_generic_bound
  18:     0x55bf9d5f46ae - <alloc[344271dbb998174e]::vec::Vec<rustdoc[3755b0600f342e0c]::clean::types::GenericBound> as alloc[344271dbb998174e]::vec::spec_from_iter::SpecFromIter<rustdoc[3755b0600f342e0c]::clean::types::GenericBound, core[d55ced6309a25c5f]::iter::adapters::filter_map::FilterMap<core[d55ced6309a25c5f]::slice::iter::Iter<rustc_hir[854dfe8484ba389]::hir::GenericBound>, rustdoc[3755b0600f342e0c]::clean::clean_maybe_renamed_item::{closure#1}::{closure#0}>>>::from_iter
  19:     0x55bf9d3f6364 - <rustdoc[3755b0600f342e0c]::core::DocContext>::with_param_env::<rustdoc[3755b0600f342e0c]::clean::types::Item, rustdoc[3755b0600f342e0c]::clean::clean_trait_item::{closure#0}>
  20:     0x55bf9d5f9811 - <alloc[344271dbb998174e]::vec::Vec<rustdoc[3755b0600f342e0c]::clean::types::Item> as alloc[344271dbb998174e]::vec::spec_from_iter::SpecFromIter<rustdoc[3755b0600f342e0c]::clean::types::Item, core[d55ced6309a25c5f]::iter::adapters::map::Map<core[d55ced6309a25c5f]::slice::iter::Iter<rustc_hir[854dfe8484ba389]::hir::TraitItemRef>, rustdoc[3755b0600f342e0c]::clean::clean_maybe_renamed_item::{closure#1}::{closure#5}>>>::from_iter
  21:     0x55bf9d3f4197 - <rustdoc[3755b0600f342e0c]::core::DocContext>::with_param_env::<alloc[344271dbb998174e]::vec::Vec<rustdoc[3755b0600f342e0c]::clean::types::Item>, rustdoc[3755b0600f342e0c]::clean::clean_maybe_renamed_item::{closure#1}>
  22:     0x55bf9d4e8ffb - <&mut rustdoc[3755b0600f342e0c]::clean::clean_doc_module::{closure#2} as core[d55ced6309a25c5f]::ops::function::FnOnce<(&(&rustc_hir[854dfe8484ba389]::hir::Item, core[d55ced6309a25c5f]::option::Option<rustc_span[a05d955188b2abc7]::symbol::Symbol>),)>>::call_once
  23:     0x55bf9d5ea13a - <alloc[344271dbb998174e]::vec::Vec<rustdoc[3755b0600f342e0c]::clean::types::Item> as alloc[344271dbb998174e]::vec::spec_extend::SpecExtend<rustdoc[3755b0600f342e0c]::clean::types::Item, core[d55ced6309a25c5f]::iter::adapters::flatten::FlatMap<core[d55ced6309a25c5f]::slice::iter::Iter<(&rustc_hir[854dfe8484ba389]::hir::Item, core[d55ced6309a25c5f]::option::Option<rustc_span[a05d955188b2abc7]::symbol::Symbol>)>, alloc[344271dbb998174e]::vec::Vec<rustdoc[3755b0600f342e0c]::clean::types::Item>, rustdoc[3755b0600f342e0c]::clean::clean_doc_module::{closure#2}>>>::spec_extend
  24:     0x55bf9d4ea640 - rustdoc[3755b0600f342e0c]::clean::clean_doc_module
  25:     0x55bf9d679374 - rustdoc[3755b0600f342e0c]::clean::utils::krate
  26:     0x55bf9d50ce44 - <rustc_session[605dacab06639d89]::session::Session>::time::<rustdoc[3755b0600f342e0c]::clean::types::Crate, rustdoc[3755b0600f342e0c]::core::run_global_ctxt::{closure#4}>
  27:     0x55bf9d3fb9c1 - rustdoc[3755b0600f342e0c]::core::run_global_ctxt
  28:     0x55bf9d50d26f - <rustc_session[605dacab06639d89]::session::Session>::time::<(rustdoc[3755b0600f342e0c]::clean::types::Crate, rustdoc[3755b0600f342e0c]::config::RenderOptions, rustdoc[3755b0600f342e0c]::formats::cache::Cache), rustdoc[3755b0600f342e0c]::main_options::{closure#0}::{closure#0}::{closure#1}::{closure#0}>
  29:     0x55bf9d463261 - <rustc_interface[158590035fe8886d]::passes::QueryContext>::enter::<rustdoc[3755b0600f342e0c]::main_options::{closure#0}::{closure#0}::{closure#1}, core[d55ced6309a25c5f]::result::Result<(), rustc_errors[e621a6510cc517c5]::ErrorGuaranteed>>
  30:     0x55bf9d3b536b - <rustc_interface[158590035fe8886d]::interface::Compiler>::enter::<rustdoc[3755b0600f342e0c]::main_options::{closure#0}::{closure#0}, core[d55ced6309a25c5f]::result::Result<(), rustc_errors[e621a6510cc517c5]::ErrorGuaranteed>>
  31:     0x55bf9d5834b0 - rustc_span[a05d955188b2abc7]::with_source_map::<core[d55ced6309a25c5f]::result::Result<(), rustc_errors[e621a6510cc517c5]::ErrorGuaranteed>, rustc_interface[158590035fe8886d]::interface::create_compiler_and_run<core[d55ced6309a25c5f]::result::Result<(), rustc_errors[e621a6510cc517c5]::ErrorGuaranteed>, rustdoc[3755b0600f342e0c]::main_options::{closure#0}>::{closure#1}>
  32:     0x55bf9d3b949e - rustc_interface[158590035fe8886d]::interface::create_compiler_and_run::<core[d55ced6309a25c5f]::result::Result<(), rustc_errors[e621a6510cc517c5]::ErrorGuaranteed>, rustdoc[3755b0600f342e0c]::main_options::{closure#0}>
  33:     0x55bf9d3b36e0 - rustdoc[3755b0600f342e0c]::main_options
  34:     0x55bf9d3b693b - <scoped_tls[10d8a9c768e14d1c]::ScopedKey<rustc_span[a05d955188b2abc7]::SessionGlobals>>::set::<rustdoc[3755b0600f342e0c]::main_args::{closure#0}, core[d55ced6309a25c5f]::result::Result<(), rustc_errors[e621a6510cc517c5]::ErrorGuaranteed>>
  35:     0x55bf9d522de0 - std[77418543e64ae431]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[158590035fe8886d]::util::run_in_thread_pool_with_globals<rustdoc[3755b0600f342e0c]::main_args::{closure#0}, core[d55ced6309a25c5f]::result::Result<(), rustc_errors[e621a6510cc517c5]::ErrorGuaranteed>>::{closure#0}, core[d55ced6309a25c5f]::result::Result<(), rustc_errors[e621a6510cc517c5]::ErrorGuaranteed>>
  36:     0x55bf9d3e80ac - <<std[77418543e64ae431]::thread::Builder>::spawn_unchecked_<rustc_interface[158590035fe8886d]::util::run_in_thread_pool_with_globals<rustdoc[3755b0600f342e0c]::main_args::{closure#0}, core[d55ced6309a25c5f]::result::Result<(), rustc_errors[e621a6510cc517c5]::ErrorGuaranteed>>::{closure#0}, core[d55ced6309a25c5f]::result::Result<(), rustc_errors[e621a6510cc517c5]::ErrorGuaranteed>>::{closure#1} as core[d55ced6309a25c5f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7fdf4695eaf3 - std::sys::unix::thread::Thread::new::thread_start::heafa918dcc1208d8
  38:     0x7fdf46624b43 - start_thread
                               at ./nptl/./nptl/pthread_create.c:442:8
  39:     0x7fdf466b6a00 - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  40:                0x0 - <unknown>

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.66.0-dev running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 3 previous errors

Not sure what's going on and why this error appears this late.

@matthiaskrgr
Copy link
Member Author

@GuillaumeGomez Hm, is it worth committing that? 🙂
In other examples like #96287 we don't get any information at all on what the underlying error is and rustdoc just says thread 'rustc' panicked at 'Error', src/librustdoc/clean/mod.rs:1671:29

I know that there are perhaps 5-10 ices that all have this thread 'rustc' panicked at 'Error' message and its hard for me to tell if they all have the same cause or are actually due to different underlying issues. :/

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Sep 30, 2022

I can provide a PR with this change if you want, but I'm not sure it's much of an improvement... Oh well. Pushing a PR and then you'll decide if you want it or not.

@compiler-errors
Copy link
Member

This errors correctly on rustdoc now, needs test

@compiler-errors compiler-errors added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Sep 22, 2023
@GuillaumeGomez
Copy link
Member

I'll add it tomorrow then. Thanks for the heads up!

@GuillaumeGomez GuillaumeGomez self-assigned this Sep 23, 2023
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 24, 2023
@bors bors closed this as completed in a1c7a1c Sep 24, 2023
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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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.

3 participants