Skip to content

ICE unsized type for 'NullaryOp::AlignOf' #147011

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Zmir-opt-level=5 -Zvalidate-mir
fn main() {
    join_all::<u32>();
}

trait Foo {
    type Item;
}

impl Foo for u32 {
    type Item = u8;
}

trait Bar {
    type Item2;
}

impl Bar for u8 {
    type Item2 = str;
}

fn join_all<I>()
where
    I: Foo,
    I::Item: Bar,
{
    Vec::<<I::Item as Bar>::Item2>::new();
}

original:

//@ compile-flags: -Z mir-opt-level=4
//@ build-pass

// This used to ICE in const-prop due
// to an empty ParamEnv being used during normalization
// of a generic type


fn main() {
    join_all::<u32>();
}

trait Foo {
    type Item;
}

impl Foo for u32 {
    type Item = u8;
}

trait Bar {
    type Item2;
}

impl Bar for u8 {
    type Item2 = str;
}

fn join_all<I>()
where I: Foo,
    I::Item: Bar
{
    Vec::<<I::Item as Bar>::Item2>::new(); // ICE occurs processing this line
}

Version information

rustc 1.92.0-nightly (caccb4d03 2025-09-24)
binary: rustc
commit-hash: caccb4d0368bd918ef6668af8e13834d07040417
commit-date: 2025-09-24
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.2

Possibly related line of code:

}
let val = layout.size.bytes();
ImmTy::from_uint(val, usize_layout())
}
AlignOf => {
if !layout.is_sized() {
span_bug!(self.cur_span(), "unsized type for `NullaryOp::AlignOf`");
}
let val = layout.align.abi.bytes();
ImmTy::from_uint(val, usize_layout())
}
OffsetOf(fields) => {
let val =

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

Program output

error[E0277]: the size for values of type `str` cannot be known at compilation time
  --> /tmp/icemaker_global_tempdir.ECTlVgqoNa1H/rustc_testrunner_tmpdir_reporting.LhU5zzIfyFA7/mvce.rs:18:18
   |
18 |     type Item2 = str;
   |                  ^^^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `str`
note: required by a bound in `Bar::Item2`
  --> /tmp/icemaker_global_tempdir.ECTlVgqoNa1H/rustc_testrunner_tmpdir_reporting.LhU5zzIfyFA7/mvce.rs:14:5
   |
14 |     type Item2;
   |     ^^^^^^^^^^^ required by this bound in `Bar::Item2`
help: consider relaxing the implicit `Sized` restriction
   |
14 |     type Item2: ?Sized;
   |               ++++++++

error: internal compiler error: compiler/rustc_const_eval/src/interpret/operator.rs:529:21: unsized type for `NullaryOp::AlignOf`
   --> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/mem/mod.rs:490:5
    |
490 |     intrinsics::align_of::<T>()
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^


thread 'rustc' (2337994) panicked at compiler/rustc_const_eval/src/interpret/operator.rs:529:21:
Box<dyn Any>
stack backtrace:
   0:     0x7f3f873cc243 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h52160e9da139e442
   1:     0x7f3f87a02004 - core::fmt::write::hf09a056a304e021a
   2:     0x7f3f87380ac1 - std::io::Write::write_fmt::h361c7127187cda65
   3:     0x7f3f87391fb2 - std::sys::backtrace::BacktraceLock::print::h15104dbcf0fd1f14
   4:     0x7f3f87397f19 - std::panicking::default_hook::{{closure}}::h0fa6cd8dbe0dd76b
   5:     0x7f3f87397a43 - std::panicking::default_hook::h8d20506cf72e4831
   6:     0x7f3f863bc747 - std[7e5923e4fb083e6e]::panicking::update_hook::<alloc[80fc306e8c98d7a4]::boxed::Box<rustc_driver_impl[bee8db6accd21c89]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7f3f8739833f - std::panicking::panic_with_hook::h746880a052e02c85
   8:     0x7f3f863f89d1 - std[7e5923e4fb083e6e]::panicking::begin_panic::<rustc_errors[9c69d5374248998b]::ExplicitBug>::{closure#0}
   9:     0x7f3f863ec346 - std[7e5923e4fb083e6e]::sys::backtrace::__rust_end_short_backtrace::<std[7e5923e4fb083e6e]::panicking::begin_panic<rustc_errors[9c69d5374248998b]::ExplicitBug>::{closure#0}, !>
  10:     0x7f3f863e9c89 - std[7e5923e4fb083e6e]::panicking::begin_panic::<rustc_errors[9c69d5374248998b]::ExplicitBug>
  11:     0x7f3f864040c1 - <rustc_errors[9c69d5374248998b]::diagnostic::BugAbort as rustc_errors[9c69d5374248998b]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7f3f86970dac - <rustc_errors[9c69d5374248998b]::DiagCtxtHandle>::span_bug::<rustc_span[19f7d544e5f5d2e0]::span_encoding::Span, alloc[80fc306e8c98d7a4]::string::String>
  13:     0x7f3f86996117 - rustc_middle[85294cbce27cd394]::util::bug::opt_span_bug_fmt::<rustc_span[19f7d544e5f5d2e0]::span_encoding::Span>::{closure#0}
  14:     0x7f3f8699619a - rustc_middle[85294cbce27cd394]::ty::context::tls::with_opt::<rustc_middle[85294cbce27cd394]::util::bug::opt_span_bug_fmt<rustc_span[19f7d544e5f5d2e0]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:     0x7f3f8698497b - rustc_middle[85294cbce27cd394]::ty::context::tls::with_context_opt::<rustc_middle[85294cbce27cd394]::ty::context::tls::with_opt<rustc_middle[85294cbce27cd394]::util::bug::opt_span_bug_fmt<rustc_span[19f7d544e5f5d2e0]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:     0x7f3f849ebca7 - rustc_middle[85294cbce27cd394]::util::bug::span_bug_fmt::<rustc_span[19f7d544e5f5d2e0]::span_encoding::Span>
  17:     0x7f3f87de2d4d - <rustc_const_eval[776b5f2f27615342]::interpret::eval_context::InterpCx<rustc_const_eval[776b5f2f27615342]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
  18:     0x7f3f87db7544 - rustc_const_eval[776b5f2f27615342]::const_eval::eval_queries::eval_to_allocation_raw_provider
  19:     0x7f3f87db67dc - rustc_query_impl[f5e7cf8f1e8ef554]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f5e7cf8f1e8ef554]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[85294cbce27cd394]::query::erase::Erased<[u8; 24usize]>>
  20:     0x7f3f87dac520 - rustc_query_system[70b7ad0dceeed8ae]::query::plumbing::try_execute_query::<rustc_query_impl[f5e7cf8f1e8ef554]::DynamicConfig<rustc_query_system[70b7ad0dceeed8ae]::query::caches::DefaultCache<rustc_middle[85294cbce27cd394]::ty::PseudoCanonicalInput<rustc_middle[85294cbce27cd394]::mir::interpret::GlobalId>, rustc_middle[85294cbce27cd394]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[f5e7cf8f1e8ef554]::plumbing::QueryCtxt, false>
  21:     0x7f3f87dac0c7 - rustc_query_impl[f5e7cf8f1e8ef554]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  22:     0x7f3f87dae6ac - rustc_const_eval[776b5f2f27615342]::const_eval::eval_queries::eval_to_const_value_raw_provider
  23:     0x7f3f87dae4c0 - rustc_query_impl[f5e7cf8f1e8ef554]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f5e7cf8f1e8ef554]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[85294cbce27cd394]::query::erase::Erased<[u8; 24usize]>>
  24:     0x7f3f87dadc06 - rustc_query_system[70b7ad0dceeed8ae]::query::plumbing::try_execute_query::<rustc_query_impl[f5e7cf8f1e8ef554]::DynamicConfig<rustc_query_system[70b7ad0dceeed8ae]::query::caches::DefaultCache<rustc_middle[85294cbce27cd394]::ty::PseudoCanonicalInput<rustc_middle[85294cbce27cd394]::mir::interpret::GlobalId>, rustc_middle[85294cbce27cd394]::query::erase::Erased<[u8; 24usize]>>, false, true, false>, rustc_query_impl[f5e7cf8f1e8ef554]::plumbing::QueryCtxt, false>
  25:     0x7f3f87dad77b - rustc_query_impl[f5e7cf8f1e8ef554]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7f3f88932cf4 - <rustc_middle[85294cbce27cd394]::ty::context::TyCtxt>::const_eval_resolve
  27:     0x7f3f8878f534 - <rustc_const_eval[776b5f2f27615342]::interpret::eval_context::InterpCx<rustc_const_eval[776b5f2f27615342]::const_eval::dummy_machine::DummyMachine>>::eval_mir_constant
  28:     0x7f3f887923ef - <rustc_mir_transform[c2bf3504227b03e4]::gvn::VnState>::eval_to_const::{closure#0}
  29:     0x7f3f8879d788 - <rustc_mir_transform[c2bf3504227b03e4]::gvn::VnState>::simplify_operand
  30:     0x7f3f887a579e - <rustc_mir_transform[c2bf3504227b03e4]::gvn::VnState as rustc_middle[85294cbce27cd394]::mir::visit::MutVisitor>::visit_assign
  31:     0x7f3f887a158c - <rustc_mir_transform[c2bf3504227b03e4]::gvn::GVN as rustc_mir_transform[c2bf3504227b03e4]::pass_manager::MirPass>::run_pass
  32:     0x7f3f87a0b8ef - rustc_mir_transform[c2bf3504227b03e4]::run_optimization_passes
  33:     0x7f3f8858008a - rustc_mir_transform[c2bf3504227b03e4]::optimized_mir
  34:     0x7f3f8857fcdd - rustc_query_impl[f5e7cf8f1e8ef554]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f5e7cf8f1e8ef554]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[85294cbce27cd394]::query::erase::Erased<[u8; 8usize]>>
  35:     0x7f3f87a1af3a - rustc_query_system[70b7ad0dceeed8ae]::query::plumbing::try_execute_query::<rustc_query_impl[f5e7cf8f1e8ef554]::DynamicConfig<rustc_query_system[70b7ad0dceeed8ae]::query::caches::DefIdCache<rustc_middle[85294cbce27cd394]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[f5e7cf8f1e8ef554]::plumbing::QueryCtxt, false>
  36:     0x7f3f87a1a3db - rustc_query_impl[f5e7cf8f1e8ef554]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f3f850aa2e8 - <rustc_middle[85294cbce27cd394]::ty::context::TyCtxt>::instance_mir
  38:     0x7f3f87bd41ba - rustc_interface[2ea1c423c56ccb20]::passes::analysis
  39:     0x7f3f87bd2d6d - rustc_query_impl[f5e7cf8f1e8ef554]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f5e7cf8f1e8ef554]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[85294cbce27cd394]::query::erase::Erased<[u8; 0usize]>>
  40:     0x7f3f88a92a48 - rustc_query_system[70b7ad0dceeed8ae]::query::plumbing::try_execute_query::<rustc_query_impl[f5e7cf8f1e8ef554]::DynamicConfig<rustc_query_system[70b7ad0dceeed8ae]::query::caches::SingleCache<rustc_middle[85294cbce27cd394]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f5e7cf8f1e8ef554]::plumbing::QueryCtxt, false>
  41:     0x7f3f88a92708 - rustc_query_impl[f5e7cf8f1e8ef554]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7f3f88e0ec4f - rustc_interface[2ea1c423c56ccb20]::passes::create_and_enter_global_ctxt::<core[a75fa55fde0009ec]::option::Option<rustc_interface[2ea1c423c56ccb20]::queries::Linker>, rustc_driver_impl[bee8db6accd21c89]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  43:     0x7f3f88bdd87e - rustc_interface[2ea1c423c56ccb20]::interface::run_compiler::<(), rustc_driver_impl[bee8db6accd21c89]::run_compiler::{closure#0}>::{closure#1}
  44:     0x7f3f88b62b38 - std[7e5923e4fb083e6e]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[2ea1c423c56ccb20]::util::run_in_thread_with_globals<rustc_interface[2ea1c423c56ccb20]::util::run_in_thread_pool_with_globals<rustc_interface[2ea1c423c56ccb20]::interface::run_compiler<(), rustc_driver_impl[bee8db6accd21c89]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  45:     0x7f3f88b6281c - <<std[7e5923e4fb083e6e]::thread::Builder>::spawn_unchecked_<rustc_interface[2ea1c423c56ccb20]::util::run_in_thread_with_globals<rustc_interface[2ea1c423c56ccb20]::util::run_in_thread_pool_with_globals<rustc_interface[2ea1c423c56ccb20]::interface::run_compiler<(), rustc_driver_impl[bee8db6accd21c89]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a75fa55fde0009ec]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:     0x7f3f88b685cd - std::sys::thread::unix::Thread::new::thread_start::h14ea1ba6e320367c
  47:     0x7f3f824969cb - <unknown>
  48:     0x7f3f8251aa0c - <unknown>
  49:                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: rustc 1.92.0-nightly (caccb4d03 2025-09-24) 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 [eval_to_allocation_raw] const-evaluating + checking `core::ptr::alignment::Alignment::of::{constant#0}`
#1 [eval_to_const_value_raw] simplifying constant for the type system `core::ptr::alignment::Alignment::of::{constant#0}`
#2 [optimized_mir] optimizing MIR for `main`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

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

Metadata

Metadata

Assignees

Labels

A-mir-opt-GVNArea: MIR opt Global Value Numbering (GVN)A-mir-opt-inliningArea: MIR inliningC-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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions