Skip to content

ICE: layout.is_sized() #115809

Closed
Closed

Description

@matthiaskrgr

Code

rustc --crate-type=lib -Zmir-opt-level=2 -Zpolymorphize=on

pub trait A {
    type B;
}

pub struct S<T: A>(T::B);

pub fn foo<T: A>(p: *mut S<T>) {
    let sides: Vec<_> = Vec::from([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]);
    let mut side = sides.iter();
    while let Some(points) = side.next() {
        match &points[..] {
            [p1, p2] => match [p1[..], p2[..]] {
                [[x1, y1], [x2, y2]] => {}
                _ => (),
            },
            _ => (),
        }
    }
}

Meta

rustc --version --verbose:

rustc 1.74.0-nightly (b4e54c6e3 2023-09-11)
binary: rustc
commit-hash: b4e54c6e39984840a04dcd02d14ec8c3574d30e5
commit-date: 2023-09-11
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0

Error output

warning: unused variable: `x1`
 --> f.rs:9:19
  |
9 |                 [[x1, y1], [x2, y2]] => {}
  |                   ^^ help: if this is intentional, prefix it with an underscore: `_x1`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `y1`
 --> f.rs:9:23
  |
9 |                 [[x1, y1], [x2, y2]] => {}
  |                       ^^ help: if this is intentional, prefix it with an underscore: `_y1`

warning: unused variable: `x2`
 --> f.rs:9:29
  |
9 |                 [[x1, y1], [x2, y2]] => {}
  |                             ^^ help: if this is intentional, prefix it with an underscore: `_x2`

warning: unused variable: `y2`
 --> f.rs:9:33
  |
9 |                 [[x1, y1], [x2, y2]] => {}
  |                                 ^^ help: if this is intentional, prefix it with an underscore: `_y2`

error[E0161]: cannot move a value of type `[i32]`
 --> f.rs:8:32
  |
