Open
Description
Code
fn foo()
where
for<'a> str: Sized,
{
let _ = [0; size_of::<str>()];
}
See also #141734
Meta
Reproducible on the playground with rust 1.87.0
and rust 1.89.0-nightly (2025-05-28 6f69710780d579b180ab)
.
Error output
error: internal compiler error: compiler/rustc_const_eval/src/interpret/operator.rs:522:21: unsized type for `NullaryOp::SizeOf`
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:307:5
|
307 | intrinsics::size_of::<T>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Backtrace
thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/operator.rs:522:21:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
2: <rustc_errors::DiagCtxtHandle>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
7: <rustc_const_eval::interpret::eval_context::InterpCx<rustc_const_eval::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
8: rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider
[... omitted 1 frame ...]
9: rustc_const_eval::const_eval::valtrees::eval_to_valtree
10: <rustc_const_eval::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>)>>::call_once
[... omitted 2 frames ...]
11: <rustc_middle::ty::context::TyCtxt>::const_eval_global_id_for_typeck
12: <rustc_middle::ty::context::TyCtxt>::const_eval_resolve_for_typeck
13: rustc_trait_selection::traits::try_evaluate_const
14: <rustc_trait_selection::traits::normalize::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_const
15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::normalize::<rustc_middle::ty::consts::Const>
16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
17: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_decl
18: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
19: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
20: rustc_hir_typeck::check::check_fn
21: rustc_hir_typeck::typeck_with_inspect::{closure#0}
[... omitted 1 frame ...]
22: rustc_hir_analysis::check_crate
23: rustc_interface::passes::run_required_analyses
24: rustc_interface::passes::analysis
[... omitted 1 frame ...]
25: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
26: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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 `/playground/rustc-ice-2025-05-29T12_36_37-80.txt` to your bug report
note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `foo::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
#2 [typeck] type-checking `foo`
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground` (lib)