Skip to content

[ICE]: Cross-Crate Generic Const Exprs with [(); N+1]: Copy #156346

Description

@JulianKnodt

I found that when trying the solution in the most recent comment of #145069 which suggests to use a bound of [(); N+1]: Copy across crate boundaries, this causes an ICE.

Code

I currently don't have a minimal repro. I suspect this error was probably already filed elsewhere, but if it is unseen I can try to find a minimal repro.

Meta

rustc --version --verbose:

rustc 1.97.0-nightly (f964de49b 2026-05-07)
binary: rustc
commit-hash: f964de49bcb561e5c6c725bb37201e11d852daf0
commit-date: 2026-05-07
host: aarch64-apple-darwin
release: 1.97.0-nightly
LLVM version: 22.1.4

Error output

warning: unused variable: `up`
... omitted ...

warning: `recursive-bilateral` (lib) generated 1 warning (run `cargo fix --lib -p recursive-bilateral` to apply 1 suggestion)
   Compiling recursive-bilateral v0.1.0 (/Users/julianknodt/Desktop/programming/rust/recursive_bilateral)
warning: `recursive-bilateral` (lib test) generated 1 warning (1 duplicate)

thread 'rustc' (1059268) panicked at /rustc-dev/f964de49bcb561e5c6c725bb37201e11d852daf0/compiler/rustc_type_ir/src/binder.rs:797:9:
type parameter `<closure_kind>/#1` (<closure_kind>/#1/1) out of range when instantiating, args=[3_usize]
stack backtrace:
   0:        0x111ecfadc - <<std[3313fec6b0b89a53]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[e30b13ff8cb2c07d]::fmt::Display>::fmt
   1:        0x10ef4abf4 - core[e30b13ff8cb2c07d]::fmt::write
   2:        0x111ee6ed8 - <std[3313fec6b0b89a53]::sys::stdio::unix::Stderr as std[3313fec6b0b89a53]::io::Write>::write_fmt
   3:        0x111ea62e8 - std[3313fec6b0b89a53]::panicking::default_hook::{closure#0}
   4:        0x111ec21e4 - std[3313fec6b0b89a53]::panicking::default_hook
   5:        0x10fbb2de0 - std[3313fec6b0b89a53]::panicking::update_hook::<alloc[6eb849c1d53df07f]::boxed::Box<rustc_driver_impl[ad7943e0a3363b68]::install_ice_hook::{closure#1}>>::{closure#0}
   6:        0x111ec2548 - std[3313fec6b0b89a53]::panicking::panic_with_hook
   7:        0x111ea6378 - std[3313fec6b0b89a53]::panicking::panic_handler::{closure#0}
   8:        0x111e9ad54 - std[3313fec6b0b89a53]::sys::backtrace::__rust_end_short_backtrace::<std[3313fec6b0b89a53]::panicking::panic_handler::{closure#0}, !>
   9:        0x111ea794c - __rustc[a4d1e851ebf29d66]::rust_begin_unwind
  10:        0x114ee3b4c - core[e30b13ff8cb2c07d]::panicking::panic_fmt
  11:        0x114fbc8dc - <rustc_type_ir[6ac2f5d8e470535d]::binder::ArgFolder<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>::type_param_out_of_range
  12:        0x110e01f30 - <rustc_type_ir[6ac2f5d8e470535d]::binder::ArgFolder<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt> as rustc_type_ir[6ac2f5d8e470535d]::fold::TypeFolder<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>::fold_ty
  13:        0x110dd5830 - <&rustc_middle[3bc53d00b1fe3775]::ty::list::RawList<(), rustc_middle[3bc53d00b1fe3775]::ty::generic_args::GenericArg> as rustc_type_ir[6ac2f5d8e470535d]::fold::TypeFoldable<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>::fold_with::<rustc_type_ir[6ac2f5d8e470535d]::binder::ArgFolder<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>
  14:        0x110dd4568 - <rustc_middle[3bc53d00b1fe3775]::ty::consts::Const as rustc_type_ir[6ac2f5d8e470535d]::fold::TypeSuperFoldable<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir[6ac2f5d8e470535d]::binder::ArgFolder<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>
  15:        0x110dd7e68 - <rustc_middle[3bc53d00b1fe3775]::ty::Ty as rustc_type_ir[6ac2f5d8e470535d]::fold::TypeSuperFoldable<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir[6ac2f5d8e470535d]::binder::ArgFolder<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>
  16:        0x110dd7e78 - <rustc_middle[3bc53d00b1fe3775]::ty::Ty as rustc_type_ir[6ac2f5d8e470535d]::fold::TypeSuperFoldable<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir[6ac2f5d8e470535d]::binder::ArgFolder<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>
  17:        0x110dd7e38 - <rustc_middle[3bc53d00b1fe3775]::ty::Ty as rustc_type_ir[6ac2f5d8e470535d]::fold::TypeSuperFoldable<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir[6ac2f5d8e470535d]::binder::ArgFolder<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>
  18:        0x110dd756c - <&rustc_middle[3bc53d00b1fe3775]::ty::list::RawList<(), rustc_middle[3bc53d00b1fe3775]::ty::Ty> as rustc_type_ir[6ac2f5d8e470535d]::fold::TypeFoldable<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>::fold_with::<rustc_type_ir[6ac2f5d8e470535d]::binder::ArgFolder<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>
  19:        0x110dd7d9c - <rustc_middle[3bc53d00b1fe3775]::ty::Ty as rustc_type_ir[6ac2f5d8e470535d]::fold::TypeSuperFoldable<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir[6ac2f5d8e470535d]::binder::ArgFolder<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>
  20:        0x110df749c - <rustc_monomorphize[f480d0b6d869026f]::collector::check_normalization_error::NormalizationChecker as rustc_type_ir[6ac2f5d8e470535d]::visit::TypeVisitor<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>::visit_ty
  21:        0x110dce740 - <rustc_middle[3bc53d00b1fe3775]::mir::Body as rustc_type_ir[6ac2f5d8e470535d]::visit::TypeVisitable<rustc_middle[3bc53d00b1fe3775]::ty::context::TyCtxt>>::visit_with::<rustc_monomorphize[f480d0b6d869026f]::collector::check_normalization_error::NormalizationChecker>
  22:        0x110df0b90 - rustc_monomorphize[f480d0b6d869026f]::collector::items_of_instance
  23:        0x111425804 - rustc_query_impl[fc06325ca43fd938]::query_impl::items_of_instance::invoke_provider_fn::__rust_begin_short_backtrace
  24:        0x1112f94d0 - rustc_query_impl[fc06325ca43fd938]::execution::try_execute_query::<rustc_middle[3bc53d00b1fe3775]::query::caches::DefaultCache<(rustc_middle[3bc53d00b1fe3775]::ty::instance::Instance, rustc_middle[3bc53d00b1fe3775]::mono::CollectionMode), rustc_middle[3bc53d00b1fe3775]::query::erase::ErasedData<[u8; 32usize]>>, true>
  25:        0x11142576c - rustc_query_impl[fc06325ca43fd938]::query_impl::items_of_instance::execute_query_incr::__rust_end_short_backtrace
  26:        0x110ddba90 - rustc_monomorphize[f480d0b6d869026f]::collector::collect_items_rec::{closure#0}
  27:        0x110def25c - rustc_monomorphize[f480d0b6d869026f]::collector::collect_items_rec
  28:        0x110df0328 - rustc_monomorphize[f480d0b6d869026f]::collector::collect_items_rec
  29:        0x110df0328 - rustc_monomorphize[f480d0b6d869026f]::collector::collect_items_rec
  30:        0x110df0328 - rustc_monomorphize[f480d0b6d869026f]::collector::collect_items_rec
  31:        0x110df0328 - rustc_monomorphize[f480d0b6d869026f]::collector::collect_items_rec
  32:        0x110ddb730 - rustc_monomorphize[f480d0b6d869026f]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  33:        0x110de4908 - rustc_monomorphize[f480d0b6d869026f]::partitioning::collect_and_partition_mono_items
  34:        0x111444b00 - rustc_query_impl[fc06325ca43fd938]::query_impl::collect_and_partition_mono_items::invoke_provider_fn::__rust_begin_short_backtrace
  35:        0x111278080 - rustc_query_impl[fc06325ca43fd938]::execution::try_execute_query::<rustc_middle[3bc53d00b1fe3775]::query::caches::SingleCache<rustc_middle[3bc53d00b1fe3775]::query::erase::ErasedData<[u8; 24usize]>>, true>
  36:        0x111444a64 - rustc_query_impl[fc06325ca43fd938]::query_impl::collect_and_partition_mono_items::execute_query_incr::__rust_end_short_backtrace
  37:        0x10f75aea8 - rustc_codegen_ssa[6cfb6b903549e167]::base::codegen_crate::<rustc_codegen_llvm[23214116cfa31e70]::LlvmCodegenBackend>
  38:        0x10f8558e4 - <rustc_codegen_llvm[23214116cfa31e70]::LlvmCodegenBackend as rustc_codegen_ssa[6cfb6b903549e167]::traits::backend::CodegenBackend>::codegen_crate
  39:        0x110529170 - <rustc_interface[a5048dccc2f8d9f4]::queries::Linker>::codegen_and_build_linker
  40:        0x10fb6d024 - rustc_interface[a5048dccc2f8d9f4]::passes::create_and_enter_global_ctxt::<core[e30b13ff8cb2c07d]::option::Option<rustc_interface[a5048dccc2f8d9f4]::queries::Linker>, rustc_driver_impl[ad7943e0a3363b68]::run_compiler::{closure#0}::{closure#2}>
  41:        0x10fbb627c - rustc_interface[a5048dccc2f8d9f4]::interface::run_compiler::<(), rustc_driver_impl[ad7943e0a3363b68]::run_compiler::{closure#0}>::{closure#1}
  42:        0x10fbaaa78 - std[3313fec6b0b89a53]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a5048dccc2f8d9f4]::util::run_in_thread_with_globals<rustc_interface[a5048dccc2f8d9f4]::util::run_in_thread_pool_with_globals<rustc_interface[a5048dccc2f8d9f4]::interface::run_compiler<(), rustc_driver_impl[ad7943e0a3363b68]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  43:        0x10fbbbed0 - <std[3313fec6b0b89a53]::thread::lifecycle::spawn_unchecked<rustc_interface[a5048dccc2f8d9f4]::util::run_in_thread_with_globals<rustc_interface[a5048dccc2f8d9f4]::util::run_in_thread_pool_with_globals<rustc_interface[a5048dccc2f8d9f4]::interface::run_compiler<(), rustc_driver_impl[ad7943e0a3363b68]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[e30b13ff8cb2c07d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:        0x111eccd64 - <std[3313fec6b0b89a53]::sys::thread::unix::Thread>::new::thread_start
  45:        0x19ef81f94 - __pthread_joiner_wake

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 `/Users/julianknodt/Desktop/programming/rust/recursive_bilateral/rustc-ice-2026-05-08T23_38_03-26136.txt` to your bug report

note: rustc 1.97.0-nightly (f964de49b 2026-05-07) running on aarch64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -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 `recursive_bilateral::bilateral2::bilateral_filter::<ValTree(Leaf(0x0000000000000003): usize)>`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `recursive-bilateral` (test "basic")

Caused by:
  process didn't exit successfully: `/Users/julianknodt/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/rustc --crate-name basic --edition=2024 tests/basic.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --test --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=6ebc975299290e83 -C extra-filename=-9553790ec6c49fa3 --out-dir /Users/julianknodt/Desktop/programming/rust/recursive_bilateral/target/debug/deps -C incremental=/Users/julianknodt/Desktop/programming/rust/recursive_bilateral/target/debug/incremental -L dependency=/Users/julianknodt/Desktop/programming/rust/recursive_bilateral/target/debug/deps --extern image=/Users/julianknodt/Desktop/programming/rust/recursive_bilateral/target/debug/deps/libimage-dcd1050dd188210a.rlib --extern recursive_bilateral=/Users/julianknodt/Desktop/programming/rust/recursive_bilateral/target/debug/deps/librecursive_bilateral-38fecbbfe698b72f.rlib` (exit status: 101)
Backtrace

warning: unused variable: `up`
... omitted ...

warning: `recursive-bilateral` (lib) generated 1 warning (run `cargo fix --lib -p recursive-bilateral` to apply 1 suggestion)
   Compiling recursive-bilateral v0.1.0 (/Users/julianknodt/Desktop/programming/rust/recursive_bilateral)
warning: `recursive-bilateral` (lib test) generated 1 warning (1 duplicate)

thread 'rustc' (1060420) panicked at /rustc-dev/f964de49bcb561e5c6c725bb37201e11d852daf0/compiler/rustc_type_ir/src/binder.rs:797:9:
type parameter `<closure_kind>/#1` (<closure_kind>/#1/1) out of range when instantiating, args=[3_usize]
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_middle::ty::consts::Const as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
   6: <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
   7: <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
   8: <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
   9: <&rustc_middle::ty::list::RawList<(), rustc_middle::ty::Ty> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
  10: <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::super_fold_with::<rustc_type_ir::binder::ArgFolder<rustc_middle::ty::context::TyCtxt>>
  11: <rustc_monomorphize::collector::check_normalization_error::NormalizationChecker as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  12: <rustc_middle::mir::Body as rustc_type_ir::visit::TypeVisitable<rustc_middle::ty::context::TyCtxt>>::visit_with::<rustc_monomorphize::collector::check_normalization_error::NormalizationChecker>
  13: rustc_monomorphize::collector::items_of_instance
      [... omitted 1 frame ...]
  14: rustc_monomorphize::collector::collect_items_rec::{closure#0}
  15: rustc_monomorphize::collector::collect_items_rec
  16: rustc_monomorphize::collector::collect_items_rec
  17: rustc_monomorphize::collector::collect_items_rec
  18: rustc_monomorphize::collector::collect_items_rec
  19: rustc_monomorphize::collector::collect_items_rec
  20: rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  21: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 1 frame ...]
  22: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  23: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  24: <rustc_interface::queries::Linker>::codegen_and_build_linker
  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}>
  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.

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 `/Users/julianknodt/Desktop/programming/rust/recursive_bilateral/rustc-ice-2026-05-08T23_39_13-26193.txt` to your bug report

note: rustc 1.97.0-nightly (f964de49b 2026-05-07) running on aarch64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -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 `recursive_bilateral::bilateral2::bilateral_filter::<ValTree(Leaf(0x0000000000000003): usize)>`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `recursive-bilateral` (test "basic")

Caused by:
  process didn't exit successfully: `/Users/julianknodt/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/rustc --crate-name basic --edition=2024 tests/basic.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --test --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=6ebc975299290e83 -C extra-filename=-9553790ec6c49fa3 --out-dir /Users/julianknodt/Desktop/programming/rust/recursive_bilateral/target/debug/deps -C incremental=/Users/julianknodt/Desktop/programming/rust/recursive_bilateral/target/debug/incremental -L dependency=/Users/julianknodt/Desktop/programming/rust/recursive_bilateral/target/debug/deps --extern image=/Users/julianknodt/Desktop/programming/rust/recursive_bilateral/target/debug/deps/libimage-dcd1050dd188210a.rlib --extern recursive_bilateral=/Users/julianknodt/Desktop/programming/rust/recursive_bilateral/target/debug/deps/librecursive_bilateral-38fecbbfe698b72f.rlib` (exit status: 101)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.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