rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
94.89k stars 12.23k forks source link

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

Open Naserume opened 1 week ago

Naserume commented 1 week ago

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 stack backtrace: 0: 0x10cae6b43 - ::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::>::{closure#0} 7: 0x10caea326 - std::panicking::rust_panic_with_hook::h6889093a56e48d04 8: 0x115df0337 - std[8efa578c02603ef9]::panicking::begin_panic::::{closure#0} 9: 0x115ddc949 - std[8efa578c02603ef9]::sys::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 10: 0x11a7e2f09 - std[8efa578c02603ef9]::panicking::begin_panic:: 11: 0x115e02276 - ::emit_producing_guarantee 12: 0x116a9c95e - rustc_middle[4384e439927f71dd]::util::bug::opt_span_bug_fmt::::{closure#0} 13: 0x116a522b7 - rustc_middle[4384e439927f71dd]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 14: 0x116a51d75 - rustc_middle[4384e439927f71dd]::ty::context::tls::with_context_opt::::{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::> 19: 0x1173f2f4e - )>>::call_once 20: 0x11720a655 - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::, 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_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::> 25: 0x1173f2f4e - )>>::call_once 26: 0x11720a655 - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::, 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_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::> 33: 0x11729701f - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::>, 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::>, ()> 36: 0x1160c4de1 - rustc_hir_analysis[8e62bc6471a04889]::check::wfcheck::check_mod_type_wf 37: 0x11741e83c - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::> 38: 0x11724db79 - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::>, 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::> 44: 0x11720249e - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::>, 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 - >::enter::, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}::{closure#1}::{closure#3}> 47: 0x115d7fc94 - rustc_interface[73216d77aad0c3a5]::interface::run_compiler::, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}>::{closure#1} 48: 0x115d6ec91 - std[8efa578c02603ef9]::sys::backtrace::__rust_begin_short_backtrace::, 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 - <::spawn_unchecked_, 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.

GrigorenkoPV commented 1 week ago

searched nightlies: from nightly-2022-02-19 to nightly-2024-06-25 regressed nightly: nightly-2024-03-08 searched commit range: https://github.com/rust-lang/rust/compare/7d3702e472b99be0f5de6608dd87af1df8f99428...9c3ad802d9b9633d60d3a74668eb1be819212d34 regressed commit: https://github.com/rust-lang/rust/commit/8c9a75b3238b66592779d6b240dbf78eacefebb8 (#121154)

theemathas commented 1 week ago

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 Every for Thing { | ^ unconstrained type parameter error[E0283]: type annotations needed --> src/lib.rs:10:11 | 10 | static I: ::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 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 - ::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::>::{closure#0} 12: 0x7f5be3c9de76 - as core::ops::function::Fn>::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::::{closure#0} 15: 0x7f5be6bc24f6 - std[3c8ba8ebcf555201]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 16: 0x7f5be6bbdb66 - std[3c8ba8ebcf555201]::panicking::begin_panic:: 17: 0x7f5be6bcef01 - ::emit_producing_guarantee 18: 0x7f5be7048b1c - rustc_middle[3ff731b746e7b038]::util::bug::opt_span_bug_fmt::::{closure#0} 19: 0x7f5be702fc2a - rustc_middle[3ff731b746e7b038]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 20: 0x7f5be702facb - rustc_middle[3ff731b746e7b038]::ty::context::tls::with_context_opt::::{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::> 25: 0x7f5be854d0bd - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::, 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_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::> 30: 0x7f5be854d0bd - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::, 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_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::> 37: 0x7f5be84d8de3 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::>, 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::> 41: 0x7f5be8b12210 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::>, 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::> 46: 0x7f5be8bf1022 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::>, 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::, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1} 49: 0x7f5be8a4ff8b - std[3c8ba8ebcf555201]::sys_common::backtrace::__rust_begin_short_backtrace::, 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 - <::spawn_unchecked_, 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 - as core::ops::function::FnOnce>::call_once::h09e5a4c541afa800 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9 52: 0x7f5be3ca7cab - as core::ops::function::FnOnce>::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 - 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 `::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 commented 1 week ago

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 Every for Thing { | ^ unconstrained type parameter error[E0282]: type annotations needed --> src/lib.rs:10:11 | 10 | fn foo(_: ::Assoc) {} | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` error[E0282]: type annotations needed --> src/lib.rs:10:8 | 10 | fn foo(_: ::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 - ::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::>::{closure#0} 12: 0x7f0d4f6d7e76 - as core::ops::function::Fn>::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 - >, &mut rustc_infer[abd41066181445be]::infer::snapshot::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key.llvm.6537034541696690420.cold 20: 0x7f0d507a0045 - >::fold_ty 21: 0x7f0d53dd6b38 - >::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::> 24: 0x7f0d53ba93c6 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::, 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::> 28: 0x7f0d53ba936a - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::, 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 - ::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::> 34: 0x7f0d53a5ef2d - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::>, 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::> 38: 0x7f0d5462b022 - rustc_query_system[4e189ce2c77124d]::query::plumbing::try_execute_query::>, 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::, rustc_driver_impl[c88438ade88661f4]::run_compiler::{closure#0}>::{closure#1} 41: 0x7f0d54489f8b - std[3c8ba8ebcf555201]::sys_common::backtrace::__rust_begin_short_backtrace::, 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 - <::spawn_unchecked_, 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 - as core::ops::function::FnOnce>::call_once::h09e5a4c541afa800 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2022:9 44: 0x7f0d4f6e1cab - as core::ops::function::FnOnce>::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 - 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.