8 |             [p1, p2] => match [p1[..], p2[..]] {
  |                                ^^^^^^ the size of `[i32]` cannot be statically determined

error[E0161]: cannot move a value of type `[i32]`
 --> f.rs:8:40
  |
8 |             [p1, p2] => match [p1[..], p2[..]] {
  |                                        ^^^^^^ the size of `[i32]` cannot be statically determined

error[E0508]: cannot move out of type `[i32]`, a non-copy slice
 --> f.rs:8:32
  |
8 |             [p1, p2] => match [p1[..], p2[..]] {
  |                                ^^^^^^
  |                                |
  |                                cannot move out of here
  |                                move occurs because value has type `[i32]`, which does not implement the `Copy` trait

error[E0508]: cannot move out of type `[i32]`, a non-copy slice
 --> f.rs:8:40
  |
8 |             [p1, p2] => match [p1[..], p2[..]] {
  |                                        ^^^^^^
  |                                        |
  |                                        cannot move out of here
  |                                        move occurs because value has type `[i32]`, which does not implement the `Copy` trait
Backtrace

thread 'rustc' panicked at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/compiler/rustc_const_eval/src/interpret/projection.rs:68:9:
assertion failed: layout.is_sized()
stack backtrace:
   0:     0x7f5ec2901efc - std::backtrace_rs::backtrace::libunwind::trace::h170ba77b7937dfc1
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f5ec2901efc - std::backtrace_rs::backtrace::trace_unsynchronized::ha3ffdef167b36dcf
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5ec2901efc - std::sys_common::backtrace::_print_fmt::h3593f75d449d7c19
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f5ec2901efc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3d681876fb1a0c35
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f5ec296815c - core::fmt::rt::Argument::fmt::h28dae40336be117d
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/core/src/fmt/rt.rs:138:9
   5:     0x7f5ec296815c - core::fmt::write::hc7ede5ba8d1b34fc
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f5ec28f493e - std::io::Write::write_fmt::h4b5cbdfd5c06e4d9
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/io/mod.rs:1714:15
   7:     0x7f5ec2901ce4 - std::sys_common::backtrace::_print::hf9f8d894d0fba8f4
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f5ec2901ce4 - std::sys_common::backtrace::print::h6736ec2ce0b1565d
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f5ec2904dda - std::panicking::panic_hook_with_disk_dump::{{closure}}::h23059af5ca98b58a
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/panicking.rs:280:22
  10:     0x7f5ec2904ad5 - std::panicking::panic_hook_with_disk_dump::h6a2d92a5ff298e6f
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/panicking.rs:314:9
  11:     0x7f5ec1751e49 - rustc_driver_impl[f8442aae50b2ebe1]::install_ice_hook::{closure#0}
  12:     0x7f5ec2905693 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h34ea97e0bbf89982
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/alloc/src/boxed.rs:2021:9
  13:     0x7f5ec2905693 - std::panicking::rust_panic_with_hook::h71b4835249b93020
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/panicking.rs:757:13
  14:     0x7f5ec29053c6 - std::panicking::begin_panic_handler::{{closure}}::haf0bd6f65b167fe9
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/panicking.rs:623:13
  15:     0x7f5ec2902426 - std::sys_common::backtrace::__rust_end_short_backtrace::hec6b1c9c3aaa2fc0
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/sys_common/backtrace.rs:170:18
  16:     0x7f5ec2905152 - rust_begin_unwind
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/panicking.rs:619:5
  17:     0x7f5ec2964505 - core::panicking::panic_fmt::hfe421f38e4eebe22
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/core/src/panicking.rs:72:14
  18:     0x7f5ec29645a3 - core::panicking::panic::h78eb9cd691eeb3c6
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/core/src/panicking.rs:127:5
  19:     0x7f5ec08c44de - <rustc_const_eval[d84dc7f24a6adf38]::interpret::eval_context::InterpCx<rustc_mir_transform[4c572a45d5e223d3]::const_prop::ConstPropMachine>>::project_index::<rustc_const_eval[d84dc7f24a6adf38]::interpret::place::PlaceTy>
  20:     0x7f5ec08c9f3a - <rustc_const_eval[d84dc7f24a6adf38]::interpret::eval_context::InterpCx<rustc_mir_transform[4c572a45d5e223d3]::const_prop::ConstPropMachine>>::eval_place
  21:     0x7f5ec08a66cb - <rustc_const_eval[d84dc7f24a6adf38]::interpret::eval_context::InterpCx<rustc_mir_transform[4c572a45d5e223d3]::const_prop::ConstPropMachine>>::eval_rvalue_into_place
  22:     0x7f5ebfb9a361 - <rustc_mir_transform[4c572a45d5e223d3]::const_prop::ConstPropagator as rustc_middle[b639b8b23e8d3436]::mir::visit::MutVisitor>::visit_assign
  23:     0x7f5ebfb993dd - <rustc_mir_transform[4c572a45d5e223d3]::const_prop::ConstPropagator as rustc_middle[b639b8b23e8d3436]::mir::visit::MutVisitor>::visit_basic_block_data
  24:     0x7f5ebfb98d0e - <rustc_mir_transform[4c572a45d5e223d3]::const_prop::ConstProp as rustc_middle[b639b8b23e8d3436]::mir::MirPass>::run_pass
  25:     0x7f5ec06663bd - rustc_mir_transform[4c572a45d5e223d3]::pass_manager::run_passes
  26:     0x7f5ec06658e7 - rustc_mir_transform[4c572a45d5e223d3]::optimized_mir
  27:     0x7f5ebf893cb8 - rustc_query_impl[5d5a3cff05f7bed8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5d5a3cff05f7bed8]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b639b8b23e8d3436]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7f5ebf893c81 - <rustc_query_impl[5d5a3cff05f7bed8]::query_impl::optimized_mir::dynamic_query::{closure#2} as core[8975a1ebd15850b5]::ops::function::FnOnce<(rustc_middle[b639b8b23e8d3436]::ty::context::TyCtxt, rustc_span[319b9c0a2f58e367]::def_id::DefId)>>::call_once
  29:     0x7f5ebf84e490 - rustc_query_system[50f896f966c25655]::query::plumbing::try_execute_query::<rustc_query_impl[5d5a3cff05f7bed8]::DynamicConfig<rustc_query_system[50f896f966c25655]::query::caches::DefaultCache<rustc_span[319b9c0a2f58e367]::def_id::DefId, rustc_middle[b639b8b23e8d3436]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5d5a3cff05f7bed8]::plumbing::QueryCtxt, false>
  30:     0x7f5ec10cf6e2 - rustc_query_impl[5d5a3cff05f7bed8]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7f5ec1f3cf17 - rustc_middle[b639b8b23e8d3436]::query::plumbing::query_get_at::<rustc_query_system[50f896f966c25655]::query::caches::DefaultCache<rustc_span[319b9c0a2f58e367]::def_id::DefId, rustc_middle[b639b8b23e8d3436]::query::erase::Erased<[u8; 8usize]>>>
  32:     0x7f5ebff19102 - rustc_query_impl[5d5a3cff05f7bed8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5d5a3cff05f7bed8]::query_impl::unused_generic_params::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b639b8b23e8d3436]::query::erase::Erased<[u8; 4usize]>>
  33:     0x7f5ec0005f25 - rustc_query_system[50f896f966c25655]::query::plumbing::try_execute_query::<rustc_query_impl[5d5a3cff05f7bed8]::DynamicConfig<rustc_query_system[50f896f966c25655]::query::caches::DefaultCache<rustc_middle[b639b8b23e8d3436]::ty::instance::InstanceDef, rustc_middle[b639b8b23e8d3436]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[5d5a3cff05f7bed8]::plumbing::QueryCtxt, false>
  34:     0x7f5ec0005bb9 - rustc_query_impl[5d5a3cff05f7bed8]::query_impl::unused_generic_params::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f5ec0919618 - <rustc_session[680ed56a62bc0fcf]::session::Session>::time::<(), rustc_interface[afabc26049662c5e]::passes::analysis::{closure#2}>
  36:     0x7f5ec0915290 - rustc_interface[afabc26049662c5e]::passes::analysis
  37:     0x7f5ec0b9f46a - rustc_query_impl[5d5a3cff05f7bed8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5d5a3cff05f7bed8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b639b8b23e8d3436]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7f5ec0b9f459 - <rustc_query_impl[5d5a3cff05f7bed8]::query_impl::analysis::dynamic_query::{closure#2} as core[8975a1ebd15850b5]::ops::function::FnOnce<(rustc_middle[b639b8b23e8d3436]::ty::context::TyCtxt, ())>>::call_once
  39:     0x7f5ec0e85174 - rustc_query_system[50f896f966c25655]::query::plumbing::try_execute_query::<rustc_query_impl[5d5a3cff05f7bed8]::DynamicConfig<rustc_query_system[50f896f966c25655]::query::caches::SingleCache<rustc_middle[b639b8b23e8d3436]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5d5a3cff05f7bed8]::plumbing::QueryCtxt, false>
  40:     0x7f5ec0e84ee9 - rustc_query_impl[5d5a3cff05f7bed8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7f5ec0c6ac13 - <rustc_middle[b639b8b23e8d3436]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[f8442aae50b2ebe1]::run_compiler::{closure#1}::{closure#2}::{closure#6}, core[8975a1ebd15850b5]::result::Result<(), rustc_span[319b9c0a2f58e367]::ErrorGuaranteed>>
  42:     0x7f5ec0c69d08 - <rustc_interface[afabc26049662c5e]::interface::Compiler>::enter::<rustc_driver_impl[f8442aae50b2ebe1]::run_compiler::{closure#1}::{closure#2}, core[8975a1ebd15850b5]::result::Result<core[8975a1ebd15850b5]::option::Option<rustc_interface[afabc26049662c5e]::queries::Linker>, rustc_span[319b9c0a2f58e367]::ErrorGuaranteed>>
  43:     0x7f5ec0c62fd4 - std[ba7dab7da19e8c24]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[afabc26049662c5e]::util::run_in_thread_with_globals<rustc_interface[afabc26049662c5e]::interface::run_compiler<core[8975a1ebd15850b5]::result::Result<(), rustc_span[319b9c0a2f58e367]::ErrorGuaranteed>, rustc_driver_impl[f8442aae50b2ebe1]::run_compiler::{closure#1}>::{closure#0}, core[8975a1ebd15850b5]::result::Result<(), rustc_span[319b9c0a2f58e367]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8975a1ebd15850b5]::result::Result<(), rustc_span[319b9c0a2f58e367]::ErrorGuaranteed>>
  44:     0x7f5ec0c6272e - <<std[ba7dab7da19e8c24]::thread::Builder>::spawn_unchecked_<rustc_interface[afabc26049662c5e]::util::run_in_thread_with_globals<rustc_interface[afabc26049662c5e]::interface::run_compiler<core[8975a1ebd15850b5]::result::Result<(), rustc_span[319b9c0a2f58e367]::ErrorGuaranteed>, rustc_driver_impl[f8442aae50b2ebe1]::run_compiler::{closure#1}>::{closure#0}, core[8975a1ebd15850b5]::result::Result<(), rustc_span[319b9c0a2f58e367]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8975a1ebd15850b5]::result::Result<(), rustc_span[319b9c0a2f58e367]::ErrorGuaranteed>>::{closure#1} as core[8975a1ebd15850b5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7f5ec2910075 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf087c3a953991192
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/alloc/src/boxed.rs:2007:9
  46:     0x7f5ec2910075 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h911ae42726efeb98
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/alloc/src/boxed.rs:2007:9
  47:     0x7f5ec2910075 - std::sys::unix::thread::Thread::new::thread_start::hb163d3257e70a2e6
                               at /rustc/b4e54c6e39984840a04dcd02d14ec8c3574d30e5/library/std/src/sys/unix/thread.rs:108:17
  48:     0x7f5ebe28c9eb - <unknown>
  49:     0x7f5ebe310dfc - <unknown>
  50:                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: please attach the file at `/tmp/im/2/rustc-ice-2023-09-13T05:00:57.948105458Z-1438393.txt` to your bug report

note: compiler flags: --crate-type lib -Z mir-opt-level=2 -Z polymorphize=on

query stack during panic:
#0 [optimized_mir] optimizing MIR for `foo`
#1 [unused_generic_params] determining which generic parameters are unused by `foo`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors; 4 warnings emitted

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

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    -ZpolymorphizeUnstable option: Polymorphization.
    on Sep 13, 2023
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 13, 2023
  3. added a commit that references this issue on Sep 13, 2023
  4. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 13, 2023
  5. added a commit that references this issue on Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    -ZpolymorphizeUnstable option: Polymorphization.C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions