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: generators: assertion failed: field.0.is_sized() #113279

Closed
matthiaskrgr opened this issue Jul 3, 2023 · 1 comment · Fixed by #114060
Closed

ICE: generators: assertion failed: field.0.is_sized() #113279

matthiaskrgr opened this issue Jul 3, 2023 · 1 comment · Fixed by #114060
Labels
A-coroutines Area: Coroutines C-bug Category: This is a bug. F-coroutines `#![feature(coroutines)]` glacier ICE tracked in rust-lang/glacier. 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.

Comments

@matthiaskrgr
Copy link
Member

Code

#![feature(generators)]

fn foo() {
    let _y = static || {
        let x = &mut 0;
        *{
            yield;
            x
        } += match { *"" }.len() {
            _ => 0,
        };
    };
}

fn main() {
    foo()
}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (5bd28f5ea 2023-06-28)
binary: rustc
commit-hash: 5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0
commit-date: 2023-06-28
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

error[E0161]: cannot move a value of type `str`
 --> treereduce.out:9:20
  |
9 |         } += match { *"" }.len() {
  |                    ^^^^^^^ the size of `str` cannot be statically determined

error[E0507]: cannot move out of a shared reference
 --> treereduce.out:9:22
  |
9 |         } += match { *"" }.len() {
  |                      ^^^ move occurs because value has type `str`, which does not implement the `Copy` trait
Backtrace

thread 'rustc' panicked at 'assertion failed: field.0.is_sized()', /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/compiler/rustc_abi/src/layout.rs:751:13
stack backtrace:
   0:     0x7f972f967e31 - std::backtrace_rs::backtrace::libunwind::trace::h8bc3e596fd6e6181
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f972f967e31 - std::backtrace_rs::backtrace::trace_unsynchronized::h9a0656fedca2f962
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f972f967e31 - std::sys_common::backtrace::_print_fmt::h11ca79bc953fda0e
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f972f967e31 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h23585af82c540d61
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f972f9c95df - core::fmt::rt::Argument::fmt::h1e7f4bcecbee3fbb
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/core/src/fmt/rt.rs:138:9
   5:     0x7f972f9c95df - core::fmt::write::h41633f265152b738
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f972f95a967 - std::io::Write::write_fmt::hdf9fdeebf4391d4c
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/io/mod.rs:1714:15
   7:     0x7f972f967c45 - std::sys_common::backtrace::_print::h0761f433dadea582
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f972f967c45 - std::sys_common::backtrace::print::hffcd468cc9baf957
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f972f96a9f3 - std::panicking::default_hook::{{closure}}::h70eb212f41458c90
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/panicking.rs:269:22
  10:     0x7f972f96a784 - std::panicking::default_hook::hf217f8886a1385fc
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/panicking.rs:288:9
  11:     0x7f9732c2217b - <rustc_driver_impl[ea51492c730803db]::install_ice_hook::{closure#0} as core[6e72eb595340d7ba]::ops::function::FnOnce<(&core[6e72eb595340d7ba]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  12:     0x7f972f96b21e - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hdf84d12f536c7065
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/alloc/src/boxed.rs:2024:9
  13:     0x7f972f96b21e - std::panicking::rust_panic_with_hook::h7901b0073bb3ed74
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/panicking.rs:709:13
  14:     0x7f972f96af61 - std::panicking::begin_panic_handler::{{closure}}::hec74e56b1f659f1d
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/panicking.rs:595:13
  15:     0x7f972f968266 - std::sys_common::backtrace::__rust_end_short_backtrace::hb5aad058838135df
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:151:18
  16:     0x7f972f96acf2 - rust_begin_unwind
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/panicking.rs:593:5
  17:     0x7f972f9c5833 - core::panicking::panic_fmt::h837c4ca50a3367f6
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/core/src/panicking.rs:67:14
  18:     0x7f972f9c58c3 - core::panicking::panic::h80d288e51a1b9574
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/core/src/panicking.rs:117:5
  19:     0x7f973135086a - <rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutCx<rustc_middle[9f74ec5cb00a905a]::ty::context::TyCtxt> as rustc_abi[f59abcbab75cfe4b]::layout::LayoutCalculator>::layout_of_union
  20:     0x7f973133a411 - rustc_ty_utils[a49f065ba4a00179]::layout::layout_of
  21:     0x7f9730bf6780 - rustc_query_impl[a5bf74a69bd3660]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5bf74a69bd3660]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 24usize]>>
  22:     0x7f9731567bc7 - rustc_query_system[d65e888f3fe19f8d]::query::plumbing::try_execute_query::<rustc_query_impl[a5bf74a69bd3660]::DynamicConfig<rustc_query_system[d65e888f3fe19f8d]::query::caches::DefaultCache<rustc_middle[9f74ec5cb00a905a]::ty::ParamEnvAnd<rustc_middle[9f74ec5cb00a905a]::ty::Ty>, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 24usize]>>, false, true, false>, rustc_query_impl[a5bf74a69bd3660]::plumbing::QueryCtxt, false>
  23:     0x7f97315677f0 - rustc_query_impl[a5bf74a69bd3660]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7f9731969df0 - <rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutCx<rustc_middle[9f74ec5cb00a905a]::ty::context::TyCtxt> as rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutOf>::spanned_layout_of
  25:     0x7f973395c41b - <core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<rustc_index[70e807cd400131f6]::bit_set::BitIter<rustc_middle[9f74ec5cb00a905a]::mir::query::GeneratorSavedLocal>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#1}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#2}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#3}> as core[6e72eb595340d7ba]::iter::traits::iterator::Iterator>::try_fold::<(), <core[6e72eb595340d7ba]::iter::adapters::GenericShunt<core[6e72eb595340d7ba]::iter::adapters::by_ref_sized::ByRefSized<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::flatten::Flatten<core[6e72eb595340d7ba]::option::IntoIter<&rustc_middle[9f74ec5cb00a905a]::ty::list::List<rustc_middle[9f74ec5cb00a905a]::ty::Ty>>>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#4}>, core[6e72eb595340d7ba]::iter::sources::once::Once<core[6e72eb595340d7ba]::result::Result<rustc_abi[f59abcbab75cfe4b]::Layout, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>>>, core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<rustc_index[70e807cd400131f6]::bit_set::BitIter<rustc_middle[9f74ec5cb00a905a]::mir::query::GeneratorSavedLocal>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#1}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#2}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#3}>>>, core[6e72eb595340d7ba]::result::Result<core[6e72eb595340d7ba]::convert::Infallible, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>> as core[6e72eb595340d7ba]::iter::traits::iterator::Iterator>::try_fold<(), core[6e72eb595340d7ba]::iter::traits::iterator::Iterator::try_for_each::call<rustc_abi[f59abcbab75cfe4b]::Layout, core[6e72eb595340d7ba]::ops::control_flow::ControlFlow<rustc_abi[f59abcbab75cfe4b]::Layout>, core[6e72eb595340d7ba]::ops::control_flow::ControlFlow<rustc_abi[f59abcbab75cfe4b]::Layout>::Break>::{closure#0}, core[6e72eb595340d7ba]::ops::control_flow::ControlFlow<rustc_abi[f59abcbab75cfe4b]::Layout>>::{closure#0}, core[6e72eb595340d7ba]::ops::control_flow::ControlFlow<core[6e72eb595340d7ba]::ops::control_flow::ControlFlow<rustc_abi[f59abcbab75cfe4b]::Layout>>>
  26:     0x7f97339669c0 - <core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::flatten::Flatten<core[6e72eb595340d7ba]::option::IntoIter<&rustc_middle[9f74ec5cb00a905a]::ty::list::List<rustc_middle[9f74ec5cb00a905a]::ty::Ty>>>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#4}>, core[6e72eb595340d7ba]::iter::sources::once::Once<core[6e72eb595340d7ba]::result::Result<rustc_abi[f59abcbab75cfe4b]::Layout, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>>>, core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<rustc_index[70e807cd400131f6]::bit_set::BitIter<rustc_middle[9f74ec5cb00a905a]::mir::query::GeneratorSavedLocal>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#1}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#2}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#3}>> as core[6e72eb595340d7ba]::iter::traits::iterator::Iterator>::try_fold::<(), <core[6e72eb595340d7ba]::iter::adapters::GenericShunt<core[6e72eb595340d7ba]::iter::adapters::by_ref_sized::ByRefSized<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::flatten::Flatten<core[6e72eb595340d7ba]::option::IntoIter<&rustc_middle[9f74ec5cb00a905a]::ty::list::List<rustc_middle[9f74ec5cb00a905a]::ty::Ty>>>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#4}>, core[6e72eb595340d7ba]::iter::sources::once::Once<core[6e72eb595340d7ba]::result::Result<rustc_abi[f59abcbab75cfe4b]::Layout, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>>>, core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<rustc_index[70e807cd400131f6]::bit_set::BitIter<rustc_middle[9f74ec5cb00a905a]::mir::query::GeneratorSavedLocal>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#1}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#2}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#3}>>>, core[6e72eb595340d7ba]::result::Result<core[6e72eb595340d7ba]::convert::Infallible, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>> as core[6e72eb595340d7ba]::iter::traits::iterator::Iterator>::try_fold<(), core[6e72eb595340d7ba]::iter::traits::iterator::Iterator::try_for_each::call<rustc_abi[f59abcbab75cfe4b]::Layout, core[6e72eb595340d7ba]::ops::control_flow::ControlFlow<rustc_abi[f59abcbab75cfe4b]::Layout>, core[6e72eb595340d7ba]::ops::control_flow::ControlFlow<rustc_abi[f59abcbab75cfe4b]::Layout>::Break>::{closure#0}, core[6e72eb595340d7ba]::ops::control_flow::ControlFlow<rustc_abi[f59abcbab75cfe4b]::Layout>>::{closure#0}, core[6e72eb595340d7ba]::ops::control_flow::ControlFlow<core[6e72eb595340d7ba]::ops::control_flow::ControlFlow<rustc_abi[f59abcbab75cfe4b]::Layout>>>
  27:     0x7f97339855c3 - <core[6e72eb595340d7ba]::iter::adapters::GenericShunt<core[6e72eb595340d7ba]::iter::adapters::by_ref_sized::ByRefSized<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::flatten::Flatten<core[6e72eb595340d7ba]::option::IntoIter<&rustc_middle[9f74ec5cb00a905a]::ty::list::List<rustc_middle[9f74ec5cb00a905a]::ty::Ty>>>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#4}>, core[6e72eb595340d7ba]::iter::sources::once::Once<core[6e72eb595340d7ba]::result::Result<rustc_abi[f59abcbab75cfe4b]::Layout, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>>>, core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<rustc_index[70e807cd400131f6]::bit_set::BitIter<rustc_middle[9f74ec5cb00a905a]::mir::query::GeneratorSavedLocal>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#1}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#2}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#3}>>>, core[6e72eb595340d7ba]::result::Result<core[6e72eb595340d7ba]::convert::Infallible, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>> as core[6e72eb595340d7ba]::iter::traits::iterator::Iterator>::next
  28:     0x7f9733956022 - <alloc[6fd48550c51b5745]::vec::Vec<rustc_abi[f59abcbab75cfe4b]::Layout> as alloc[6fd48550c51b5745]::vec::spec_from_iter::SpecFromIter<rustc_abi[f59abcbab75cfe4b]::Layout, core[6e72eb595340d7ba]::iter::adapters::GenericShunt<core[6e72eb595340d7ba]::iter::adapters::by_ref_sized::ByRefSized<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::flatten::Flatten<core[6e72eb595340d7ba]::option::IntoIter<&rustc_middle[9f74ec5cb00a905a]::ty::list::List<rustc_middle[9f74ec5cb00a905a]::ty::Ty>>>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#4}>, core[6e72eb595340d7ba]::iter::sources::once::Once<core[6e72eb595340d7ba]::result::Result<rustc_abi[f59abcbab75cfe4b]::Layout, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>>>, core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<rustc_index[70e807cd400131f6]::bit_set::BitIter<rustc_middle[9f74ec5cb00a905a]::mir::query::GeneratorSavedLocal>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#1}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#2}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#3}>>>, core[6e72eb595340d7ba]::result::Result<core[6e72eb595340d7ba]::convert::Infallible, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>>>>::from_iter
  29:     0x7f9733984b23 - core[6e72eb595340d7ba]::iter::adapters::try_process::<core[6e72eb595340d7ba]::iter::adapters::by_ref_sized::ByRefSized<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::flatten::Flatten<core[6e72eb595340d7ba]::option::IntoIter<&rustc_middle[9f74ec5cb00a905a]::ty::list::List<rustc_middle[9f74ec5cb00a905a]::ty::Ty>>>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#4}>, core[6e72eb595340d7ba]::iter::sources::once::Once<core[6e72eb595340d7ba]::result::Result<rustc_abi[f59abcbab75cfe4b]::Layout, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>>>, core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<rustc_index[70e807cd400131f6]::bit_set::BitIter<rustc_middle[9f74ec5cb00a905a]::mir::query::GeneratorSavedLocal>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#1}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#2}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#3}>>>, rustc_abi[f59abcbab75cfe4b]::Layout, core[6e72eb595340d7ba]::result::Result<core[6e72eb595340d7ba]::convert::Infallible, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>, <core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::chain::Chain<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::flatten::Flatten<core[6e72eb595340d7ba]::option::IntoIter<&rustc_middle[9f74ec5cb00a905a]::ty::list::List<rustc_middle[9f74ec5cb00a905a]::ty::Ty>>>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#4}>, core[6e72eb595340d7ba]::iter::sources::once::Once<core[6e72eb595340d7ba]::result::Result<rustc_abi[f59abcbab75cfe4b]::Layout, rustc_middle[9f74ec5cb00a905a]::ty::layout::LayoutError>>>, core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<core[6e72eb595340d7ba]::iter::adapters::map::Map<rustc_index[70e807cd400131f6]::bit_set::BitIter<rustc_middle[9f74ec5cb00a905a]::mir::query::GeneratorSavedLocal>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#1}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#2}>, rustc_ty_utils[a49f065ba4a00179]::layout::generator_layout::{closure#3}>> as core[6e72eb595340d7ba]::iter::traits::iterator::Iterator>::try_collect<rustc_index[70e807cd400131f6]::vec::IndexVec<rustc_abi[f59abcbab75cfe4b]::FieldIdx, rustc_abi[f59abcbab75cfe4b]::Layout>>::{closure#0}, rustc_index[70e807cd400131f6]::vec::IndexVec<rustc_abi[f59abcbab75cfe4b]::FieldIdx, rustc_abi[f59abcbab75cfe4b]::Layout>>
  30:     0x7f973133bc32 - rustc_ty_utils[a49f065ba4a00179]::layout::layout_of
  31:     0x7f9730bf6780 - rustc_query_impl[a5bf74a69bd3660]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5bf74a69bd3660]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 24usize]>>
  32:     0x7f9731567bc7 - rustc_query_system[d65e888f3fe19f8d]::query::plumbing::try_execute_query::<rustc_query_impl[a5bf74a69bd3660]::DynamicConfig<rustc_query_system[d65e888f3fe19f8d]::query::caches::DefaultCache<rustc_middle[9f74ec5cb00a905a]::ty::ParamEnvAnd<rustc_middle[9f74ec5cb00a905a]::ty::Ty>, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 24usize]>>, false, true, false>, rustc_query_impl[a5bf74a69bd3660]::plumbing::QueryCtxt, false>
  33:     0x7f97315677f0 - rustc_query_impl[a5bf74a69bd3660]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f9731c200df - <rustc_mir_transform[3a72d7fd4a713ad]::const_prop::CanConstProp>::check
  35:     0x7f9731bf49c8 - <rustc_mir_transform[3a72d7fd4a713ad]::const_prop_lint::ConstProp as rustc_mir_transform[3a72d7fd4a713ad]::pass_manager::MirLint>::run_lint
  36:     0x7f973117b4a6 - rustc_mir_transform[3a72d7fd4a713ad]::mir_drops_elaborated_and_const_checked
  37:     0x7f9730c6859e - rustc_query_impl[a5bf74a69bd3660]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5bf74a69bd3660]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 8usize]>>
  38:     0x7f9730c6856e - <rustc_query_impl[a5bf74a69bd3660]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2} as core[6e72eb595340d7ba]::ops::function::FnOnce<(rustc_middle[9f74ec5cb00a905a]::ty::context::TyCtxt, rustc_span[624dabdd61f2978b]::def_id::LocalDefId)>>::call_once
  39:     0x7f9730d2891d - rustc_query_system[d65e888f3fe19f8d]::query::plumbing::try_execute_query::<rustc_query_impl[a5bf74a69bd3660]::DynamicConfig<rustc_query_system[d65e888f3fe19f8d]::query::caches::VecCache<rustc_span[624dabdd61f2978b]::def_id::LocalDefId, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a5bf74a69bd3660]::plumbing::QueryCtxt, false>
  40:     0x7f97325a7a21 - rustc_query_impl[a5bf74a69bd3660]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7f97320ee629 - <rustc_session[a15a65f093e103e1]::session::Session>::time::<(), rustc_interface[b943f00ad50b5541]::passes::analysis::{closure#2}>
  42:     0x7f97320ea955 - rustc_interface[b943f00ad50b5541]::passes::analysis
  43:     0x7f9732133aba - rustc_query_impl[a5bf74a69bd3660]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a5bf74a69bd3660]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 1usize]>>
  44:     0x7f9732133aa9 - <rustc_query_impl[a5bf74a69bd3660]::query_impl::analysis::dynamic_query::{closure#2} as core[6e72eb595340d7ba]::ops::function::FnOnce<(rustc_middle[9f74ec5cb00a905a]::ty::context::TyCtxt, ())>>::call_once
  45:     0x7f97322b2da8 - rustc_query_system[d65e888f3fe19f8d]::query::plumbing::try_execute_query::<rustc_query_impl[a5bf74a69bd3660]::DynamicConfig<rustc_query_system[d65e888f3fe19f8d]::query::caches::SingleCache<rustc_middle[9f74ec5cb00a905a]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a5bf74a69bd3660]::plumbing::QueryCtxt, false>
  46:     0x7f97322b2b79 - rustc_query_impl[a5bf74a69bd3660]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  47:     0x7f9732286a55 - <rustc_middle[9f74ec5cb00a905a]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>
  48:     0x7f9731eb9341 - <rustc_interface[b943f00ad50b5541]::interface::Compiler>::enter::<rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}::{closure#2}, core[6e72eb595340d7ba]::result::Result<core[6e72eb595340d7ba]::option::Option<rustc_interface[b943f00ad50b5541]::queries::Linker>, rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>
  49:     0x7f9731eb4575 - rustc_span[624dabdd61f2978b]::set_source_map::<core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>, rustc_interface[b943f00ad50b5541]::interface::run_compiler<core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  50:     0x7f9731eb3996 - <scoped_tls[8088cff701f74b4a]::ScopedKey<rustc_span[624dabdd61f2978b]::SessionGlobals>>::set::<rustc_interface[b943f00ad50b5541]::interface::run_compiler<core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>
  51:     0x7f9731eb2f46 - std[4a840e81aae3439]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b943f00ad50b5541]::util::run_in_thread_pool_with_globals<rustc_interface[b943f00ad50b5541]::interface::run_compiler<core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>
  52:     0x7f9731eb2cee - <<std[4a840e81aae3439]::thread::Builder>::spawn_unchecked_<rustc_interface[b943f00ad50b5541]::util::run_in_thread_pool_with_globals<rustc_interface[b943f00ad50b5541]::interface::run_compiler<core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>::{closure#1} as core[6e72eb595340d7ba]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  53:     0x7f972f975695 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h61eb867555625a06
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/alloc/src/boxed.rs:2010:9
  54:     0x7f972f975695 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb80c29f89b136b72
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/alloc/src/boxed.rs:2010:9
  55:     0x7f972f975695 - std::sys::unix::thread::Thread::new::thread_start::hf4205715d65b27a6
                               at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys/unix/thread.rs:108:17
  56:     0x7f972f70d44b - <unknown>
  57:     0x7f972f790e40 - <unknown>
  58:                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.72.0-nightly (5bd28f5ea 2023-06-28) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [layout_of] computing layout of `core::mem::maybe_uninit::MaybeUninit<str>`
#1 [layout_of] computing layout of `[static generator@treereduce.out:4:14: 4:23]`
#2 [mir_drops_elaborated_and_const_checked] elaborating drops for `foo`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0161, E0507.
For more information about an error, try `rustc --explain E0161`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. A-coroutines Area: Coroutines F-coroutines `#![feature(coroutines)]` labels Jul 3, 2023
@matthiaskrgr
Copy link
Member Author

Regression in nightly-2023-04-22
Regression in fa4cc63

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jul 11, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 25, 2023
abi: unsized field in union - assert to delay bug

Fixes rust-lang#113279.

> Unions cannot have unsized fields, and as such, layout computation for
unions asserts that each union field is sized (as this would normally
have halted compilation earlier).
>
> However, if a generator ends up with an unsized local - a circumstance
in which an error will always have been emitted earlier, for example, if
attempting to dereference a `&str` - then the generator transform will
produce a union with an unsized field.
>
> Since rust-lang#110107, later passes will be run, such as constant propagation,
and can attempt layout computation on the generator, which will result
in layout computation of `str` in the context of it being a field of a
union - and so the aforementioned assertion would cause an ICE.
>
> It didn't seem appropriate to try and detect this case in the MIR body
and skip this specific pass; tainting the MIR body or delaying a bug
from the generator transform (or elsewhere) wouldn't prevent this either
(as neither would prevent the later pass from running); and tainting when
the deref of `&str` is reported, if that's possible, would unnecessarily
prevent potential other errors from being reported later in compilation,
and is very tailored to this specific case of getting a unsized type in
a generator.
>
> Given that this circumstance can only happen when an error should have
already been reported, the correct fix appears to be just changing the
assert to a delayed bug. This will still assert if there is some
circumstance where this occurs and no error has been reported, but it
won't crash the compiler in this instance.

While debugging this, I noticed a translation ICE in a delayed bug, so I fixed that too:

> During borrowck, the `MultiSpan` from a buffered diagnostic is cloned and
used to emit a delayed bug indicating a diagnostic was buffered - when
the buffered diagnostic is translated, then the cloned `MultiSpan` may
contain labels which can only render with the diagnostic's arguments, but
the delayed bug being emitted won't have those arguments. Adds a function
which clones `MultiSpan` without also cloning the contained labels, and
use this function when creating the buffered diagnostic delayed bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coroutines Area: Coroutines C-bug Category: This is a bug. F-coroutines `#![feature(coroutines)]` glacier ICE tracked in rust-lang/glacier. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants