Skip to content

ICE: layout.is_sized() #139872

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

Open
matthiaskrgr opened this issue Apr 15, 2025 · 2 comments
Open

ICE: layout.is_sized() #139872

matthiaskrgr opened this issue Apr 15, 2025 · 2 comments
Labels
A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) 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.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

//@compile-flags: -Zmir-opt-level=5 -Zvalidate-mir



enum E { V16(u16), V32(u32) }
static C: (E, u16, str) = (, 0x600D, 0xBAD);

pub fn main() {
    let (_, n, _) = C;
    
    
}

original:

//@ run-pass
#![allow(dead_code)]

enum E { V16(u16), V32(u32) }
static C: (E, u16, str) = (E::V16(0xDEAD), 0x600D, 0xBAD);

pub fn main() {
    let (_, n, _) = C;
    assert!(n != 0xBAD);
    assert_eq!(n, 0x600D);
}

Version information

rustc 1.88.0-nightly (40dacd50b 2025-04-15)
binary: rustc
commit-hash: 40dacd50b7074783db748d73925ac5c3693a7ec1
commit-date: 2025-04-15
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Possibly related line of code:

// * be able to get information on extern statics.
let ty = tcx
.type_of(def_id)
.no_bound_vars()
.expect("statics should not have generic parameters");
let layout = tcx.layout_of(typing_env.as_query_input(ty)).unwrap();
assert!(layout.is_sized());
(layout.size, layout.align.abi)
}
}
GlobalAlloc::Memory(alloc) => {
let alloc = alloc.inner();
(alloc.size(), alloc.align)

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=5 -Zvalidate-mir

Program output

error: expected expression, found `,`
 --> /tmp/icemaker_global_tempdir.3AprGNyTl55i/rustc_testrunner_tmpdir_reporting.bRtgIyNkaXla/mvce.rs:5:28
  |
5 | static C: (E, u16, str) = (, 0x600D, 0xBAD);
  |                            ^ expected expression

error[E0277]: the size for values of type `str` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.3AprGNyTl55i/rustc_testrunner_tmpdir_reporting.bRtgIyNkaXla/mvce.rs:5:11
  |
5 | static C: (E, u16, str) = (, 0x600D, 0xBAD);
  |           ^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = help: within `(E, u16, str)`, the trait `Sized` is not implemented for `str`
  = note: required because it appears within the type `(E, u16, str)`
  = note: statics and constants must have a statically known size

warning: unused variable: `n`
 --> /tmp/icemaker_global_tempdir.3AprGNyTl55i/rustc_testrunner_tmpdir_reporting.bRtgIyNkaXla/mvce.rs:8:13
  |
8 |     let (_, n, _) = C;
  |             ^ help: if this is intentional, prefix it with an underscore: `_n`
  |
  = note: `#[warn(unused_variables)]` on by default


thread 'rustc' panicked at compiler/rustc_middle/src/mir/interpret/mod.rs:372:21:
assertion failed: layout.is_sized()
stack backtrace:
   0:     0x7f16c90e36f3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hac1fd18538367f85
   1:     0x7f16c9806087 - core::fmt::write::h355b50e2dd48b7cb
   2:     0x7f16cacaab91 - std::io::Write::write_fmt::h3c208cfcae87fbc5
   3:     0x7f16c90e3552 - std::sys::backtrace::BacktraceLock::print::h52bf60fe66a866b6
   4:     0x7f16c90e703a - std::panicking::default_hook::{{closure}}::ha54cd4f331000bf4
   5:     0x7f16c90e6bbf - std::panicking::default_hook::h65502b75eb6b3c4d
   6:     0x7f16c815b843 - std[6f1f62f9e1890267]::panicking::update_hook::<alloc[9c10c445f94edf6f]::boxed::Box<rustc_driver_impl[261694032873b461]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7f16c90e78b3 - std::panicking::rust_panic_with_hook::h9f8305ffe577d3e1
   8:     0x7f16c90e7576 - std::panicking::begin_panic_handler::{{closure}}::h1196da9ca3c9caa6
   9:     0x7f16c90e3bb9 - std::sys::backtrace::__rust_end_short_backtrace::h209d7d99dc310f1c
  10:     0x7f16c90e726d - __rustc[de9843575c99dce8]::rust_begin_unwind
  11:     0x7f16c5a8a680 - core::panicking::panic_fmt::h42dd318a0e6082fa
  12:     0x7f16c5a8f62c - core::panicking::panic::hb0960e31c93bed80
  13:     0x7f16cae0181e - <rustc_middle[2dc3a1ceabbabe6a]::mir::interpret::GlobalAlloc>::size_and_align.cold
  14:     0x7f16ca324c6a - <rustc_const_eval[ae92fa6a8d266fb6]::interpret::eval_context::InterpCx<rustc_const_eval[ae92fa6a8d266fb6]::const_eval::dummy_machine::DummyMachine>>::get_alloc_info
  15:     0x7f16ca334d58 - <rustc_const_eval[ae92fa6a8d266fb6]::interpret::eval_context::InterpCx<rustc_const_eval[ae92fa6a8d266fb6]::const_eval::dummy_machine::DummyMachine>>::ptr_offset_inbounds
  16:     0x7f16ca334ab9 - <rustc_const_eval[ae92fa6a8d266fb6]::interpret::operand::OpTy as rustc_const_eval[ae92fa6a8d266fb6]::interpret::projection::Projectable<rustc_middle[2dc3a1ceabbabe6a]::mir::interpret::pointer::CtfeProvenance>>::offset_with_meta::<rustc_const_eval[ae92fa6a8d266fb6]::const_eval::dummy_machine::DummyMachine>
  17:     0x7f16ca334998 - <rustc_const_eval[ae92fa6a8d266fb6]::interpret::eval_context::InterpCx<rustc_const_eval[ae92fa6a8d266fb6]::const_eval::dummy_machine::DummyMachine>>::project_field::<rustc_const_eval[ae92fa6a8d266fb6]::interpret::operand::OpTy>
  18:     0x7f16ca334447 - <rustc_const_eval[ae92fa6a8d266fb6]::interpret::eval_context::InterpCx<rustc_const_eval[ae92fa6a8d266fb6]::const_eval::dummy_machine::DummyMachine>>::project::<rustc_const_eval[ae92fa6a8d266fb6]::interpret::operand::OpTy>
  19:     0x7f16ca32d176 - <rustc_mir_transform[27e09089e56c5a07]::gvn::VnState>::insert
  20:     0x7f16ca32863b - <rustc_mir_transform[27e09089e56c5a07]::gvn::VnState>::simplify_place_value
  21:     0x7f16ca327deb - <rustc_mir_transform[27e09089e56c5a07]::gvn::VnState>::simplify_operand
  22:     0x7f16c70e2b1e - <rustc_mir_transform[27e09089e56c5a07]::gvn::VnState as rustc_middle[2dc3a1ceabbabe6a]::mir::visit::MutVisitor>::visit_statement
  23:     0x7f16c70e0e97 - <rustc_mir_transform[27e09089e56c5a07]::gvn::GVN as rustc_mir_transform[27e09089e56c5a07]::pass_manager::MirPass>::run_pass
  24:     0x7f16c9803fbb - rustc_mir_transform[27e09089e56c5a07]::pass_manager::run_passes_inner
  25:     0x7f16ca376a9f - rustc_mir_transform[27e09089e56c5a07]::optimized_mir
  26:     0x7f16ca37608d - rustc_query_impl[ad69a23e50a8fbd1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ad69a23e50a8fbd1]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2dc3a1ceabbabe6a]::query::erase::Erased<[u8; 8usize]>>
  27:     0x7f16c9af412f - rustc_query_system[8ca381065095edd4]::query::plumbing::try_execute_query::<rustc_query_impl[ad69a23e50a8fbd1]::DynamicConfig<rustc_query_system[8ca381065095edd4]::query::caches::DefIdCache<rustc_middle[2dc3a1ceabbabe6a]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[ad69a23e50a8fbd1]::plumbing::QueryCtxt, false>
  28:     0x7f16c9af355d - rustc_query_impl[ad69a23e50a8fbd1]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7f16c9db3d46 - <rustc_middle[2dc3a1ceabbabe6a]::ty::context::TyCtxt>::instance_mir
  30:     0x7f16c9c0e0b4 - rustc_interface[f2198cb0de4afffb]::passes::run_required_analyses
  31:     0x7f16ca355f9e - rustc_interface[f2198cb0de4afffb]::passes::analysis
  32:     0x7f16ca355f73 - rustc_query_impl[ad69a23e50a8fbd1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ad69a23e50a8fbd1]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2dc3a1ceabbabe6a]::query::erase::Erased<[u8; 0usize]>>
  33:     0x7f16ca7fb73d - rustc_query_system[8ca381065095edd4]::query::plumbing::try_execute_query::<rustc_query_impl[ad69a23e50a8fbd1]::DynamicConfig<rustc_query_system[8ca381065095edd4]::query::caches::SingleCache<rustc_middle[2dc3a1ceabbabe6a]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[ad69a23e50a8fbd1]::plumbing::QueryCtxt, false>
  34:     0x7f16ca7fb438 - rustc_query_impl[ad69a23e50a8fbd1]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f16cab1b47e - rustc_interface[f2198cb0de4afffb]::passes::create_and_enter_global_ctxt::<core[e6c01ae462af1362]::option::Option<rustc_interface[f2198cb0de4afffb]::queries::Linker>, rustc_driver_impl[261694032873b461]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  36:     0x7f16ca90d904 - rustc_interface[f2198cb0de4afffb]::interface::run_compiler::<(), rustc_driver_impl[261694032873b461]::run_compiler::{closure#0}>::{closure#1}
  37:     0x7f16ca6ee028 - std[6f1f62f9e1890267]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f2198cb0de4afffb]::util::run_in_thread_with_globals<rustc_interface[f2198cb0de4afffb]::util::run_in_thread_pool_with_globals<rustc_interface[f2198cb0de4afffb]::interface::run_compiler<(), rustc_driver_impl[261694032873b461]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  38:     0x7f16ca6ee92b - <<std[6f1f62f9e1890267]::thread::Builder>::spawn_unchecked_<rustc_interface[f2198cb0de4afffb]::util::run_in_thread_with_globals<rustc_interface[f2198cb0de4afffb]::util::run_in_thread_pool_with_globals<rustc_interface[f2198cb0de4afffb]::interface::run_compiler<(), rustc_driver_impl[261694032873b461]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[e6c01ae462af1362]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7f16ca6efd37 - std::sys::pal::unix::thread::Thread::new::thread_start::he9943a285b1830ff
  40:     0x7f16c46a370a - <unknown>
  41:     0x7f16c4727aac - <unknown>
  42:                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 make sure that you have updated to the latest nightly

note: rustc 1.88.0-nightly (40dacd50b 2025-04-15) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=5 -Z validate-mir -Z dump-mir-dir=dir

query stack during panic:
#0 [optimized_mir] optimizing MIR for `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.

@matthiaskrgr matthiaskrgr 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 Apr 15, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 15, 2025
@matthiaskrgr
Copy link
Member Author

bisects to nightly-2024-08-09
commit[0] 2024-08-07: Auto merge of #128796 - matthiaskrgr:rollup-r7l68ph, r=matthiaskrgr
commit[1] 2024-08-07: Auto merge of #128793 - matthiaskrgr:rollup-ork16t0, r=matthiaskrgr
commit[2] 2024-08-08: Auto merge of #128550 - compiler-errors:shadowed-params-perf, r=petrochenkov
commit[3] 2024-08-08: Auto merge of #128805 - tgross35:rollup-wajzi6w, r=tgross35
commit[4] 2024-08-08: Auto merge of #128465 - GrigorenkoPV:128200, r=estebank
commit[5] 2024-08-08: Auto merge of #128639 - folkertdev:rmake-thumb-none-qemu, r=jieyouxu
commit[6] 2024-08-08: Auto merge of #128835 - matthiaskrgr:rollup-apzlbxy, r=matthiaskrgr

@matthiaskrgr
Copy link
Member Author

smaller:

pub fn main() {
    enum A {
        B(u32),
    }
    static C: (A, u16, str);
    fn d() {
        let (_, e, _) = C;
    }
}

``

@matthiaskrgr matthiaskrgr added A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) 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.
Projects
None yet
Development

No branches or pull requests

2 participants