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: Layout::compute: unexpected type '_' #126942

Open
Naserume opened this issue Jun 25, 2024 · 5 comments · May be fixed by #127973
Open

ICE: Layout::compute: unexpected type '_' #126942

Naserume opened this issue Jun 25, 2024 · 5 comments · May be fixed by #127973
Assignees
Labels
A-layout Area: Memory layout of types C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Naserume
Copy link

Naserume commented Jun 25, 2024

Code

pub trait A {}
pub trait B: A {}

pub trait Mirror {
    type Assoc: ?Sized;
}
impl<T: ?Sized> Mirror for A {
    type Assoc = T;
}

pub fn foo<'a>(x: &'a <dyn A + 'static as Mirror>::Assoc) -> &'a <dyn B + 'static as Mirror>::Assoc {
    static
}

static I: <dyn A + 'static as Mirror>::Assoc = 3;
pub fn main() {}

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (bcf94dec5 2024-06-23)
binary: rustc
commit-hash: bcf94dec5ba6838e435902120c0384c360126a26
commit-date: 2024-06-23
host: x86_64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7

Error output

error: expected identifier, found `}`
  --> ./6EC19.rs:13:1
   |
13 | }
   | ^ expected identifier

warning: trait objects without an explicit `dyn` are deprecated
 --> ./6EC19.rs:7:28
  |
7 | impl<T: ?Sized> Mirror for A {
  |                            ^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` on by default
help: if this is an object-safe trait, use `dyn`
  |
7 | impl<T: ?Sized> Mirror for dyn A {
  |                            +++
help: alternatively use a blanket implementation to implement `Mirror` for all types that also implement `A`
  |
7 | impl<T: ?Sized, U: A> Mirror for U {
  |               ++++++             ~

error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
 --> ./6EC19.rs:7:6
  |
7 | impl<T: ?Sized> Mirror for A {
  |      ^ unconstrained type parameter

error[E0277]: the trait bound `(dyn B + 'static): Mirror` is not satisfied
  --> ./6EC19.rs:11:62
   |
11 | pub fn foo<'a>(x: &'a <dyn A + 'static as Mirror>::Assoc) -> &'a <dyn B + 'static as Mirror>::Assoc {
   |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Mirror` is not implemented for `(dyn B + 'static)`
   |
   = help: the trait `Mirror` is implemented for `(dyn A + 'static)`

error[E0283]: type annotations needed
  --> ./6EC19.rs:15:11
   |
15 | static I: <dyn A + 'static as Mirror>::Assoc = 3;
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
   |
   = note: cannot satisfy `_: Sync`
   = note: shared static variables must have a type that implements `Sync`
Backtrace

error: internal compiler error: compiler/rustc_ty_utils/src/layout.rs:674:13: Layout::compute: unexpected type `_`

thread 'rustc' panicked at compiler/rustc_ty_utils/src/layout.rs:674:13:
Box<dyn Any>
stack backtrace:
   0:        0x10cae6b43 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he71f7af0ddafc64d
   1:        0x10cb3225b - core::fmt::write::h30d0e266faff29b6
   2:        0x10cadcace - std::io::Write::write_fmt::he666ca78eb4b8406
   3:        0x10cae6931 - std::sys::backtrace::print::h22721f9ab9a2749a
   4:        0x10cae9709 - std::panicking::default_hook::{{closure}}::h145e29ed875d8021
   5:        0x10cae948a - std::panicking::default_hook::h5d437c7e6bf0e3b5
   6:        0x115d8147c - std[8efa578c02603ef9]::panicking::update_hook::<alloc[135510a28be92df]::boxed::Box<rustc_driver_impl[63f2171535a6fe49]::install_ice_hook::{closure#0}>>::{closure#0}
   7:        0x10caea326 - std::panicking::rust_panic_with_hook::h6889093a56e48d04
   8:        0x115df0337 - std[8efa578c02603ef9]::panicking::begin_panic::<rustc_errors[8995f93e9c4bcc9a]::ExplicitBug>::{closure#0}
   9:        0x115ddc949 - std[8efa578c02603ef9]::sys::backtrace::__rust_end_short_backtrace::<std[8efa578c02603ef9]::panicking::begin_panic<rustc_errors[8995f93e9c4bcc9a]::ExplicitBug>::{closure#0}, !>
  10:        0x11a7e2f09 - std[8efa578c02603ef9]::panicking::begin_panic::<rustc_errors[8995f93e9c4bcc9a]::ExplicitBug>
  11:        0x115e02276 - <rustc_errors[8995f93e9c4bcc9a]::diagnostic::BugAbort as rustc_errors[8995f93e9c4bcc9a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:        0x116a9c95e - rustc_middle[4384e439927f71dd]::util::bug::opt_span_bug_fmt::<rustc_span[aed5394308446158]::span_encoding::Span>::{closure#0}
  13:        0x116a522b7 - rustc_middle[4384e439927f71dd]::ty::context::tls::with_opt::<rustc_middle[4384e439927f71dd]::util::bug::opt_span_bug_fmt<rustc_span[aed5394308446158]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:        0x116a51d75 - rustc_middle[4384e439927f71dd]::ty::context::tls::with_context_opt::<rustc_middle[4384e439927f71dd]::ty::context::tls::with_opt<rustc_middle[4384e439927f71dd]::util::bug::opt_span_bug_fmt<rustc_span[aed5394308446158]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:        0x11a8a57eb - rustc_middle[4384e439927f71dd]::util::bug::bug_fmt
  16:        0x117bc12e7 - rustc_ty_utils[a4413d16294df763]::layout::layout_of_uncached
  17:        0x117bd4076 - rustc_ty_utils[a4413d16294df763]::layout::layout_of
  18:        0x117423276 - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 16usize]>>
  19:        0x1173f2f4e - <rustc_query_impl[a24e9023943e74ab]::query_impl::layout_of::dynamic_query::{closure#2} as core[9412a59d758dca42]::ops::function::FnOnce<(rustc_middle[4384e439927f71dd]::ty::context::TyCtxt, rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_middle[4384e439927f71dd]::ty::Ty>)>>::call_once
  20:        0x11720a655 - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::DefaultCache<rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_middle[4384e439927f71dd]::ty::Ty>, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  21:        0x1174613f4 - rustc_query_impl[a24e9023943e74ab]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  22:        0x117b59d59 - rustc_middle[4384e439927f71dd]::query::plumbing::query_get_at::<rustc_query_system[30bd0146b5104221]::query::caches::DefaultCache<rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_middle[4384e439927f71dd]::ty::Ty>, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 16usize]>>>
  23:        0x117bd4051 - rustc_ty_utils[a4413d16294df763]::layout::layout_of
  24:        0x117423276 - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 16usize]>>
  25:        0x1173f2f4e - <rustc_query_impl[a24e9023943e74ab]::query_impl::layout_of::dynamic_query::{closure#2} as core[9412a59d758dca42]::ops::function::FnOnce<(rustc_middle[4384e439927f71dd]::ty::context::TyCtxt, rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_middle[4384e439927f71dd]::ty::Ty>)>>::call_once
  26:        0x11720a655 - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::DefaultCache<rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_middle[4384e439927f71dd]::ty::Ty>, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  27:        0x1174613f4 - rustc_query_impl[a24e9023943e74ab]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  28:        0x115fac0a6 - rustc_middle[4384e439927f71dd]::query::plumbing::query_get_at::<rustc_query_system[30bd0146b5104221]::query::caches::DefaultCache<rustc_middle[4384e439927f71dd]::ty::ParamEnvAnd<rustc_middle[4384e439927f71dd]::ty::Ty>, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 16usize]>>>
  29:        0x11607bd51 - rustc_hir_analysis[8e62bc6471a04889]::check::check::check_static_inhabited
  30:        0x11607f85d - rustc_hir_analysis[8e62bc6471a04889]::check::check::check_item_type
  31:        0x1160b64ae - rustc_hir_analysis[8e62bc6471a04889]::check::wfcheck::check_well_formed
  32:        0x11741e86c - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 1usize]>>
  33:        0x11729701f - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::VecCache<rustc_hir[ae2456c39d7f6170]::hir_id::OwnerId, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  34:        0x117468280 - rustc_query_impl[a24e9023943e74ab]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  35:        0x115facba2 - rustc_middle[4384e439927f71dd]::query::plumbing::query_ensure_error_guaranteed::<rustc_query_system[30bd0146b5104221]::query::caches::VecCache<rustc_hir[ae2456c39d7f6170]::hir_id::OwnerId, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 1usize]>>, ()>
  36:        0x1160c4de1 - rustc_hir_analysis[8e62bc6471a04889]::check::wfcheck::check_mod_type_wf
  37:        0x11741e83c - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 1usize]>>
  38:        0x11724db79 - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::DefaultCache<rustc_span[aed5394308446158]::def_id::LocalModDefId, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  39:        0x117444ed0 - rustc_query_impl[a24e9023943e74ab]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  40:        0x11614024c - rustc_hir_analysis[8e62bc6471a04889]::check_crate
  41:        0x1166da6cb - rustc_interface[73216d77aad0c3a5]::passes::run_required_analyses
  42:        0x1166dccb3 - rustc_interface[73216d77aad0c3a5]::passes::analysis
  43:        0x117422dec - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 1usize]>>
  44:        0x11720249e - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::SingleCache<rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  45:        0x11742d307 - rustc_query_impl[a24e9023943e74ab]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  46:        0x115d258d7 - <rustc_interface[73216d77aad0c3a5]::queries::QueryResult<&rustc_middle[4384e439927f71dd]::ty::context::GlobalCtxt>>::enter::<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  47:        0x115d7fc94 - rustc_interface[73216d77aad0c3a5]::interface::run_compiler::<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}>::{closure#1}
  48:        0x115d6ec91 - std[8efa578c02603ef9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_with_globals<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_pool_with_globals<rustc_interface[73216d77aad0c3a5]::interface::run_compiler<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}>::{closure#1}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>
  49:        0x115d8a3a6 - <<std[8efa578c02603ef9]::thread::Builder>::spawn_unchecked_<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_with_globals<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_pool_with_globals<rustc_interface[73216d77aad0c3a5]::interface::run_compiler<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}>::{closure#1}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#2} as core[9412a59d758dca42]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:        0x10caf352b - std::sys::pal::unix::thread::Thread::new::thread_start::h68d49fa26efc1659
  51:     0x7ff801f5318b - __pthread_start

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/Documents/240624-56257.txt` to your bug report

query stack during panic:
panicked at /rustc/bcf94dec5ba6838e435902120c0384c360126a26/compiler/rustc_type_ir/src/ty_kind.rs:889:17:

thread panicked while processing panic. aborting.
zsh: abort      rustc ./6EC19.rs

Similar Issue

Issue #124207 has same ice message with similar backtrace, but this require #![feature(transmutability)] and #![feature(type_alias_impl_trait)] because it uses BikeshedIntrinsicsFrom so I decided to report mine.

@Naserume Naserume 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 Jun 25, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 25, 2024
@GrigorenkoPV
Copy link
Contributor

searched nightlies: from nightly-2022-02-19 to nightly-2024-06-25
regressed nightly: nightly-2024-03-08
searched commit range: 7d3702e...9c3ad80
regressed commit: 8c9a75b (#121154)

@theemathas
Copy link
Contributor

Minimized:

struct Thing;

pub trait Every {
    type Assoc;
}
impl<T: ?Sized> Every for Thing {
    type Assoc = T;
}

static I: <Thing as Every>::Assoc = 3;
Error output
   Compiling playground v0.0.1 (/playground)
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
 --> src/lib.rs:6:6
  |
6 | impl<T: ?Sized> Every for Thing {
  |      ^ unconstrained type parameter

error[E0283]: type annotations needed
  --> src/lib.rs:10:11
   |
10 | static I: <Thing as Every>::Assoc = 3;
   |           ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
   |
   = note: cannot satisfy `_: Sync`
   = note: shared static variables must have a type that implements `Sync`

error: internal compiler error: compiler/rustc_ty_utils/src/layout.rs:676:13: Layout::compute: unexpected type `_`

thread 'rustc' panicked at compiler/rustc_ty_utils/src/layout.rs:676:13:
Box<dyn Any>
stack backtrace:
   0:     0x7f5be3c9b035 - std::backtrace_rs::backtrace::libunwind::trace::h1a07e5dba0da0cd2
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f5be3c9b035 - std::backtrace_rs::backtrace::trace_unsynchronized::h61b9b8394328c0bc
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5be3c9b035 - std::sys_common::backtrace::_print_fmt::h1c5e18b460934cff
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f5be3c9b035 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1e1a1972118942ad
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f5be3cea29b - core::fmt::rt::Argument::fmt::h07af2b4071d536cd
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/rt.rs:165:63
   5:     0x7f5be3cea29b - core::fmt::write::hc090a2ffd6b28c4a
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/mod.rs:1157:21
   6:     0x7f5be3c8fbdf - std::io::Write::write_fmt::h8898bac6ff039a23
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/mod.rs:1832:15
   7:     0x7f5be3c9ae0e - std::sys_common::backtrace::_print::h4e80c5803d4ee35b
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f5be3c9ae0e - std::sys_common::backtrace::print::ha96650907276675e
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f5be3c9d779 - std::panicking::default_hook::{{closure}}::h215c2a0a8346e0e0
  10:     0x7f5be3c9d4bd - std::panicking::default_hook::h207342be97478370
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:298:9
  11:     0x7f5be6b981b7 - std[3c8ba8ebcf555201]::panicking::update_hook::<alloc[bfbae7e348dce413]::boxed::Box<rustc_driver_impl[c88438ade88661f4]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f5be3c9de76 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha9c3bc81d312fd83
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2036:9
  13:     0x7f5be3c9de76 - std::panicking::rust_panic_with_hook::hac8bdceee1e4fe2c
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:799:13
  14:     0x7f5be6bc5b44 - std[3c8ba8ebcf555201]::panicking::begin_panic::<rustc_errors[80cf825e20fac581]::ExplicitBug>::{closure#0}
  15:     0x7f5be6bc24f6 - std[3c8ba8ebcf555201]::sys_common::backtrace::__rust_end_short_backtrace::<std[3c8ba8ebcf555201]::panicking::begin_panic<rustc_errors[80cf825e20fac581]::ExplicitBug>::{closure#0}, !>
  16:     0x7f5be6bbdb66 - std[3c8ba8ebcf555201]::panicking::begin_panic::<rustc_errors[80cf825e20fac581]::ExplicitBug>
  17:     0x7f5be6bcef01 - <rustc_errors[80cf825e20fac581]::diagnostic::BugAbort as rustc_errors[80cf825e20fac581]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f5be7048b1c - rustc_middle[3ff731b746e7b038]::util::bug::opt_span_bug_fmt::<rustc_span[8c7415e9d33ddd75]::span_encoding::Span>::{closure#0}
  19:     0x7f5be702fc2a - rustc_middle[3ff731b746e7b038]::ty::context::tls::with_opt::<rustc_middle[3ff731b746e7b038]::util::bug::opt_span_bug_fmt<rustc_span[8c7415e9d33ddd75]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7f5be702facb - rustc_middle[3ff731b746e7b038]::ty::context::tls::with_context_opt::<rustc_middle[3ff731b746e7b038]::ty::context::tls::with_opt<rustc_middle[3ff731b746e7b038]::util::bug::opt_span_bug_fmt<rustc_span[8c7415e9d33ddd75]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7f5be4da0740 - rustc_middle[3ff731b746e7b038]::util::bug::bug_fmt
  22:     0x7f5be855b842 - rustc_ty_utils[b79b74a9f824867d]::layout::layout_of_uncached
  23:     0x7f5be854d990 - rustc_ty_utils[b79b74a9f824867d]::layout::layout_of
  24:     0x7f5be854d911 - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 16usize]>>
  25:     0x7f5be854d0bd - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::DefaultCache<rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::ty::Ty>, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  26:     0x7f5be854cdb2 - rustc_query_impl[a12402620de91e8]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7f5be855fc0a - rustc_middle[3ff731b746e7b038]::query::plumbing::query_get_at::<rustc_query_system[4e189ce2c77124d]::query::caches::DefaultCache<rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::ty::Ty>, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 16usize]>>>
  28:     0x7f5be854db59 - rustc_ty_utils[b79b74a9f824867d]::layout::layout_of
  29:     0x7f5be854d911 - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 16usize]>>
  30:     0x7f5be854d0bd - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::DefaultCache<rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::ty::Ty>, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  31:     0x7f5be854cdb2 - rustc_query_impl[a12402620de91e8]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f5be8dafaec - rustc_middle[3ff731b746e7b038]::query::plumbing::query_get_at::<rustc_query_system[4e189ce2c77124d]::query::caches::DefaultCache<rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::ty::Ty>, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 16usize]>>>
  33:     0x7f5be8daf63b - rustc_hir_analysis[46a17d8846b4335f]::check::check::check_static_inhabited
  34:     0x7f5be8db4fa0 - rustc_hir_analysis[46a17d8846b4335f]::check::check::check_item_type
  35:     0x7f5be84da627 - rustc_hir_analysis[46a17d8846b4335f]::check::wfcheck::check_well_formed
  36:     0x7f5be84d923d - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7f5be84d8de3 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::VecCache<rustc_hir[809d8cc19d3b2ead]::hir_id::OwnerId, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  38:     0x7f5be84d8b99 - rustc_query_impl[a12402620de91e8]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7f5be84d6e95 - rustc_hir_analysis[46a17d8846b4335f]::check::wfcheck::check_mod_type_wf
  40:     0x7f5be84d6d49 - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>
  41:     0x7f5be8b12210 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::DefaultCache<rustc_span[8c7415e9d33ddd75]::def_id::LocalModDefId, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  42:     0x7f5be8b11fff - rustc_query_impl[a12402620de91e8]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  43:     0x7f5be86d91d0 - rustc_hir_analysis[46a17d8846b4335f]::check_crate
  44:     0x7f5be88980e0 - rustc_interface[640972162e3c086f]::passes::analysis
  45:     0x7f5be8897aef - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>
  46:     0x7f5be8bf1022 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::SingleCache<rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  47:     0x7f5be8bf0dc9 - rustc_query_impl[a12402620de91e8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  48:     0x7f5be8a92149 - rustc_interface[640972162e3c086f]::interface::run_compiler::<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}
  49:     0x7f5be8a4ff8b - std[3c8ba8ebcf555201]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[640972162e3c086f]::util::run_in_thread_with_globals<rustc_interface[640972162e3c086f]::interface::run_compiler<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>
  50:     0x7f5be8a4fd80 - <<std[3c8ba8ebcf555201]::thread::Builder>::spawn_unchecked_<rustc_interface[640972162e3c086f]::util::run_in_thread_with_globals<rustc_interface[640972162e3c086f]::interface::run_compiler<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#2} as core[868bc93c3f2beb33]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:     0x7f5be3ca7cab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h09e5a4c541afa800
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
  52:     0x7f5be3ca7cab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9c8b03c22f4e7026
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
  53:     0x7f5be3ca7cab - std::sys::pal::unix::thread::Thread::new::thread_start::h522bc89a54da820a
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys/pal/unix/thread.rs:108:17
  54:     0x7f5be3bb5609 - start_thread
  55:     0x7f5be3ad8353 - clone
  56:                0x0 - <unknown>

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.79.0 (129f3b996 2024-06-10) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
#0 [layout_of] computing layout of `_`
#1 [layout_of] computing layout of `<Thing as Every>::Assoc`
#2 [check_well_formed] checking that `I` is well-formed
#3 [check_mod_type_wf] checking that types are well-formed in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
Some errors have detailed explanations: E0207, E0283.
For more information about an error, try `rustc --explain E0207`.
error: could not compile `playground` (lib) due to 2 previous errors

@theemathas
Copy link
Contributor

theemathas commented Jun 27, 2024

Variant with a different ICE (index out of bounds: the len is 0 but the index is 0)

struct Thing;

pub trait Every {
    type Assoc;
}
impl<T: ?Sized> Every for Thing {
    type Assoc = T;
}

fn foo(_: <Thing as Every>::Assoc) {}
Error output
   Compiling playground v0.0.1 (/playground)
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
 --> src/lib.rs:6:6
  |
6 | impl<T: ?Sized> Every for Thing {
  |      ^ unconstrained type parameter

error[E0282]: type annotations needed
  --> src/lib.rs:10:11
   |
10 | fn foo(_: <Thing as Every>::Assoc) {}
   |           ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`

error[E0282]: type annotations needed
  --> src/lib.rs:10:8
   |
10 | fn foo(_: <Thing as Every>::Assoc) {}
   |        ^ cannot infer type for type parameter `T`

thread 'rustc' panicked at /rust/deps/ena-0.14.2/src/snapshot_vec.rs:199:10:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7f0d4f6d5035 - std::backtrace_rs::backtrace::libunwind::trace::h1a07e5dba0da0cd2
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f0d4f6d5035 - std::backtrace_rs::backtrace::trace_unsynchronized::h61b9b8394328c0bc
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f0d4f6d5035 - std::sys_common::backtrace::_print_fmt::h1c5e18b460934cff
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f0d4f6d5035 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1e1a1972118942ad
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f0d4f72429b - core::fmt::rt::Argument::fmt::h07af2b4071d536cd
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/rt.rs:165:63
   5:     0x7f0d4f72429b - core::fmt::write::hc090a2ffd6b28c4a
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/mod.rs:1157:21
   6:     0x7f0d4f6c9bdf - std::io::Write::write_fmt::h8898bac6ff039a23
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/mod.rs:1832:15
   7:     0x7f0d4f6d4e0e - std::sys_common::backtrace::_print::h4e80c5803d4ee35b
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f0d4f6d4e0e - std::sys_common::backtrace::print::ha96650907276675e
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f0d4f6d7779 - std::panicking::default_hook::{{closure}}::h215c2a0a8346e0e0
  10:     0x7f0d4f6d74bd - std::panicking::default_hook::h207342be97478370
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:298:9
  11:     0x7f0d525d21b7 - std[3c8ba8ebcf555201]::panicking::update_hook::<alloc[bfbae7e348dce413]::boxed::Box<rustc_driver_impl[c88438ade88661f4]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f0d4f6d7e76 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha9c3bc81d312fd83
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2036:9
  13:     0x7f0d4f6d7e76 - std::panicking::rust_panic_with_hook::hac8bdceee1e4fe2c
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:799:13
  14:     0x7f0d4f6d7c24 - std::panicking::begin_panic_handler::{{closure}}::h00d785e82757ce3c
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:664:13
  15:     0x7f0d4f6d54f9 - std::sys_common::backtrace::__rust_end_short_backtrace::h1628d957bcd06996
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f0d4f6d7957 - rust_begin_unwind
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
  17:     0x7f0d4f720763 - core::panicking::panic_fmt::hdc63834ffaaefae5
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
  18:     0x7f0d4f720987 - core::panicking::panic_bounds_check::hd7e618b1b39cc1c3
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:275:5
  19:     0x7f0d54a5f768 - <ena[7ba0c23a1613b29]::unify::UnificationTable<ena[7ba0c23a1613b29]::unify::backing_vec::InPlace<rustc_infer[abd41066181445be]::infer::type_variable::TyVidEqKey, &mut alloc[bfbae7e348dce413]::vec::Vec<ena[7ba0c23a1613b29]::unify::VarValue<rustc_infer[abd41066181445be]::infer::type_variable::TyVidEqKey>>, &mut rustc_infer[abd41066181445be]::infer::snapshot::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key.llvm.6537034541696690420.cold
  20:     0x7f0d507a0045 - <rustc_infer[abd41066181445be]::infer::canonical::canonicalizer::Canonicalizer as rustc_type_ir[a145be3c51398263]::fold::TypeFolder<rustc_middle[3ff731b746e7b038]::ty::context::TyCtxt>>::fold_ty
  21:     0x7f0d53dd6b38 - <rustc_infer[abd41066181445be]::infer::canonical::canonicalizer::Canonicalizer as rustc_type_ir[a145be3c51398263]::fold::FallibleTypeFolder<rustc_middle[3ff731b746e7b038]::ty::context::TyCtxt>>::try_fold_predicate
  22:     0x7f0d5115701f - rustc_trait_selection[173dcaf5d960508e]::traits::type_known_to_meet_bound_modulo_regions
  23:     0x7f0d53ba840b - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::is_copy_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>
  24:     0x7f0d53ba93c6 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::DefaultCache<rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::ty::Ty>, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  25:     0x7f0d53ba90ce - rustc_query_impl[a12402620de91e8]::query_impl::is_copy_raw::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7f0d53baa0eb - rustc_ty_utils[b79b74a9f824867d]::needs_drop::needs_drop_raw
  27:     0x7f0d53ba9b59 - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::needs_drop_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>
  28:     0x7f0d53ba936a - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::DefaultCache<rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::ty::Ty>, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  29:     0x7f0d53ba900e - rustc_query_impl[a12402620de91e8]::query_impl::needs_drop_raw::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f0d50b12f93 - <rustc_mir_transform[2984d3182075647]::elaborate_drops::ElaborateDrops as rustc_middle[3ff731b746e7b038]::mir::MirPass>::run_pass
  31:     0x7f0d5394a4cd - rustc_mir_transform[2984d3182075647]::pass_manager::run_passes_inner
  32:     0x7f0d5141bff7 - rustc_mir_transform[2984d3182075647]::mir_drops_elaborated_and_const_checked
  33:     0x7f0d53a5ec31 - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 8usize]>>
  34:     0x7f0d53a5ef2d - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::VecCache<rustc_span[8c7415e9d33ddd75]::def_id::LocalDefId, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  35:     0x7f0d53a5e78c - rustc_query_impl[a12402620de91e8]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f0d542d2432 - rustc_interface[640972162e3c086f]::passes::analysis
  37:     0x7f0d542d1aef - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7f0d5462b022 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::SingleCache<rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  39:     0x7f0d5462adc9 - rustc_query_impl[a12402620de91e8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f0d544cc149 - rustc_interface[640972162e3c086f]::interface::run_compiler::<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7f0d54489f8b - std[3c8ba8ebcf555201]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[640972162e3c086f]::util::run_in_thread_with_globals<rustc_interface[640972162e3c086f]::interface::run_compiler<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>
  42:     0x7f0d54489d80 - <<std[3c8ba8ebcf555201]::thread::Builder>::spawn_unchecked_<rustc_interface[640972162e3c086f]::util::run_in_thread_with_globals<rustc_interface[640972162e3c086f]::interface::run_compiler<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#2} as core[868bc93c3f2beb33]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f0d4f6e1cab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h09e5a4c541afa800
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
  44:     0x7f0d4f6e1cab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9c8b03c22f4e7026
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
  45:     0x7f0d4f6e1cab - std::sys::pal::unix::thread::Thread::new::thread_start::h522bc89a54da820a
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys/pal/unix/thread.rs:108:17
  46:     0x7f0d4f5ef609 - start_thread
  47:     0x7f0d4f512353 - clone
  48:                0x0 - <unknown>

error: 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.79.0 (129f3b996 2024-06-10) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
#0 [is_copy_raw] computing whether `_` is `Copy`
#1 [needs_drop_raw] computing whether `_` needs drop
#2 [mir_drops_elaborated_and_const_checked] elaborating drops for `foo`
#3 [analysis] running analysis passes on this crate
end of query stack
Some errors have detailed explanations: E0207, E0282.
For more information about an error, try `rustc --explain E0207`.
error: could not compile `playground` (lib) due to 3 previous errors

Removing the ?Sized makes the ICE go away for some reason.

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Jul 5, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 7, 2024
@gurry
Copy link
Contributor

gurry commented Jul 16, 2024

Minimized:

struct Thing;

pub trait Every {
    type Assoc;
}
impl<T: ?Sized> Every for Thing {
    type Assoc = T;
}

static I: <Thing as Every>::Assoc = 3;

I investigated using the above code. The ICE occurs when we call the layout query during the inhabitedness check for the static I. Given the assignment to 3 in the declaration static I: <Thing as Every>::Assoc = 3 its type should normalize and resolve to i32 or something, but because we have a T: ?Size constraint in the impl that is not possible. So we get back a tykind Infer instead. When that Infer type is passed to layout_of_uncached it ICEs.

That explains why removing the ?Sized constraint makes the issue go away.

@rustbot claim

@gurry
Copy link
Contributor

gurry commented Jul 16, 2024

Variant with a different ICE (index out of bounds: the len is 0 but the index is 0)

struct Thing;

pub trait Every {
    type Assoc;
}
impl<T: ?Sized> Every for Thing {
    type Assoc = T;
}

fn foo(_: <Thing as Every>::Assoc) {}

Error output

   Compiling playground v0.0.1 (/playground)
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
 --> src/lib.rs:6:6
  |
6 | impl<T: ?Sized> Every for Thing {
  |      ^ unconstrained type parameter

error[E0282]: type annotations needed
  --> src/lib.rs:10:11
   |
10 | fn foo(_: <Thing as Every>::Assoc) {}
   |           ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`

error[E0282]: type annotations needed
  --> src/lib.rs:10:8
   |
10 | fn foo(_: <Thing as Every>::Assoc) {}
   |        ^ cannot infer type for type parameter `T`

thread 'rustc' panicked at /rust/deps/ena-0.14.2/src/snapshot_vec.rs:199:10:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7f0d4f6d5035 - std::backtrace_rs::backtrace::libunwind::trace::h1a07e5dba0da0cd2
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f0d4f6d5035 - std::backtrace_rs::backtrace::trace_unsynchronized::h61b9b8394328c0bc
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f0d4f6d5035 - std::sys_common::backtrace::_print_fmt::h1c5e18b460934cff
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f0d4f6d5035 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1e1a1972118942ad
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f0d4f72429b - core::fmt::rt::Argument::fmt::h07af2b4071d536cd
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/rt.rs:165:63
   5:     0x7f0d4f72429b - core::fmt::write::hc090a2ffd6b28c4a
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/mod.rs:1157:21
   6:     0x7f0d4f6c9bdf - std::io::Write::write_fmt::h8898bac6ff039a23
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/mod.rs:1832:15
   7:     0x7f0d4f6d4e0e - std::sys_common::backtrace::_print::h4e80c5803d4ee35b
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f0d4f6d4e0e - std::sys_common::backtrace::print::ha96650907276675e
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f0d4f6d7779 - std::panicking::default_hook::{{closure}}::h215c2a0a8346e0e0
  10:     0x7f0d4f6d74bd - std::panicking::default_hook::h207342be97478370
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:298:9
  11:     0x7f0d525d21b7 - std[3c8ba8ebcf555201]::panicking::update_hook::<alloc[bfbae7e348dce413]::boxed::Box<rustc_driver_impl[c88438ade88661f4]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f0d4f6d7e76 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha9c3bc81d312fd83
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2036:9
  13:     0x7f0d4f6d7e76 - std::panicking::rust_panic_with_hook::hac8bdceee1e4fe2c
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:799:13
  14:     0x7f0d4f6d7c24 - std::panicking::begin_panic_handler::{{closure}}::h00d785e82757ce3c
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:664:13
  15:     0x7f0d4f6d54f9 - std::sys_common::backtrace::__rust_end_short_backtrace::h1628d957bcd06996
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f0d4f6d7957 - rust_begin_unwind
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
  17:     0x7f0d4f720763 - core::panicking::panic_fmt::hdc63834ffaaefae5
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
  18:     0x7f0d4f720987 - core::panicking::panic_bounds_check::hd7e618b1b39cc1c3
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:275:5
  19:     0x7f0d54a5f768 - <ena[7ba0c23a1613b29]::unify::UnificationTable<ena[7ba0c23a1613b29]::unify::backing_vec::InPlace<rustc_infer[abd41066181445be]::infer::type_variable::TyVidEqKey, &mut alloc[bfbae7e348dce413]::vec::Vec<ena[7ba0c23a1613b29]::unify::VarValue<rustc_infer[abd41066181445be]::infer::type_variable::TyVidEqKey>>, &mut rustc_infer[abd41066181445be]::infer::snapshot::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key.llvm.6537034541696690420.cold
  20:     0x7f0d507a0045 - <rustc_infer[abd41066181445be]::infer::canonical::canonicalizer::Canonicalizer as rustc_type_ir[a145be3c51398263]::fold::TypeFolder<rustc_middle[3ff731b746e7b038]::ty::context::TyCtxt>>::fold_ty
  21:     0x7f0d53dd6b38 - <rustc_infer[abd41066181445be]::infer::canonical::canonicalizer::Canonicalizer as rustc_type_ir[a145be3c51398263]::fold::FallibleTypeFolder<rustc_middle[3ff731b746e7b038]::ty::context::TyCtxt>>::try_fold_predicate
  22:     0x7f0d5115701f - rustc_trait_selection[173dcaf5d960508e]::traits::type_known_to_meet_bound_modulo_regions
  23:     0x7f0d53ba840b - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::is_copy_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>
  24:     0x7f0d53ba93c6 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::DefaultCache<rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::ty::Ty>, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  25:     0x7f0d53ba90ce - rustc_query_impl[a12402620de91e8]::query_impl::is_copy_raw::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7f0d53baa0eb - rustc_ty_utils[b79b74a9f824867d]::needs_drop::needs_drop_raw
  27:     0x7f0d53ba9b59 - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::needs_drop_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>
  28:     0x7f0d53ba936a - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::DefaultCache<rustc_middle[3ff731b746e7b038]::ty::ParamEnvAnd<rustc_middle[3ff731b746e7b038]::ty::Ty>, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  29:     0x7f0d53ba900e - rustc_query_impl[a12402620de91e8]::query_impl::needs_drop_raw::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f0d50b12f93 - <rustc_mir_transform[2984d3182075647]::elaborate_drops::ElaborateDrops as rustc_middle[3ff731b746e7b038]::mir::MirPass>::run_pass
  31:     0x7f0d5394a4cd - rustc_mir_transform[2984d3182075647]::pass_manager::run_passes_inner
  32:     0x7f0d5141bff7 - rustc_mir_transform[2984d3182075647]::mir_drops_elaborated_and_const_checked
  33:     0x7f0d53a5ec31 - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 8usize]>>
  34:     0x7f0d53a5ef2d - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::VecCache<rustc_span[8c7415e9d33ddd75]::def_id::LocalDefId, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  35:     0x7f0d53a5e78c - rustc_query_impl[a12402620de91e8]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f0d542d2432 - rustc_interface[640972162e3c086f]::passes::analysis
  37:     0x7f0d542d1aef - rustc_query_impl[a12402620de91e8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a12402620de91e8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7f0d5462b022 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::<rustc_query_impl[a12402620de91e8]::DynamicConfig<rustc_query_system[4e189ce2c77124d]::query::caches::SingleCache<rustc_middle[3ff731b746e7b038]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a12402620de91e8]::plumbing::QueryCtxt, false>
  39:     0x7f0d5462adc9 - rustc_query_impl[a12402620de91e8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f0d544cc149 - rustc_interface[640972162e3c086f]::interface::run_compiler::<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7f0d54489f8b - std[3c8ba8ebcf555201]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[640972162e3c086f]::util::run_in_thread_with_globals<rustc_interface[640972162e3c086f]::interface::run_compiler<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>
  42:     0x7f0d54489d80 - <<std[3c8ba8ebcf555201]::thread::Builder>::spawn_unchecked_<rustc_interface[640972162e3c086f]::util::run_in_thread_with_globals<rustc_interface[640972162e3c086f]::interface::run_compiler<core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[868bc93c3f2beb33]::result::Result<(), rustc_span[8c7415e9d33ddd75]::ErrorGuaranteed>>::{closure#2} as core[868bc93c3f2beb33]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f0d4f6e1cab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h09e5a4c541afa800
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
  44:     0x7f0d4f6e1cab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9c8b03c22f4e7026
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9
  45:     0x7f0d4f6e1cab - std::sys::pal::unix::thread::Thread::new::thread_start::h522bc89a54da820a
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys/pal/unix/thread.rs:108:17
  46:     0x7f0d4f5ef609 - start_thread
  47:     0x7f0d4f512353 - clone
  48:                0x0 - <unknown>

error: 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.79.0 (129f3b996 2024-06-10) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
#0 [is_copy_raw] computing whether `_` is `Copy`
#1 [needs_drop_raw] computing whether `_` needs drop
#2 [mir_drops_elaborated_and_const_checked] elaborating drops for `foo`
#3 [analysis] running analysis passes on this crate
end of query stack
Some errors have detailed explanations: E0207, E0282.
For more information about an error, try `rustc --explain E0207`.
error: could not compile `playground` (lib) due to 3 previous errors

Removing the ?Sized makes the ICE go away for some reason.

This is a completely different ICE. I have opened a separate issue for it: #127804

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-layout Area: Memory layout of types C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
8 participants