Closed as duplicate of#119729
Closed as duplicate of#119729
Description
Code
#![feature(generic_const_exprs)]
pub struct Foo<const C: usize>();
pub type FooAlias<T> = Foo<{std::mem::size_of::<T>()}>;
fn main() {
let foo: FooAlias<[()]> = todo!();
}
Meta
rustc --version --verbose
:
rustc 1.85.0-nightly (9e136a30a 2024-12-19)
binary: rustc
commit-hash: 9e136a30a965bf4e63f03095c57df7257bf96fd6
commit-date: 2024-12-19
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6
Error output
Errors
Compiling playground v0.0.1 (/playground)
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> src/main.rs:1:12
|
1 | #![feature(generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
= note: `#[warn(incomplete_features)]` on by default
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:309:5
|
309 | intrinsics::size_of::<T>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/operator.rs:522:21:
Box<dyn Any>
stack backtrace:
0: 0x74f50d58315a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6c37de0361fa7462
1: 0x74f50dc13cbc - core::fmt::write::hf77fe0583268bf67
2: 0x74f50eb42dd1 - std::io::Write::write_fmt::h3b0b8069e2435ed6
3: 0x74f50d582fb2 - std::sys::backtrace::BacktraceLock::print::hce84519ec0e7588e
4: 0x74f50d5854aa - std::panicking::default_hook::{{closure}}::h6e0433c33d1ed12b
5: 0x74f50d5852f3 - std::panicking::default_hook::h19d4e9e8d7fba9e2
6: 0x74f50c6f7768 - std[19739dcbdd52d894]::panicking::update_hook::<alloc[d24e20bba6540ab9]::boxed::Box<rustc_driver_impl[3177e72804664110]::install_ice_hook::{closure#0}>>::{closure#0}
7: 0x74f50d585c68 - std::panicking::rust_panic_with_hook::hd21771b96ea64164
8: 0x74f50c7322d1 - std[19739dcbdd52d894]::panicking::begin_panic::<rustc_errors[37abd7aad4ad5df0]::ExplicitBug>::{closure#0}
9: 0x74f50c7274b6 - std[19739dcbdd52d894]::sys::backtrace::__rust_end_short_backtrace::<std[19739dcbdd52d894]::panicking::begin_panic<rustc_errors[37abd7aad4ad5df0]::ExplicitBug>::{closure#0}, !>
10: 0x74f50c723ec9 - std[19739dcbdd52d894]::panicking::begin_panic::<rustc_errors[37abd7aad4ad5df0]::ExplicitBug>
11: 0x74f50c73c231 - <rustc_errors[37abd7aad4ad5df0]::diagnostic::BugAbort as rustc_errors[37abd7aad4ad5df0]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x74f50cc8b76c - <rustc_errors[37abd7aad4ad5df0]::DiagCtxtHandle>::span_bug::<rustc_span[2a960e124d280c12]::span_encoding::Span, alloc[d24e20bba6540ab9]::string::String>
13: 0x74f50cd10fe7 - rustc_middle[a45f2c6e02975f4b]::util::bug::opt_span_bug_fmt::<rustc_span[2a960e124d280c12]::span_encoding::Span>::{closure#0}
14: 0x74f50ccf67ba - rustc_middle[a45f2c6e02975f4b]::ty::context::tls::with_opt::<rustc_middle[a45f2c6e02975f4b]::util::bug::opt_span_bug_fmt<rustc_span[2a960e124d280c12]::span_encoding::Span>::{closure#0}, !>::{closure#0}
15: 0x74f50ccf664b - rustc_middle[a45f2c6e02975f4b]::ty::context::tls::with_context_opt::<rustc_middle[a45f2c6e02975f4b]::ty::context::tls::with_opt<rustc_middle[a45f2c6e02975f4b]::util::bug::opt_span_bug_fmt<rustc_span[2a960e124d280c12]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
16: 0x74f50b12b477 - rustc_middle[a45f2c6e02975f4b]::util::bug::span_bug_fmt::<rustc_span[2a960e124d280c12]::span_encoding::Span>
17: 0x74f50bbe6b17 - <rustc_const_eval[b8aee231d2d722f1]::interpret::eval_context::InterpCx<rustc_const_eval[b8aee231d2d722f1]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
18: 0x74f50bb5ec3d - rustc_const_eval[b8aee231d2d722f1]::const_eval::eval_queries::eval_to_allocation_raw_provider
19: 0x74f50e3e38fe - rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 24usize]>>
20: 0x74f50e3e3222 - rustc_query_system[1e197417f2882beb]::query::plumbing::try_execute_query::<rustc_query_impl[7b0f6e1e4ae2319d]::DynamicConfig<rustc_query_system[1e197417f2882beb]::query::caches::DefaultCache<rustc_middle[a45f2c6e02975f4b]::ty::PseudoCanonicalInput<rustc_middle[a45f2c6e02975f4b]::mir::interpret::GlobalId>, rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::QueryCtxt, false>
21: 0x74f50e3e2d7b - rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
22: 0x74f50e3be4c3 - rustc_const_eval[b8aee231d2d722f1]::const_eval::valtrees::eval_to_valtree
23: 0x74f50e3be294 - <rustc_const_eval[b8aee231d2d722f1]::provide::{closure#0} as core[57d68807791337c0]::ops::function::FnOnce<(rustc_middle[a45f2c6e02975f4b]::ty::context::TyCtxt, rustc_middle[a45f2c6e02975f4b]::ty::PseudoCanonicalInput<rustc_middle[a45f2c6e02975f4b]::mir::interpret::GlobalId>)>>::call_once
24: 0x74f50e3be23e - rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::eval_to_valtree::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 24usize]>>
25: 0x74f50e3be1f7 - <rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::eval_to_valtree::dynamic_query::{closure#2} as core[57d68807791337c0]::ops::function::FnOnce<(rustc_middle[a45f2c6e02975f4b]::ty::context::TyCtxt, rustc_middle[a45f2c6e02975f4b]::ty::PseudoCanonicalInput<rustc_middle[a45f2c6e02975f4b]::mir::interpret::GlobalId>)>>::call_once
26: 0x74f50e3e32f8 - rustc_query_system[1e197417f2882beb]::query::plumbing::try_execute_query::<rustc_query_impl[7b0f6e1e4ae2319d]::DynamicConfig<rustc_query_system[1e197417f2882beb]::query::caches::DefaultCache<rustc_middle[a45f2c6e02975f4b]::ty::PseudoCanonicalInput<rustc_middle[a45f2c6e02975f4b]::mir::interpret::GlobalId>, rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::QueryCtxt, false>
27: 0x74f50e62a793 - rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::eval_to_valtree::get_query_non_incr::__rust_end_short_backtrace
28: 0x74f50e62a08c - rustc_middle[a45f2c6e02975f4b]::query::plumbing::query_get_at::<rustc_query_system[1e197417f2882beb]::query::caches::DefaultCache<rustc_middle[a45f2c6e02975f4b]::ty::PseudoCanonicalInput<rustc_middle[a45f2c6e02975f4b]::mir::interpret::GlobalId>, rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 24usize]>>>
29: 0x74f50e6296a2 - <rustc_middle[a45f2c6e02975f4b]::ty::context::TyCtxt>::const_eval_global_id_for_typeck
30: 0x74f50e629539 - <rustc_middle[a45f2c6e02975f4b]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
31: 0x74f50e629277 - rustc_trait_selection[ec0dc258e7628c19]::traits::try_evaluate_const
32: 0x74f50f83061e - rustc_trait_selection[ec0dc258e7628c19]::traits::const_evaluatable::is_const_evaluatable.cold
33: 0x74f50e5b5b2d - <rustc_trait_selection[ec0dc258e7628c19]::traits::fulfill::FulfillProcessor as rustc_data_structures[192c71b2dc5f58e0]::obligation_forest::ObligationProcessor>::process_obligation
34: 0x74f50dc04d0b - <rustc_data_structures[192c71b2dc5f58e0]::obligation_forest::ObligationForest<rustc_trait_selection[ec0dc258e7628c19]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[ec0dc258e7628c19]::traits::fulfill::FulfillProcessor>
35: 0x74f50dd8d0a9 - <rustc_hir_typeck[773c2b5054f1554]::fn_ctxt::FnCtxt>::confirm_builtin_call
36: 0x74f50e6f57e3 - <rustc_hir_typeck[773c2b5054f1554]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args::{closure#0}
37: 0x74f50e6f1a9c - <rustc_hir_typeck[773c2b5054f1554]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
38: 0x74f50e6de574 - <rustc_hir_typeck[773c2b5054f1554]::fn_ctxt::FnCtxt>::check_decl
39: 0x74f50e6ee8dd - <rustc_hir_typeck[773c2b5054f1554]::fn_ctxt::FnCtxt>::check_expr_block
40: 0x74f50e6f5d78 - <rustc_hir_typeck[773c2b5054f1554]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args::{closure#0}
41: 0x74f50e6f1a9c - <rustc_hir_typeck[773c2b5054f1554]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
42: 0x74f50de3328a - rustc_hir_typeck[773c2b5054f1554]::check::check_fn
43: 0x74f50de3bab8 - rustc_hir_typeck[773c2b5054f1554]::typeck
44: 0x74f50de3a67b - rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 8usize]>>
45: 0x74f50de94b91 - rustc_query_system[1e197417f2882beb]::query::plumbing::try_execute_query::<rustc_query_impl[7b0f6e1e4ae2319d]::DynamicConfig<rustc_data_structures[192c71b2dc5f58e0]::vec_cache::VecCache<rustc_span[2a960e124d280c12]::def_id::LocalDefId, rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[1e197417f2882beb]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::QueryCtxt, false>
46: 0x74f50de93e4d - rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
47: 0x74f50de93aff - <rustc_middle[a45f2c6e02975f4b]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[f04f71a4747ef8cb]::check_crate::{closure#4}>::{closure#0}
48: 0x74f50de91b12 - rustc_hir_analysis[f04f71a4747ef8cb]::check_crate
49: 0x74f50e05a07c - rustc_interface[dfcc7ff3f03a05db]::passes::run_required_analyses
50: 0x74f50eb46c5e - rustc_interface[dfcc7ff3f03a05db]::passes::analysis
51: 0x74f50eb46c2f - rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 0usize]>>
52: 0x74f50eba9c55 - rustc_query_system[1e197417f2882beb]::query::plumbing::try_execute_query::<rustc_query_impl[7b0f6e1e4ae2319d]::DynamicConfig<rustc_query_system[1e197417f2882beb]::query::caches::SingleCache<rustc_middle[a45f2c6e02975f4b]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[7b0f6e1e4ae2319d]::plumbing::QueryCtxt, false>
53: 0x74f50eba998e - rustc_query_impl[7b0f6e1e4ae2319d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
54: 0x74f50eb9ed9e - rustc_interface[dfcc7ff3f03a05db]::passes::create_and_enter_global_ctxt::<core[57d68807791337c0]::option::Option<rustc_interface[dfcc7ff3f03a05db]::queries::Linker>, rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
55: 0x74f50ec10c43 - rustc_interface[dfcc7ff3f03a05db]::interface::run_compiler::<(), rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}>::{closure#1}
56: 0x74f50ebf7711 - std[19739dcbdd52d894]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_with_globals<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_pool_with_globals<rustc_interface[dfcc7ff3f03a05db]::interface::run_compiler<(), rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
57: 0x74f50ebf7ba6 - <<std[19739dcbdd52d894]::thread::Builder>::spawn_unchecked_<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_with_globals<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_pool_with_globals<rustc_interface[dfcc7ff3f03a05db]::interface::run_compiler<(), rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[57d68807791337c0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
58: 0x74f50ebf916f - std::sys::pal::unix::thread::Thread::new::thread_start::h71fe57097907b3f8
59: 0x74f5102cba94 - <unknown>
60: 0x74f510358a34 - clone
61: 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 `/playground/rustc-ice-2024-12-20T04_58_40-38.txt` to your bug report
note: compiler flags: --crate-type bin -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 `FooAlias::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
end of query stack
warning: `playground` (bin "playground") generated 1 warning
error: could not compile `playground` (bin "playground"); 1 warning emitted
Backtrace
Compiling playground v0.0.1 (/playground)
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> src/main.rs:1:12
|
1 | #![feature(generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
= note: `#[warn(incomplete_features)]` on by default
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:309:5
|
309 | intrinsics::size_of::<T>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
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::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::mir::interpret::GlobalId>, rustc_middle::query::erase::Erased<[u8; 24]>>>
12: <rustc_middle::ty::context::TyCtxt>::const_eval_global_id_for_typeck
13: <rustc_middle::ty::context::TyCtxt>::const_eval_resolve_for_typeck
14: rustc_trait_selection::traits::try_evaluate_const
15: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable.cold
16: <rustc_trait_selection::traits::fulfill::FulfillProcessor as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
17: <rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection::traits::fulfill::FulfillProcessor>
18: <rustc_hir_typeck::fn_ctxt::FnCtxt>::confirm_builtin_call
19: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args::{closure#0}
20: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
21: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_decl
22: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
23: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args::{closure#0}
24: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
25: rustc_hir_typeck::check::check_fn
26: rustc_hir_typeck::typeck
[... omitted 1 frame ...]
27: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_hir_analysis::check_crate::{closure#4}>::{closure#0}
28: rustc_hir_analysis::check_crate
29: rustc_interface::passes::run_required_analyses
30: rustc_interface::passes::analysis
[... omitted 1 frame ...]
31: 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}
32: 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-2024-12-20T04_59_12-47.txt` to your bug report
note: compiler flags: --crate-type bin -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 `FooAlias::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
#2 [typeck] type-checking `main`
#3 [analysis] running analysis passes on this crate
end of query stack
warning: `playground` (bin "playground") generated 1 warning
error: could not compile `playground` (bin "playground"); 1 warning emitted
@rustbot labels +A-const-generics +F-generic_const_exprs +requires-nightly +requires-incomplete-features
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Category: This is a bug.`#![feature(generic_const_exprs)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires the use of incomplete features.This issue requires a nightly compiler in some way.