Skip to content

ICE: assertion failed: layout.is_sized() #137186

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

static no_mangle: str = {
    unimplemented!();
};

original:

#[track_caller]
static no_mangle: str = {
    unimplemented!();
};

Version information

rustc 1.87.0-nightly (ce36a966c 2025-02-17)
binary: rustc
commit-hash: ce36a966c79e109dabeef7a47fe68e5294c6d71e
commit-date: 2025-02-17
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

| DefKind::AssocConst
),
"Unexpected DefKind: {:?}",
ecx.tcx.def_kind(cid.instance.def_id())
);
let layout = ecx.layout_of(body.bound_return_ty().instantiate(tcx, cid.instance.args))?;
assert!(layout.is_sized());
let intern_kind = if cid.promoted.is_some() {
InternKind::Promoted
} else {
match tcx.static_mutability(cid.instance.def_id()) {
Some(m) => InternKind::Static(m),

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.pWi9wq9I3FhY/rustc_testrunner_tmpdir_reporting.LzJ1a0v253mW/mvce.rs:3:3
  |
3 | };
  |   ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.pWi9wq9I3FhY/rustc_testrunner_tmpdir_reporting.LzJ1a0v253mW/mvce.rs`

error[E0277]: the size for values of type `str` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.pWi9wq9I3FhY/rustc_testrunner_tmpdir_reporting.LzJ1a0v253mW/mvce.rs:1:19
  |
1 | static no_mangle: str = {
  |                   ^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `str`


thread 'rustc' panicked at compiler/rustc_const_eval/src/const_eval/eval_queries.rs:49:5:
assertion failed: layout.is_sized()
stack backtrace:
   0:     0x70741cd99e40 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h3841cd57ff2ecd73
   1:     0x70741d6148ac - core::fmt::write::h1e3520bf56740af3
   2:     0x70741e6318d1 - std::io::Write::write_fmt::hba9e4167b3001b26
   3:     0x70741cd99ca2 - std::sys::backtrace::BacktraceLock::print::h4cef63a231b9b903
   4:     0x70741cd9c4a6 - std::panicking::default_hook::{{closure}}::h42a071c1742d1486
   5:     0x70741cd9c084 - std::panicking::default_hook::hb623603f8ca8d5a9
   6:     0x70741bee571b - std[3b75b760e1909bee]::panicking::update_hook::<alloc[fee51eceb6acdb2a]::boxed::Box<rustc_driver_impl[345723d7f8fea549]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x70741cd9cd53 - std::panicking::rust_panic_with_hook::h4a78a56a08a0281e
   8:     0x70741cd9ca16 - std::panicking::begin_panic_handler::{{closure}}::h003b3348edc396e0
   9:     0x70741cd9a309 - std::sys::backtrace::__rust_end_short_backtrace::h40301e4d631caaec
  10:     0x70741cd9c70d - rust_begin_unwind
  11:     0x707419a459e0 - core::panicking::panic_fmt::hf9c35d88d19a7b20
  12:     0x70741a44a02c - core::panicking::panic::h816f8e94a2911cfd
  13:     0x70741d675c7e - rustc_const_eval[24ba1ca4ddcda3d4]::const_eval::eval_queries::eval_body_using_ecx::<rustc_middle[8f0bb18145f914db]::mir::interpret::allocation::ConstAllocation>
  14:     0x70741e2e9640 - rustc_const_eval[24ba1ca4ddcda3d4]::const_eval::eval_queries::eval_static_initializer_provider
  15:     0x70741e2e93d9 - rustc_query_impl[1dc7e25d3505b9db]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1dc7e25d3505b9db]::query_impl::eval_static_initializer::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8f0bb18145f914db]::query::erase::Erased<[u8; 16usize]>>
  16:     0x70741e2e93b1 - <rustc_query_impl[1dc7e25d3505b9db]::query_impl::eval_static_initializer::dynamic_query::{closure#2} as core[22e5dcc507c1ce60]::ops::function::FnOnce<(rustc_middle[8f0bb18145f914db]::ty::context::TyCtxt, rustc_span[75e5c439b5acee8]::def_id::DefId)>>::call_once
  17:     0x70741dbbaa9b - rustc_query_system[923c01520de53f9e]::query::plumbing::try_execute_query::<rustc_query_impl[1dc7e25d3505b9db]::DynamicConfig<rustc_query_system[923c01520de53f9e]::query::caches::DefIdCache<rustc_middle[8f0bb18145f914db]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[1dc7e25d3505b9db]::plumbing::QueryCtxt, false>
  18:     0x70741e69c73a - rustc_query_impl[1dc7e25d3505b9db]::query_impl::eval_static_initializer::get_query_non_incr::__rust_end_short_backtrace
  19:     0x70741d9ac458 - <rustc_middle[8f0bb18145f914db]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[6ca72d962790c728]::check_crate::{closure#2}>::{closure#0}
  20:     0x70741d9ab238 - rustc_hir_analysis[6ca72d962790c728]::check_crate
  21:     0x70741d95f8dc - rustc_interface[d53afbea1eb411d7]::passes::run_required_analyses
  22:     0x70741e62d95e - rustc_interface[d53afbea1eb411d7]::passes::analysis
  23:     0x70741e62d92f - rustc_query_impl[1dc7e25d3505b9db]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1dc7e25d3505b9db]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8f0bb18145f914db]::query::erase::Erased<[u8; 0usize]>>
  24:     0x70741e617495 - rustc_query_system[923c01520de53f9e]::query::plumbing::try_execute_query::<rustc_query_impl[1dc7e25d3505b9db]::DynamicConfig<rustc_query_system[923c01520de53f9e]::query::caches::SingleCache<rustc_middle[8f0bb18145f914db]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1dc7e25d3505b9db]::plumbing::QueryCtxt, false>
  25:     0x70741e6171ce - rustc_query_impl[1dc7e25d3505b9db]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  26:     0x70741e6daf3c - rustc_interface[d53afbea1eb411d7]::passes::create_and_enter_global_ctxt::<core[22e5dcc507c1ce60]::option::Option<rustc_interface[d53afbea1eb411d7]::queries::Linker>, rustc_driver_impl[345723d7f8fea549]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  27:     0x70741e6557e2 - rustc_interface[d53afbea1eb411d7]::interface::run_compiler::<(), rustc_driver_impl[345723d7f8fea549]::run_compiler::{closure#0}>::{closure#1}
  28:     0x70741e5d5898 - std[3b75b760e1909bee]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d53afbea1eb411d7]::util::run_in_thread_with_globals<rustc_interface[d53afbea1eb411d7]::util::run_in_thread_pool_with_globals<rustc_interface[d53afbea1eb411d7]::interface::run_compiler<(), rustc_driver_impl[345723d7f8fea549]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  29:     0x70741e5d5574 - <<std[3b75b760e1909bee]::thread::Builder>::spawn_unchecked_<rustc_interface[d53afbea1eb411d7]::util::run_in_thread_with_globals<rustc_interface[d53afbea1eb411d7]::util::run_in_thread_pool_with_globals<rustc_interface[d53afbea1eb411d7]::interface::run_compiler<(), rustc_driver_impl[345723d7f8fea549]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[22e5dcc507c1ce60]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x70741e5d4d2b - std::sys::pal::unix::thread::Thread::new::thread_start::h9b930113dc9df217
  31:     0x7074186a339d - <unknown>
  32:     0x70741872849c - <unknown>
  33:                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.87.0-nightly (ce36a966c 2025-02-17) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_static_initializer] evaluating initializer of static `no_mangle`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

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

Metadata

Metadata

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions