Skip to content

-Zverbose hrlt pretty printing ICE #98594

Closed
@lcnr

Description

@lcnr
#![allow(unused_parens)]
trait Foo {
    type Assoc;
}

fn called()
where
    for<'b> fn(&'b ()): Foo,
{
}

fn caller()
where
    (for<'a> fn(&'a ())): Foo,
{
    called()
}

fn main() {}

with rustc src/main.rs -Zverbose causes the following ICE (godbolt)

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', compiler/rustc_middle/src/ty/print/pretty.rs:2202:28
thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', compiler/rustc_middle/src/ty/print/pretty.rs:2202:28
stack backtrace:
   0:     0x7f6782cca18d - std::backtrace_rs::backtrace::libunwind::trace::hb1109710b5bac759
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f6782cca18d - std::backtrace_rs::backtrace::trace_unsynchronized::h785364b6aed0029a
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f6782cca18d - std::sys_common::backtrace::_print_fmt::h74f64f39298dd76e
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f6782cca18d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h496e3b79162d5554
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f6782d25f7c - core::fmt::write::hab33fa5859262fe7
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/fmt/mod.rs:1197:17
   5:     0x7f6782cbb801 - std::io::Write::write_fmt::h1710e3e0ee173be1
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/io/mod.rs:1672:15
   6:     0x7f6782ccce55 - std::sys_common::backtrace::_print::h2a4a41c4c8a478e3
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f6782ccce55 - std::sys_common::backtrace::print::h04d400740890388f
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f6782ccce55 - std::panicking::default_hook::{{closure}}::h33882b41ce9ace17
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/panicking.rs:295:22
   9:     0x7f6782cccb76 - std::panicking::default_hook::hed13b5f1fa769ff8
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/panicking.rs:314:9
  10:     0x7f67834b8804 - rustc_driver[2985e0c6160588b5]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f6782ccd52a - std::panicking::rust_panic_with_hook::hfb6f3749c685320d
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/panicking.rs:702:17
  12:     0x7f6782ccd367 - std::panicking::begin_panic_handler::{{closure}}::h99f3f91cb6d654a6
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/panicking.rs:588:13
  13:     0x7f6782cca644 - std::sys_common::backtrace::__rust_end_short_backtrace::h1d5304cdf1728a1c
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f6782ccd099 - rust_begin_unwind
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/panicking.rs:584:5
  15:     0x7f6782c92263 - core::panicking::panic_fmt::hce2c0129c83bc4c4
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/panicking.rs:142:14
  16:     0x7f6782c921a2 - core::panicking::panic_bounds_check::hf7c8174e31d6b971
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/panicking.rs:84:5
  17:     0x7f6784562157 - <alloc[318c0fc51e3c1903]::collections::btree::map::entry::Entry<rustc_middle[e91eda85edc2d458]::ty::sty::BoundRegion, rustc_middle[e91eda85edc2d458]::ty::sty::Region>>::or_insert_with::<<rustc_middle[e91eda85edc2d458]::ty::context::TyCtxt>::replace_late_bound_regions<rustc_middle[e91eda85edc2d458]::ty::print::pretty::TraitRefPrintOnlyTraitPath, <rustc_middle[e91eda85edc2d458]::ty::print::pretty::FmtPrinter>::name_all_regions<rustc_middle[e91eda85edc2d458]::ty::print::pretty::TraitRefPrintOnlyTraitPath>::{closure#4}>::{closure#0}::{closure#0}>
  18:     0x7f67845d971d - <rustc_middle[e91eda85edc2d458]::ty::context::TyCtxt>::replace_late_bound_regions::<rustc_middle[e91eda85edc2d458]::ty::TraitPredicate, <rustc_middle[e91eda85edc2d458]::ty::print::pretty::FmtPrinter>::name_all_regions<rustc_middle[e91eda85edc2d458]::ty::TraitPredicate>::{closure#4}>::{closure#0}
  19:     0x7f67855ad509 - <rustc_middle[e91eda85edc2d458]::ty::fold::BoundVarReplacer as rustc_middle[e91eda85edc2d458]::ty::fold::FallibleTypeFolder>::try_fold_ty
  20:     0x7f678550d071 - <&rustc_middle[e91eda85edc2d458]::ty::list::List<rustc_middle[e91eda85edc2d458]::ty::Ty> as rustc_middle[e91eda85edc2d458]::ty::fold::TypeFoldable>::try_fold_with::<rustc_middle[e91eda85edc2d458]::ty::fold::BoundVarReplacer>
  21:     0x7f67855dc844 - <rustc_middle[e91eda85edc2d458]::ty::Ty as rustc_middle[e91eda85edc2d458]::ty::fold::TypeSuperFoldable>::super_fold_with::<rustc_middle[e91eda85edc2d458]::ty::fold::BoundVarReplacer>
  22:     0x7f678550894b - <&rustc_middle[e91eda85edc2d458]::ty::list::List<rustc_middle[e91eda85edc2d458]::ty::subst::GenericArg> as rustc_middle[e91eda85edc2d458]::ty::fold::TypeFoldable>::try_fold_with::<rustc_middle[e91eda85edc2d458]::ty::fold::BoundVarReplacer>
  23:     0x7f67845beeaa - <rustc_middle[e91eda85edc2d458]::ty::TraitPredicate as rustc_middle[e91eda85edc2d458]::ty::fold::TypeFoldable>::fold_with::<rustc_middle[e91eda85edc2d458]::ty::fold::BoundVarReplacer>
  24:     0x7f67845d8788 - <rustc_middle[e91eda85edc2d458]::ty::context::TyCtxt>::replace_late_bound_regions::<rustc_middle[e91eda85edc2d458]::ty::TraitPredicate, <rustc_middle[e91eda85edc2d458]::ty::print::pretty::FmtPrinter>::name_all_regions<rustc_middle[e91eda85edc2d458]::ty::TraitPredicate>::{closure#4}>
  25:     0x7f678452e4fd - <rustc_middle[e91eda85edc2d458]::ty::print::pretty::FmtPrinter as rustc_middle[e91eda85edc2d458]::ty::print::pretty::PrettyPrinter>::in_binder::<rustc_middle[e91eda85edc2d458]::ty::TraitPredicate>
  26:     0x7f678457e69f - <rustc_middle[e91eda85edc2d458]::ty::sty::Binder<rustc_middle[e91eda85edc2d458]::ty::TraitPredicate> as core[1c8f1df5a59aa66f]::fmt::Display>::fmt
  27:     0x7f6782d25f7c - core::fmt::write::hab33fa5859262fe7
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/fmt/mod.rs:1197:17
  28:     0x7f6782d189d9 - core::fmt::Write::write_fmt::h3eddb09f8b8e3862
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/fmt/mod.rs:187:9
  29:     0x7f6782d189d9 - alloc::fmt::format::format_inner::h3d59f3ae20d36a53
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/alloc/src/fmt.rs:612:9
  30:     0x7f67843852dc - <rustc_infer[fac6976779193def]::infer::InferCtxt as rustc_trait_selection[ea8af3ec51aca8b4]::traits::error_reporting::InferCtxtExt>::report_selection_error
  31:     0x7f6784390051 - <rustc_infer[fac6976779193def]::infer::InferCtxt as rustc_trait_selection[ea8af3ec51aca8b4]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  32:     0x7f67843824b7 - <rustc_infer[fac6976779193def]::infer::InferCtxt as rustc_trait_selection[ea8af3ec51aca8b4]::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
  33:     0x7f6784a789fd - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_argument_types
  34:     0x7f6784a5644e - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_call
  35:     0x7f6784aa9b55 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_expr_kind
  36:     0x7f6784aa8bf0 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  37:     0x7f6784a97cce - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  38:     0x7f6784aa9ec3 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_expr_kind
  39:     0x7f6784aa8bf0 - <rustc_typeck[9766a23a180a54e4]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  40:     0x7f6784adac06 - rustc_typeck[9766a23a180a54e4]::check::check::check_fn
  41:     0x7f6784b6f3fe - <rustc_infer[fac6976779193def]::infer::InferCtxtBuilder>::enter::<&rustc_middle[e91eda85edc2d458]::ty::context::TypeckResults, <rustc_typeck[9766a23a180a54e4]::check::inherited::InheritedBuilder>::enter<rustc_typeck[9766a23a180a54e4]::check::typeck_with_fallback<rustc_typeck[9766a23a180a54e4]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[e91eda85edc2d458]::ty::context::TypeckResults>::{closure#0}>
  42:     0x7f6784af97ba - rustc_typeck[9766a23a180a54e4]::check::typeck
  43:     0x7f67850b0984 - rustc_query_system[a80f8bd821f477c6]::query::plumbing::try_execute_query::<rustc_query_impl[bc93cb9e73dff18e]::plumbing::QueryCtxt, rustc_query_system[a80f8bd821f477c6]::query::caches::DefaultCache<rustc_span[8b48bd2bfbcc9443]::def_id::LocalDefId, &rustc_middle[e91eda85edc2d458]::ty::context::TypeckResults>>
  44:     0x7f6785086cde - <rustc_query_impl[bc93cb9e73dff18e]::Queries as rustc_middle[e91eda85edc2d458]::ty::query::QueryEngine>::typeck
  45:     0x7f6784b965b8 - <rustc_middle[e91eda85edc2d458]::hir::map::Map>::par_body_owners::<rustc_typeck[9766a23a180a54e4]::check::typeck_item_bodies::{closure#0}>
  46:     0x7f678594e1fc - rustc_typeck[9766a23a180a54e4]::check::typeck_item_bodies
  47:     0x7f6785c4875c - rustc_query_system[a80f8bd821f477c6]::query::plumbing::try_execute_query::<rustc_query_impl[bc93cb9e73dff18e]::plumbing::QueryCtxt, rustc_query_system[a80f8bd821f477c6]::query::caches::DefaultCache<(), ()>>
  48:     0x7f6785c75ac1 - rustc_query_system[a80f8bd821f477c6]::query::plumbing::get_query::<rustc_query_impl[bc93cb9e73dff18e]::queries::typeck_item_bodies, rustc_query_impl[bc93cb9e73dff18e]::plumbing::QueryCtxt>
  49:     0x7f6785973df3 - <rustc_session[a46327cfa276e5ae]::session::Session>::time::<(), rustc_typeck[9766a23a180a54e4]::check_crate::{closure#7}>
  50:     0x7f678596a573 - rustc_typeck[9766a23a180a54e4]::check_crate
  51:     0x7f67856dc067 - rustc_interface[3f74620ae1096927]::passes::analysis
  52:     0x7f6785c3dc8f - rustc_query_system[a80f8bd821f477c6]::query::plumbing::try_execute_query::<rustc_query_impl[bc93cb9e73dff18e]::plumbing::QueryCtxt, rustc_query_system[a80f8bd821f477c6]::query::caches::DefaultCache<(), core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>>
  53:     0x7f6785c8801e - rustc_query_system[a80f8bd821f477c6]::query::plumbing::get_query::<rustc_query_impl[bc93cb9e73dff18e]::queries::analysis, rustc_query_impl[bc93cb9e73dff18e]::plumbing::QueryCtxt>
  54:     0x7f67856bfe37 - <rustc_interface[3f74620ae1096927]::passes::QueryContext>::enter::<rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>
  55:     0x7f67856aa11f - <rustc_interface[3f74620ae1096927]::interface::Compiler>::enter::<rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}::{closure#2}, core[1c8f1df5a59aa66f]::result::Result<core[1c8f1df5a59aa66f]::option::Option<rustc_interface[3f74620ae1096927]::queries::Linker>, rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>
  56:     0x7f67856a364f - rustc_span[8b48bd2bfbcc9443]::with_source_map::<core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>, rustc_interface[3f74620ae1096927]::interface::create_compiler_and_run<core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>, rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}>::{closure#1}>
  57:     0x7f67856aafb2 - <scoped_tls[3b74a2cd32801712]::ScopedKey<rustc_span[8b48bd2bfbcc9443]::SessionGlobals>>::set::<rustc_interface[3f74620ae1096927]::interface::run_compiler<core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>, rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}>::{closure#0}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>
  58:     0x7f67856c04bf - std[183c58237bb308d2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3f74620ae1096927]::util::run_in_thread_pool_with_globals<rustc_interface[3f74620ae1096927]::interface::run_compiler<core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>, rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}>::{closure#0}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>::{closure#0}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>
  59:     0x7f67856c06a9 - <<std[183c58237bb308d2]::thread::Builder>::spawn_unchecked_<rustc_interface[3f74620ae1096927]::util::run_in_thread_pool_with_globals<rustc_interface[3f74620ae1096927]::interface::run_compiler<core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>, rustc_driver[2985e0c6160588b5]::run_compiler::{closure#1}>::{closure#0}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>::{closure#0}, core[1c8f1df5a59aa66f]::result::Result<(), rustc_errors[cc19d71e926465fe]::ErrorGuaranteed>>::{closure#1} as core[1c8f1df5a59aa66f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  60:     0x7f6782cd7463 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha4ec43e0ec331bcb
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/alloc/src/boxed.rs:1951:9
  61:     0x7f6782cd7463 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5e13b6a1911b918e
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/alloc/src/boxed.rs:1951:9
  62:     0x7f6782cd7463 - std::sys::unix::thread::Thread::new::thread_start::h21c45ad5909aa02c
                               at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/sys/unix/thread.rs:108:17
  63:     0x7f6782c01609 - start_thread
  64:     0x7f6782b24163 - clone
  65:                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 (20a6f3a8a 2022-06-25) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=1 -C llvm-args=--x86-asm-syntax=intel --crate-type rlib -Z verbose

query stack during panic:
#0 [typeck] type-checking `caller` [typeck]
#1 [typeck_item_bodies] type-checking all item bodies [typeck_item_bodies]
#2 [analysis] running analysis passes on this crate [analysis]
end of query stack
Compiler returned: 101

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions