[ICE]: generic_const_args with async and closure
Open
Nobody has claimed this yet.
C-bug
F-generic_const_args
F-generic_const_items
F-min_generic_const_args
I-ICE
needs-triage
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
But by tweeking it a bit for fun and see how the compiler handle the error and show it to the user I tried this :
#![feature(min_generic_const_args, generic_const_items, generic_const_args)] #![allow(incomplete_features)] use core::marker::PhantomData; fn main() { embassy_futures::block_on(async { let mut rrb_big: RRBTree<[u8; usize::MAX]> = RRBTree { root: Node::Leaf(PhantomData), }; let _rrb_small = rrb_big.split_at().await; }); } struct RRBTree<T> { root: Node<T>, } #[allow(unused)] enum Node<T> { Leaf(PhantomData<T>), Inner(Vec<Node<T>>), } const N<T>: usize = 1 + size_of::<T>(); impl<T> RRBTree<T> { async fn split_at(&mut self) -> Self { let mut skips = heapless::Vec::<(usize, usize), { core::direct_const_arg!(N::<T>) }>::new(); let mut search = |_children: &Vec<Node<T>>| { let _ = skips.push((42, 42)); 42 }; let mut stack = heapless::Vec::<&Node<T>, { core::direct_const_arg!(N::<T>) }>::new(); let _ = stack.push(&self.root); while let Some(Node::Inner(inner)) = stack.last() { let child = &inner[search(inner)]; let _ = stack.push(child); } todo!() } }And got another ICE:
error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> /home/val/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:1463:25 | 1463 | const SIZE: usize = intrinsics::size_of::<Self>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `<[u8; usize::MAX] as std::mem::SizedTypeProperties>::SIZE` failed here error: internal compiler error: /rustc-dev/574ff7d98bd6d037e5236a8453029173b32631fd/compiler/rustc_middle/src/ty/layout.rs:1401:17: `fn_abi_of_instance(VecInner::<(usize, usize), usize, heapless::vec::storage::VecStorageInner<[MaybeUninit<(usize, usize)>; {const error}]>>::new, [])` failed: Layout(ReferencesError(ErrorGuaranteed(()))) --> /home/val/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/heapless-0.9.3/src/vec/mod.rs:320:5 | 320 | pub const fn new() -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ thread 'rustc' (128268) panicked at /rustc-dev/574ff7d98bd6d037e5236a8453029173b32631fd/compiler/rustc_middle/src/ty/layout.rs:1401:17: Box<dyn Any> stack backtrace: 0: 0x7f347ac40666 - <<std[e88b123c45551a4b]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[e3370a31d8f1c8c0]::fmt::Display>::fmt 1: 0x7f347b20984f - core[e3370a31d8f1c8c0]::fmt::write 2: 0x7f347ac5562c - <std[e88b123c45551a4b]::sys::stdio::unix::Stderr as core[e3370a31d8f1c8c0]::io::write::Write>::write_fmt 3: 0x7f347ac1316a - std[e88b123c45551a4b]::panicking::default_hook::{closure#0} 4: 0x7f347ac34c13 - std[e88b123c45551a4b]::panicking::default_hook 5: 0x7f3479961daf - std[e88b123c45551a4b]::panicking::update_hook::<alloc[d256a4456fbff4f9]::boxed::Box<rustc_driver_impl[c5d5f53170729273]::install_ice_hook::{closure#1}>>::{closure#0} 6: 0x7f347ac350b2 - std[e88b123c45551a4b]::panicking::panic_with_hook 7: 0x7f3479990ca4 - std[e88b123c45551a4b]::panicking::begin_panic::<rustc_errors[21843d9be35c0955]::ExplicitBug>::{closure#0} 8: 0x7f3479989a36 - std[e88b123c45551a4b]::sys::backtrace::__rust_end_short_backtrace::<std[e88b123c45551a4b]::panicking::begin_panic<rustc_errors[21843d9be35c0955]::ExplicitBug>::{closure#0}, !> 9: 0x7f347998786e - std[e88b123c45551a4b]::panicking::begin_panic::<rustc_errors[21843d9be35c0955]::ExplicitBug> 10: 0x7f3479996da7 - <rustc_errors[21843d9be35c0955]::diagnostic::Diag<rustc_errors[21843d9be35c0955]::diagnostic::BugAbort>>::emit 11: 0x7f3479feba6d - <rustc_errors[21843d9be35c0955]::DiagCtxtHandle>::span_bug::<rustc_span[caaced1e687b12a]::span_encoding::Span, alloc[d256a4456fbff4f9]::string::String> 12: 0x7f347a019c46 - rustc_middle[9640d5cb0e0c5ece]::util::bug::opt_span_bug_fmt::<rustc_span[caaced1e687b12a]::span_encoding::Span>::{closure#0} 13: 0x7f347a01a0a2 - rustc_middle[9640d5cb0e0c5ece]::ty::context::tls::with_opt::<rustc_middle[9640d5cb0e0c5ece]::util::bug::opt_span_bug_fmt<rustc_span[caaced1e687b12a]::span_encoding::Span>::{closure#0}, !>::{closure#0} 14: 0x7f347a005020 - rustc_middle[9640d5cb0e0c5ece]::ty::context::tls::with_context_opt::<rustc_middle[9640d5cb0e0c5ece]::ty::context::tls::with_opt<rustc_middle[9640d5cb0e0c5ece]::util::bug::opt_span_bug_fmt<rustc_span[caaced1e687b12a]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !> 15: 0x7f3477cf1128 - rustc_middle[9640d5cb0e0c5ece]::util::bug::span_bug_fmt::<rustc_span[caaced1e687b12a]::span_encoding::Span> 16: 0x7f347a04f814 - rustc_middle[9640d5cb0e0c5ece]::ty::layout::codegen_handle_fn_abi_err 17: 0x7f34771d08b7 - rustc_monomorphize[17050ecd102511f2]::mono_checks::check_mono_item 18: 0x7f347c17ee4e - rustc_query_impl[d7850a466dfc989b]::execution::try_execute_query::<rustc_middle[9640d5cb0e0c5ece]::query::caches::DefaultCache<rustc_middle[9640d5cb0e0c5ece]::ty::instance::Instance, rustc_middle[9640d5cb0e0c5ece]::query::erase::ErasedData<[u8; 0usize]>>, true> 19: 0x7f347c17e925 - rustc_query_impl[d7850a466dfc989b]::query_vtables::check_mono_item::execute_query_incr::__rust_end_short_backtrace 20: 0x7f347b64ca02 - rustc_monomorphize[17050ecd102511f2]::collector::items_of_instance 21: 0x7f347b64c811 - rustc_query_impl[d7850a466dfc989b]::query_vtables::items_of_instance::invoke_provider_fn::__rust_begin_short_backtrace 22: 0x7f347c172401 - rustc_query_impl[d7850a466dfc989b]::execution::try_execute_query::<rustc_middle[9640d5cb0e0c5ece]::query::caches::DefaultCache<(rustc_middle[9640d5cb0e0c5ece]::ty::instance::Instance, rustc_middle[9640d5cb0e0c5ece]::mono::CollectionMode), rustc_middle[9640d5cb0e0c5ece]::query::erase::ErasedData<[u8; 32usize]>>, true> 23: 0x7f347c171a21 - rustc_query_impl[d7850a466dfc989b]::query_vtables::items_of_instance::execute_query_incr::__rust_end_short_backtrace 24: 0x7f347c2d3aac - rustc_monomorphize[17050ecd102511f2]::collector::collect_items_rec 25: 0x7f347c2d8852 - rustc_monomorphize[17050ecd102511f2]::collector::collect_items_rec 26: 0x7f347c2d8852 - rustc_monomorphize[17050ecd102511f2]::collector::collect_items_rec 27: 0x7f347c2d8852 - rustc_monomorphize[17050ecd102511f2]::collector::collect_items_rec 28: 0x7f347c2d8852 - rustc_monomorphize[17050ecd102511f2]::collector::collect_items_rec 29: 0x7f347c2dad34 - rustc_monomorphize[17050ecd102511f2]::collector::collect_crate_mono_items::{closure#1}::{closure#0} 30: 0x7f347c2db663 - rustc_monomorphize[17050ecd102511f2]::partitioning::collect_and_partition_mono_items 31: 0x7f347c382b34 - rustc_query_impl[d7850a466dfc989b]::query_vtables::collect_and_partition_mono_items::invoke_provider_fn::__rust_begin_short_backtrace 32: 0x7f347cb28291 - rustc_query_impl[d7850a466dfc989b]::execution::try_execute_query::<rustc_middle[9640d5cb0e0c5ece]::query::caches::SingleCache<rustc_middle[9640d5cb0e0c5ece]::query::erase::ErasedData<[u8; 24usize]>>, true> 33: 0x7f347cb27cea - rustc_query_impl[d7850a466dfc989b]::query_vtables::collect_and_partition_mono_items::execute_query_incr::__rust_end_short_backtrace 34: 0x7f347c5be9f4 - rustc_codegen_ssa[55cb4f5a62726ace]::base::codegen_crate::<rustc_codegen_llvm[4d44b2886c8eee09]::LlvmCodegenBackend, rustc_codegen_llvm[4d44b2886c8eee09]::ModuleLlvm> 35: 0x7f347c5be7ae - <rustc_codegen_llvm[4d44b2886c8eee09]::LlvmCodegenBackend as rustc_codegen_ssa[55cb4f5a62726ace]::traits::backend::CodegenBackend>::codegen_crate 36: 0x7f347c4cb97e - <rustc_interface[fe52a0dd05c9819f]::queries::Linker>::codegen_and_build_linker 37: 0x7f347c4c1e09 - rustc_interface[fe52a0dd05c9819f]::interface::run_compiler::<(), rustc_driver_impl[c5d5f53170729273]::run_compiler::{closure#0}>::{closure#2} 38: 0x7f347c519c24 - std[e88b123c45551a4b]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[fe52a0dd05c9819f]::util::run_in_thread_with_globals<rustc_interface[fe52a0dd05c9819f]::util::run_in_thread_pool_with_globals<rustc_interface[fe52a0dd05c9819f]::interface::run_compiler<(), rustc_driver_impl[c5d5f53170729273]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()> 39: 0x7f347c5199cb - <std[e88b123c45551a4b]::thread::lifecycle::spawn_unchecked<rustc_interface[fe52a0dd05c9819f]::util::run_in_thread_with_globals<rustc_interface[fe52a0dd05c9819f]::util::run_in_thread_pool_with_globals<rustc_interface[fe52a0dd05c9819f]::interface::run_compiler<(), rustc_driver_impl[c5d5f53170729273]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[e3370a31d8f1c8c0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 40: 0x7f347c514d1b - <std[e88b123c45551a4b]::sys::thread::unix::Thread>::new::thread_start 41: 0x7f34754980a2 - <unknown> 42: 0x7f347552080c - <unknown> 43: 0x0 - <unknown>
Originally posted by @ValouBambou in #162773
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied async and closure example first, then inspect rustc_middle/src/ty/layout.rs around line 1401 and the fn_abi_of_instance failure shown in the report. Done means the invalid generic-const case produces a diagnostic without an internal compiler error or panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100