Skip to content

[ICE]: wasm: unsized type for size_of #156051

@matthiaskrgr

Description

@matthiaskrgr

Code

rustc a.rs --crate-type lib --target=wasm32-wasip2 -Zmir-opt-level=3

pub trait Widget<E> {
    fn boxed<'w>(self) -> Box<dyn WidgetDyn<E> + 'w>
    where
        Self: Sized + 'w;
}

pub trait WidgetDyn<E> {}

impl<T, E> WidgetDyn<E> for T where T: Widget<E> {}

impl<E> Widget<E> for dyn WidgetDyn<E> + '_ {
    fn boxed<'w>(self) -> Box<dyn WidgetDyn<E> + 'w>
    where
        Self: Sized + 'w,
    {
        // Even though this is illegal to const evaluate, this should never
        // trigger an ICE because it can never be called from actual code
        // (due to the trivially false where-clause predicate).
        Box::new(self)
    }
}

Meta

rustc --version --verbose:

rustc 1.97.0-nightly (f53b654a8 2026-04-30)
binary: rustc
commit-hash: f53b654a8882fd5fc036c4ca7a4ff41ce32497a6
commit-date: 2026-04-30
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4

Error output

<output>
Backtrace

warning: this item cannot be used as its where bounds are not satisfied for the `Self` type
  --> a.rs:15:5
   |
15 | /     fn boxed<'w>(self) -> Box<dyn WidgetDyn<E> + 'w>
16 | |     where
17 | |         Self: Sized + 'w,
   | |_________________________^
   |
   = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

error: internal compiler error: /rustc-dev/f53b654a8882fd5fc036c4ca7a4ff41ce32497a6/compiler/rustc_const_eval/src/interpret/intrinsics.rs:216:21: unsized type for `size_of`
    --> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:1379:25
     |
1379 |     const SIZE: usize = intrinsics::size_of::<Self>();
     |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


thread 'rustc' (3100640) panicked at /rustc-dev/f53b654a8882fd5fc036c4ca7a4ff41ce32497a6/compiler/rustc_const_eval/src/interpret/intrinsics.rs:216:21:
Box<dyn Any>
stack backtrace:
   0:     0x7f9e44a767b9 - <<std[664156f38db6df9a]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[703624273cedab6d]::fmt::Display>::fmt
   1:     0x7f9e45015f08 - core[703624273cedab6d]::fmt::write
   2:     0x7f9e44a8d1e6 - <std[664156f38db6df9a]::sys::stdio::unix::Stderr as std[664156f38db6df9a]::io::Write>::write_fmt
   3:     0x7f9e44a4c98e - std[664156f38db6df9a]::panicking::default_hook::{closure#0}
   4:     0x7f9e44a69e73 - std[664156f38db6df9a]::panicking::default_hook
   5:     0x7f9e43a60051 - std[664156f38db6df9a]::panicking::update_hook::<alloc[150995461fc6fe17]::boxed::Box<rustc_driver_impl[2526e35b49e1b9f9]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f9e44a6a152 - std[664156f38db6df9a]::panicking::panic_with_hook
   7:     0x7f9e43a8f871 - std[664156f38db6df9a]::panicking::begin_panic::<rustc_errors[2693d4ed35fc52ab]::ExplicitBug>::{closure#0}
   8:     0x7f9e43a88866 - std[664156f38db6df9a]::sys::backtrace::__rust_end_short_backtrace::<std[664156f38db6df9a]::panicking::begin_panic<rustc_errors[2693d4ed35fc52ab]::ExplicitBug>::{closure#0}, !>
   9:     0x7f9e43a865e8 - std[664156f38db6df9a]::panicking::begin_panic::<rustc_errors[2693d4ed35fc52ab]::ExplicitBug>
  10:     0x7f9e43a9ad51 - <rustc_errors[2693d4ed35fc52ab]::diagnostic::BugAbort as rustc_errors[2693d4ed35fc52ab]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f9e4404354c - <rustc_errors[2693d4ed35fc52ab]::DiagCtxtHandle>::span_bug::<rustc_span[2d3dd618ebd931a]::span_encoding::Span, alloc[150995461fc6fe17]::string::String>
  12:     0x7f9e4406f0d6 - rustc_middle[5557c243720a2efc]::util::bug::opt_span_bug_fmt::<rustc_span[2d3dd618ebd931a]::span_encoding::Span>::{closure#0}
  13:     0x7f9e4406f282 - rustc_middle[5557c243720a2efc]::ty::context::tls::with_opt::<rustc_middle[5557c243720a2efc]::util::bug::opt_span_bug_fmt<rustc_span[2d3dd618ebd931a]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f9e4405d90b - rustc_middle[5557c243720a2efc]::ty::context::tls::with_context_opt::<rustc_middle[5557c243720a2efc]::ty::context::tls::with_opt<rustc_middle[5557c243720a2efc]::util::bug::opt_span_bug_fmt<rustc_span[2d3dd618ebd931a]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f9e41e3fd98 - rustc_middle[5557c243720a2efc]::util::bug::span_bug_fmt::<rustc_span[2d3dd618ebd931a]::span_encoding::Span>
  16:     0x7f9e4304b2c3 - <rustc_const_eval[befec05bf7cf0772]::interpret::eval_context::InterpCx<rustc_const_eval[befec05bf7cf0772]::const_eval::machine::CompileTimeMachine>>::eval_intrinsic
  17:     0x7f9e4304696c - <rustc_const_eval[befec05bf7cf0772]::const_eval::machine::CompileTimeMachine as rustc_const_eval[befec05bf7cf0772]::interpret::machine::Machine>::call_intrinsic
  18:     0x7f9e422c685b - <rustc_const_eval[befec05bf7cf0772]::interpret::eval_context::InterpCx<rustc_const_eval[befec05bf7cf0772]::const_eval::machine::CompileTimeMachine>>::init_fn_call
  19:     0x7f9e429be573 - rustc_const_eval[befec05bf7cf0772]::const_eval::eval_queries::eval_to_allocation_raw_provider
  20:     0x7f9e458b9c96 - rustc_query_impl[53e4749d94278651]::query_impl::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
  21:     0x7f9e458b9346 - rustc_query_impl[53e4749d94278651]::execution::try_execute_query::<rustc_middle[5557c243720a2efc]::query::caches::DefaultCache<rustc_middle[5557c243720a2efc]::ty::PseudoCanonicalInput<rustc_middle[5557c243720a2efc]::mir::interpret::GlobalId>, rustc_middle[5557c243720a2efc]::query::erase::ErasedData<[u8; 24usize]>>, false>
  22:     0x7f9e458b8d45 - rustc_query_impl[53e4749d94278651]::query_impl::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7f9e458ba736 - rustc_const_eval[befec05bf7cf0772]::const_eval::eval_queries::eval_to_const_value_raw_provider
  24:     0x7f9e458ba296 - rustc_query_impl[53e4749d94278651]::query_impl::eval_to_const_value_raw::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x7f9e458b923e - rustc_query_impl[53e4749d94278651]::execution::try_execute_query::<rustc_middle[5557c243720a2efc]::query::caches::DefaultCache<rustc_middle[5557c243720a2efc]::ty::PseudoCanonicalInput<rustc_middle[5557c243720a2efc]::mir::interpret::GlobalId>, rustc_middle[5557c243720a2efc]::query::erase::ErasedData<[u8; 24usize]>>, false>
  26:     0x7f9e458b8dff - rustc_query_impl[53e4749d94278651]::query_impl::eval_to_const_value_raw::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f9e45b4071c - <rustc_middle[5557c243720a2efc]::ty::context::TyCtxt>::const_eval_resolve
  28:     0x7f9e458ecd4b - <rustc_middle[5557c243720a2efc]::mir::consts::Const>::eval
  29:     0x7f9e458ec559 - <rustc_const_eval[befec05bf7cf0772]::interpret::eval_context::InterpCx<rustc_const_eval[befec05bf7cf0772]::const_eval::machine::CompileTimeMachine>>::push_stack_frame_raw
  30:     0x7f9e429bbecf - rustc_const_eval[befec05bf7cf0772]::const_eval::eval_queries::eval_to_allocation_raw_provider
  31:     0x7f9e458b9c96 - rustc_query_impl[53e4749d94278651]::query_impl::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
  32:     0x7f9e458b9346 - rustc_query_impl[53e4749d94278651]::execution::try_execute_query::<rustc_middle[5557c243720a2efc]::query::caches::DefaultCache<rustc_middle[5557c243720a2efc]::ty::PseudoCanonicalInput<rustc_middle[5557c243720a2efc]::mir::interpret::GlobalId>, rustc_middle[5557c243720a2efc]::query::erase::ErasedData<[u8; 24usize]>>, false>
  33:     0x7f9e458b8d45 - rustc_query_impl[53e4749d94278651]::query_impl::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
  34:     0x7f9e458ba736 - rustc_const_eval[befec05bf7cf0772]::const_eval::eval_queries::eval_to_const_value_raw_provider
  35:     0x7f9e458ba296 - rustc_query_impl[53e4749d94278651]::query_impl::eval_to_const_value_raw::invoke_provider_fn::__rust_begin_short_backtrace
  36:     0x7f9e458b923e - rustc_query_impl[53e4749d94278651]::execution::try_execute_query::<rustc_middle[5557c243720a2efc]::query::caches::DefaultCache<rustc_middle[5557c243720a2efc]::ty::PseudoCanonicalInput<rustc_middle[5557c243720a2efc]::mir::interpret::GlobalId>, rustc_middle[5557c243720a2efc]::query::erase::ErasedData<[u8; 24usize]>>, false>
  37:     0x7f9e458b8dff - rustc_query_impl[53e4749d94278651]::query_impl::eval_to_const_value_raw::execute_query_non_incr::__rust_end_short_backtrace
  38:     0x7f9e45b40ba6 - <rustc_middle[5557c243720a2efc]::ty::context::TyCtxt>::const_eval_resolve
  39:     0x7f9e45b2a18f - <rustc_const_eval[befec05bf7cf0772]::interpret::eval_context::InterpCx<rustc_const_eval[befec05bf7cf0772]::const_eval::dummy_machine::DummyMachine>>::eval_mir_constant
  40:     0x7f9e46441dce - <rustc_mir_transform[fce5d52f15d06436]::gvn::VnState>::eval_to_const
  41:     0x7f9e45d72b18 - <rustc_mir_transform[fce5d52f15d06436]::gvn::VnState>::simplify_operand
  42:     0x7f9e45d71521 - <rustc_mir_transform[fce5d52f15d06436]::gvn::VnState as rustc_middle[5557c243720a2efc]::mir::visit::MutVisitor>::visit_operand
  43:     0x7f9e45d771c3 - <rustc_mir_transform[fce5d52f15d06436]::gvn::GVN as rustc_mir_transform[fce5d52f15d06436]::pass_manager::MirPass>::run_pass
  44:     0x7f9e45008a8e - rustc_mir_transform[fce5d52f15d06436]::run_optimization_passes
  45:     0x7f9e4550c342 - rustc_mir_transform[fce5d52f15d06436]::optimized_mir
  46:     0x7f9e4550bf9d - rustc_query_impl[53e4749d94278651]::query_impl::optimized_mir::invoke_provider_fn::__rust_begin_short_backtrace
  47:     0x7f9e4501350d - rustc_query_impl[53e4749d94278651]::execution::try_execute_query::<rustc_middle[5557c243720a2efc]::query::caches::DefIdCache<rustc_middle[5557c243720a2efc]::query::erase::ErasedData<[u8; 8usize]>>, false>
  48:     0x7f9e45012b4e - rustc_query_impl[53e4749d94278651]::query_impl::optimized_mir::execute_query_non_incr::__rust_end_short_backtrace
  49:     0x7f9e45fde34e - <rustc_metadata[1383c13ad8a7daef]::rmeta::encoder::EncodeContext>::encode_crate_root
  50:     0x7f9e463fdcda - rustc_metadata[1383c13ad8a7daef]::rmeta::encoder::encode_metadata::{closure#3}
  51:     0x7f9e463fb027 - rustc_metadata[1383c13ad8a7daef]::rmeta::encoder::encode_metadata
  52:     0x7f9e45d28bc5 - rustc_metadata[1383c13ad8a7daef]::fs::encode_and_write_metadata
  53:     0x7f9e461bd982 - <rustc_interface[952682f9f3d307b7]::queries::Linker>::codegen_and_build_linker
  54:     0x7f9e461b7f6c - rustc_interface[952682f9f3d307b7]::interface::run_compiler::<(), rustc_driver_impl[2526e35b49e1b9f9]::run_compiler::{closure#0}>::{closure#1}
  55:     0x7f9e4619537e - std[664156f38db6df9a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[952682f9f3d307b7]::util::run_in_thread_with_globals<rustc_interface[952682f9f3d307b7]::util::run_in_thread_pool_with_globals<rustc_interface[952682f9f3d307b7]::interface::run_compiler<(), rustc_driver_impl[2526e35b49e1b9f9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  56:     0x7f9e46195a6d - <std[664156f38db6df9a]::thread::lifecycle::spawn_unchecked<rustc_interface[952682f9f3d307b7]::util::run_in_thread_with_globals<rustc_interface[952682f9f3d307b7]::util::run_in_thread_pool_with_globals<rustc_interface[952682f9f3d307b7]::interface::run_compiler<(), rustc_driver_impl[2526e35b49e1b9f9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[703624273cedab6d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  57:     0x7f9e4619686c - <std[664156f38db6df9a]::sys::thread::unix::Thread>::new::thread_start
  58:     0x7f9e3fea597a - <unknown>
  59:     0x7f9e3ff292bc - <unknown>
  60:                0x0 - <unknown>

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 `/tmp/im/rustc-ice-2026-05-01T15_12_57-3100630.txt` to your bug report

note: rustc 1.97.0-nightly (f53b654a8 2026-04-30) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z mir-opt-level=3

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `core::mem::SizedTypeProperties::SIZE`
#1 [eval_to_const_value_raw] simplifying constant for the type system `core::mem::SizedTypeProperties::SIZE`
#2 [eval_to_allocation_raw] const-evaluating + checking `core::mem::SizedTypeProperties::LAYOUT`
#3 [eval_to_const_value_raw] simplifying constant for the type system `core::mem::SizedTypeProperties::LAYOUT`
#4 [optimized_mir] optimizing MIR for `<impl at a.rs:14:1: 14:44>::boxed`
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-mir-optArea: MIR optimizationsA-mir-opt-GVNArea: MIR opt Global Value Numbering (GVN)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️O-wasmTarget: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions