rust-lang / rust-lang/rust

[ICE]: generic_const_exprs with async and closure

Open
#162,773 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-generic_const_exprs I-ICE needs-triage T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

use core::marker::PhantomData;

fn main() {
    embassy_futures::block_on(async {
        let mut rrb_big: RRBTree<u64> = 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>>),
}

impl<T> RRBTree<T>
where
    [(); size_of::<T>()]:,
{
    async fn split_at(&mut self) -> Self {
        let mut skips = heapless::Vec::<(usize, usize), { size_of::<T>() }>::new();
        let mut search = |_children: &Vec<Node<T>>| {
            let _ = skips.push((42, 42));
            42
        };
        let mut stack = heapless::Vec::<&Node<T>, { size_of::<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!()
    }
}
Meta

rustc --version --verbose:

rustc 1.100.0-nightly (4b6d04e70 2026-09-13)
binary: rustc
commit-hash: 4b6d04e706108ccfeafe2547fbe857dfe8972bad
commit-date: 2026-09-13
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1
Error output
warning: `feature(generic_const_exprs)` is not supported with the next-generation trait solver
 --> src/main.rs:2:12
  |
2 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: `-Znext-solver=globally` is currently enabled by default for testing
  = note: reverted the setting to `-Znext-solver=coherence` for this crate
  = note: the currently stable trait solver will be used for this crate
  = note: see issues #160895 <https://github.com/rust-lang/rust/issues/160895> for more information


thread 'rustc' (352168) panicked at /rustc-dev/4b6d04e706108ccfeafe2547fbe857dfe8972bad/compiler/rustc_type_ir/src/binder.rs:790:9:
type parameter `/#4` (/#4/4) out of range when instantiating, args=[u64, i16, Binder { value: extern "RustCall" fn((&'^0 std::vec::Vec<Node<u64>, std::alloc::Global>,)) -> usize, bound_vars: [Region(BrAnon)] }, (&'{erased} mut heapless::vec::VecInner<(usize, usize), usize, heapless::vec::storage::VecStorageInner<[std::mem::MaybeUninit<(usize, usize)>; 8_usize]>>,)]
stack backtrace:
   0:     0x7f126ee54e46 - <<std[552422bcccb5c833]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[1b0f708be8c133d1]::fmt::Display>::fmt
   1:     0x7f126f40984f - core[1b0f708be8c133d1]::fmt::write
   2:     0x7f126ee69e1c - <std[552422bcccb5c833]::sys::stdio::unix::Stderr as core[1b0f708be8c133d1]::io::write::Write>::write_fmt
   3:     0x7f126ee27b1a - std[552422bcccb5c833]::panicking::default_hook::{closure#0}
   4:     0x7f126ee495a3 - std[552422bcccb5c833]::panicking::default_hook
   5:     0x7f126db7631f - std[552422bcccb5c833]::panicking::update_hook::<alloc[8d16d54ddffdc8a3]::boxed::Box<rustc_driver_impl[b59e3ffdd9ae4470]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f126ee49a42 - std[552422bcccb5c833]::panicking::panic_with_hook
   7:     0x7f126ee27bd2 - std[552422bcccb5c833]::panicking::panic_handler::{closure#0}
   8:     0x7f126ee1fc59 - std[552422bcccb5c833]::sys::backtrace::__rust_end_short_backtrace::<std[552422bcccb5c833]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f126ee297ad - __rustc[20add320cf717b90]::rust_begin_unwind
  10:     0x7f126b90c3dc - core[1b0f708be8c133d1]::panicking::panic_fmt
  11:     0x7f126e25cfd5 - <rustc_type_ir[577d48379558a620]::binder::ArgFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt>>::type_param_out_of_range
  12:     0x7f126f7e38b0 - <rustc_type_ir[577d48379558a620]::binder::ArgFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt> as rustc_type_ir[577d48379558a620]::fold::TypeFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt>>::fold_ty
  13:     0x7f126f7e9b40 - <&rustc_middle[dad200052675e81d]::ty::list::RawList<(), rustc_middle[dad200052675e81d]::ty::generic_args::GenericArg> as rustc_type_ir[577d48379558a620]::fold::TypeFoldable<rustc_middle[dad200052675e81d]::ty::context::TyCtxt>>::fold_with::<rustc_type_ir[577d48379558a620]::binder::ArgFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt>>
  14:     0x7f126f7de3ac - <rustc_type_ir[577d48379558a620]::binder::ArgFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt> as rustc_type_ir[577d48379558a620]::fold::TypeFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt>>::fold_const
  15:     0x7f126f7e17b9 - <rustc_type_ir[577d48379558a620]::binder::ArgFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt> as rustc_type_ir[577d48379558a620]::fold::TypeFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt>>::fold_ty
  16:     0x7f126f7ded03 - <rustc_type_ir[577d48379558a620]::binder::ArgFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt> as rustc_type_ir[577d48379558a620]::fold::TypeFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt>>::fold_ty
  17:     0x7f126f7df77e - <rustc_type_ir[577d48379558a620]::binder::ArgFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt> as rustc_type_ir[577d48379558a620]::fold::TypeFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt>>::fold_ty
  18:     0x7f126f7deae8 - <rustc_type_ir[577d48379558a620]::binder::ArgFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt> as rustc_type_ir[577d48379558a620]::fold::TypeFolder<rustc_middle[dad200052675e81d]::ty::context::TyCtxt>>::fold_ty
  19:     0x7f126f7ed91c - <rustc_middle[dad200052675e81d]::mir::Body as rustc_type_ir[577d48379558a620]::visit::TypeVisitable<rustc_middle[dad200052675e81d]::ty::context::TyCtxt>>::visit_with::<rustc_monomorphize[b66db2de85bc634c]::collector::check_normalization_error::NormalizationChecker>
  20:     0x7f126f7d3fcb - rustc_monomorphize[b66db2de85bc634c]::collector::items_of_instance
  21:     0x7f126f7d3f11 - rustc_query_impl[be4bf2c2bc2163e7]::query_vtables::items_of_instance::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7f1270323ec1 - rustc_query_impl[be4bf2c2bc2163e7]::execution::try_execute_query::<rustc_middle[dad200052675e81d]::query::caches::DefaultCache<(rustc_middle[dad200052675e81d]::ty::instance::Instance, rustc_middle[dad200052675e81d]::mono::CollectionMode), rustc_middle[dad200052675e81d]::query::erase::ErasedData<[u8; 32usize]>>, true>
  23:     0x7f12703234e1 - rustc_query_impl[be4bf2c2bc2163e7]::query_vtables::items_of_instance::execute_query_incr::__rust_end_short_backtrace
  24:     0x7f1270495d2c - rustc_monomorphize[b66db2de85bc634c]::collector::collect_items_rec
  25:     0x7f127049aacf - rustc_monomorphize[b66db2de85bc634c]::collector::collect_items_rec
  26:     0x7f127049aacf - rustc_monomorphize[b66db2de85bc634c]::collector::collect_items_rec
  27:     0x7f127049aacf - rustc_monomorphize[b66db2de85bc634c]::collector::collect_items_rec
  28:     0x7f127049aacf - rustc_monomorphize[b66db2de85bc634c]::collector::collect_items_rec
  29:     0x7f127049cfb4 - rustc_monomorphize[b66db2de85bc634c]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  30:     0x7f127049d8e3 - rustc_monomorphize[b66db2de85bc634c]::partitioning::collect_and_partition_mono_items
  31:     0x7f127048cf16 - rustc_query_impl[be4bf2c2bc2163e7]::query_vtables::collect_and_partition_mono_items::invoke_provider_fn::__rust_begin_short_backtrace
  32:     0x7f1270c50c51 - rustc_query_impl[be4bf2c2bc2163e7]::execution::try_execute_query::<rustc_middle[dad200052675e81d]::query::caches::SingleCache<rustc_middle[dad200052675e81d]::query::erase::ErasedData<[u8; 24usize]>>, true>
  33:     0x7f1270c506aa - rustc_query_impl[be4bf2c2bc2163e7]::query_vtables::collect_and_partition_mono_items::execute_query_incr::__rust_end_short_backtrace
  34:     0x7f12707da932 - rustc_codegen_ssa[ef473a769a018e8c]::base::codegen_crate::<rustc_codegen_llvm[b36ae924e28f7bfb]::LlvmCodegenBackend, rustc_codegen_llvm[b36ae924e28f7bfb]::ModuleLlvm>
  35:     0x7f12707da6ee - <rustc_codegen_llvm[b36ae924e28f7bfb]::LlvmCodegenBackend as rustc_codegen_ssa[ef473a769a018e8c]::traits::backend::CodegenBackend>::codegen_crate
  36:     0x7f1270761abe - <rustc_interface[b88f436b63b54bbb]::queries::Linker>::codegen_and_build_linker
  37:     0x7f1270759089 - rustc_interface[b88f436b63b54bbb]::interface::run_compiler::<(), rustc_driver_impl[b59e3ffdd9ae4470]::run_compiler::{closure#0}>::{closure#2}
  38:     0x7f12707b6724 - std[552422bcccb5c833]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[b88f436b63b54bbb]::util::run_in_thread_with_globals<rustc_interface[b88f436b63b54bbb]::util::run_in_thread_pool_with_globals<rustc_interface[b88f436b63b54bbb]::interface::run_compiler<(), rustc_driver_impl[b59e3ffdd9ae4470]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  39:     0x7f12707b64cb - <std[552422bcccb5c833]::thread::lifecycle::spawn_unchecked<rustc_interface[b88f436b63b54bbb]::util::run_in_thread_with_globals<rustc_interface[b88f436b63b54bbb]::util::run_in_thread_pool_with_globals<rustc_interface[b88f436b63b54bbb]::interface::run_compiler<(), rustc_driver_impl[b59e3ffdd9ae4470]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[1b0f708be8c133d1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7f12707bf8db - <std[552422bcccb5c833]::sys::thread::unix::Thread>::new::thread_start
  41:     0x7f12696980a2 - <unknown>
  42:     0x7f126972080c - <unknown>
  43:                0x0 - <unknown>

error: the compiler unexpectedly panicked. This is a bug

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 `/home/val/Coding/These/swap-cache/minimal-bug-repro/rustc-ice-2026-09-14T16_57_44-352166.txt` to your bug report

note: rustc 1.100.0-nightly (4b6d04e70 2026-09-13) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [items_of_instance] collecting items used by `<impl at src/main.rs:25:1: 27:27>::split_at::{closure#0}::{closure#0}`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
warning: `minimal-bug-repro` (bin "minimal-bug-repro") generated 1 warning
error: could not compile `minimal-bug-repro` (bin "minimal-bug-repro"); 1 warning emitted

Caused by:
  process didn't exit successfully: `/home/val/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name minimal_bug_repro --edition=2024 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat,unused-externs-silent --diagnostic-width=148 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=24d4a92d61be5191 --out-dir /home/val/Coding/These/swap-cache/minimal-bug-repro/target/debug/build/minimal-bug-repro/71d5c43cd887a385/out -C incremental=/home/val/Coding/These/swap-cache/minimal-bug-repro/target/debug/incremental -L dependency=/home/val/Coding/These/swap-cache/minimal-bug-repro/target/debug/build/byteorder/7b2246451a749927/out -L dependency=/home/val/Coding/These/swap-cache/minimal-bug-repro/target/debug/build/hash32/f249c69d723a1c9e/out -L dependency=/home/val/Coding/These/swap-cache/minimal-bug-repro/target/debug/build/stable_deref_trait/d13fd163da2fc199/out --extern embassy_futures=/home/val/Coding/These/swap-cache/minimal-bug-repro/target/debug/build/embassy-futures/3dcc6f905aaa095b/out/libembassy_futures-3dcc6f905aaa095b.rlib --extern embassy_futures=/home/val/Coding/These/swap-cache/minimal-bug-repro/target/debug/build/embassy-futures/3dcc6f905aaa095b/out/libembassy_futures-3dcc6f905aaa095b.rmeta --extern heapless=/home/val/Coding/These/swap-cache/minimal-bug-repro/target/debug/build/heapless/59f5e7b6bdbb98f9/out/libheapless-59f5e7b6bdbb98f9.rlib --extern heapless=/home/val/Coding/These/swap-cache/minimal-bug-repro/target/debug/build/heapless/59f5e7b6bdbb98f9/out/libheapless-59f5e7b6bdbb98f9.rmeta --force-warn=unused_crate_dependencies` (exit status: 101)
Backtrace

stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: <rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>::type_param_out_of_range
   3: <rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
   4: <&rustc_middle::ty::list::RawList<(), rustc_middle::ty::generic_args::GenericArg> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
   5: <rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_const
   6: <rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
   7: <rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
   8: <rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
   9: <rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt> as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
  10: <rustc_middle::mir::Body as rustc_type_ir::visit::TypeVisitable<rustc_middle::ty::context::TyCtxt>>::visit_with::<rustc_monomorphize::collector::check_normalization_error::NormalizationChecker>
  11: rustc_monomorphize::collector::items_of_instance
      [... omitted 1 frame ...]
  12: rustc_monomorphize::collector::collect_items_rec
  13: rustc_monomorphize::collector::collect_items_rec
  14: rustc_monomorphize::collector::collect_items_rec
  15: rustc_monomorphize::collector::collect_items_rec
  16: rustc_monomorphize::collector::collect_items_rec
  17: rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  18: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 1 frame ...]
  19: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend, rustc_codegen_llvm::ModuleLlvm>
  20: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  21: <rustc_interface::queries::Linker>::codegen_and_build_linker
  22: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#2}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by building the reproducer in src/main.rs and confirm the ICE, then trace the reported panic at rustc_type_ir/src/binder.rs:790 and the items_of_instance query in rustc_monomorphize. Compare the generic_const_exprs, async, and closure portions of the example while narrowing the failing compiler path. Done means this case produces a diagnostic or compiles without an internal compiler error.

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
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.