Skip to content

[ICE]: unexpected inference var #156744

@nazar-pc

Description

@nazar-pc

Code

#![expect(incomplete_features, reason = "generic_const_*")]
#![feature(
    min_generic_const_args,
    generic_const_args,
    generic_const_items,
)]

type const PROOF_ELEMENTS<const N: usize>: usize = const { N.ilog2() as usize };

pub struct BalancedMerkleTree<const N: usize> {}

impl<const N: usize> BalancedMerkleTree<N> {
    pub fn all_proofs(&self) -> impl Iterator<Item = [[u8; 32]; PROOF_ELEMENTS::<N>]> {
        let iter = core::iter::empty().map(|()| [[0u8; _]; _]);

        ProofsIterator { iter, len: N }
    }
}

struct ProofsIterator<Iter> {
    iter: Iter,
    len: usize,
}

impl<Iter> Iterator for ProofsIterator<Iter>
where
    Iter: Iterator,
{
    type Item = Iter::Item;

    fn next(&mut self) -> Option<Self::Item> {
        let item = self.iter.next();
        self.len = self.len.saturating_sub(1);
        item
    }
}

Meta

rustc --version --verbose:

rustc 1.97.0-nightly (9eb3be26b 2026-05-18)
binary: rustc
commit-hash: 9eb3be26b46eccea1de7448ea9cc3c1d20bb1a35
commit-date: 2026-05-18
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4

Error output

thread 'rustc' (106120) panicked at /rustc-dev/9eb3be26b46eccea1de7448ea9cc3c1d20bb1a35/compiler/rustc_borrowck/src/type_check/relate_tys.rs:449:9:
unexpected inference var ?8c
stack backtrace:
   0:     0x7f96db4731f9 - <<std[96bb1fa33c82f88a]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[a4b43c77cd16befc]::fmt::Display>::fmt
   1:     0x7f96dba1a808 - core[a4b43c77cd16befc]::fmt::write
   2:     0x7f96db489ee6 - <std[96bb1fa33c82f88a]::sys::stdio::unix::Stderr as std[96bb1fa33c82f88a]::io::Write>::write_fmt
   3:     0x7f96db44941e - std[96bb1fa33c82f88a]::panicking::default_hook::{closure#0}
   4:     0x7f96db466b33 - std[96bb1fa33c82f88a]::panicking::default_hook
   5:     0x7f96da265441 - std[96bb1fa33c82f88a]::panicking::update_hook::<alloc[6ae955702c75754f]::boxed::Box<rustc_driver_impl[c8dd7defd295a0d5]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f96db466e12 - std[96bb1fa33c82f88a]::panicking::panic_with_hook
   7:     0x7f96db4494e2 - std[96bb1fa33c82f88a]::panicking::panic_handler::{closure#0}
   8:     0x7f96db43da09 - std[96bb1fa33c82f88a]::sys::backtrace::__rust_end_short_backtrace::<std[96bb1fa33c82f88a]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f96db44af4d - __rustc[31db7c507078ba80]::rust_begin_unwind
  10:     0x7f96d7e106ec - core[a4b43c77cd16befc]::panicking::panic_fmt
  11:     0x7f96dc5d9bed - <rustc_borrowck[a5050f6ae90a3892]::type_check::relate_tys::NllTypeRelating as rustc_type_ir[90db3acef15731e1]::relate::TypeRelation<rustc_middle[738dba01435f8feb]::ty::context::TyCtxt>>::consts
  12:     0x7f96dc5dc09e - rustc_type_ir[90db3acef15731e1]::relate::structurally_relate_tys::<rustc_middle[738dba01435f8feb]::ty::context::TyCtxt, rustc_borrowck[a5050f6ae90a3892]::type_check::relate_tys::NllTypeRelating>::{closure#0}
  13:     0x7f96dc5da1bb - <rustc_borrowck[a5050f6ae90a3892]::type_check::relate_tys::NllTypeRelating as rustc_type_ir[90db3acef15731e1]::relate::TypeRelation<rustc_middle[738dba01435f8feb]::ty::context::TyCtxt>>::tys
  14:     0x7f96dc5e8cbc - <rustc_infer[cce6abbb80d163bf]::infer::InferCtxt>::instantiate_var::<rustc_borrowck[a5050f6ae90a3892]::type_check::relate_tys::NllTypeRelating>
  15:     0x7f96dc5e8851 - <rustc_borrowck[a5050f6ae90a3892]::type_check::TypeChecker>::relate_types
  16:     0x7f96dc5e7045 - <rustc_borrowck[a5050f6ae90a3892]::type_check::TypeChecker>::ascribe_user_type_skip_wf
  17:     0x7f96d872b98d - rustc_borrowck[a5050f6ae90a3892]::type_check::type_check
  18:     0x7f96dcaf4240 - <rustc_borrowck[a5050f6ae90a3892]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  19:     0x7f96dcaef09b - rustc_borrowck[a5050f6ae90a3892]::mir_borrowck
  20:     0x7f96dcaeee75 - rustc_query_impl[cd1ee47b75179b1c]::query_impl::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
  21:     0x7f96dbb84fa1 - rustc_query_impl[cd1ee47b75179b1c]::execution::try_execute_query::<rustc_data_structures[7c127a85152bc75d]::vec_cache::VecCache<rustc_span[17ae307486240b8b]::def_id::LocalDefId, rustc_middle[738dba01435f8feb]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[738dba01435f8feb]::dep_graph::graph::DepNodeIndex>, true>
  22:     0x7f96dbb8196e - rustc_query_impl[cd1ee47b75179b1c]::query_impl::mir_borrowck::execute_query_incr::__rust_end_short_backtrace
  23:     0x7f96dcc1f81e - rustc_hir_analysis[b0cc240c6543ca0a]::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
  24:     0x7f96dcc1f55c - rustc_hir_analysis[b0cc240c6543ca0a]::collect::type_of::type_of_opaque
  25:     0x7f96dbb77bd6 - rustc_query_impl[cd1ee47b75179b1c]::execution::try_execute_query::<rustc_middle[738dba01435f8feb]::query::caches::DefIdCache<rustc_middle[738dba01435f8feb]::query::erase::ErasedData<[u8; 8usize]>>, true>
  26:     0x7f96dce2c2aa - rustc_query_impl[cd1ee47b75179b1c]::query_impl::type_of_opaque::execute_query_incr::__rust_end_short_backtrace
  27:     0x7f96dbe24d08 - rustc_hir_analysis[b0cc240c6543ca0a]::collect::type_of::type_of
  28:     0x7f96dbe1afaa - rustc_query_impl[cd1ee47b75179b1c]::query_impl::type_of::invoke_provider_fn::__rust_begin_short_backtrace
  29:     0x7f96dbb77bd6 - rustc_query_impl[cd1ee47b75179b1c]::execution::try_execute_query::<rustc_middle[738dba01435f8feb]::query::caches::DefIdCache<rustc_middle[738dba01435f8feb]::query::erase::ErasedData<[u8; 8usize]>>, true>
  30:     0x7f96dbb74f2f - rustc_query_impl[cd1ee47b75179b1c]::query_impl::type_of::execute_query_incr::__rust_end_short_backtrace
  31:     0x7f96dcc1fc14 - rustc_hir_analysis[b0cc240c6543ca0a]::check::check::check_opaque
  32:     0x7f96dbf73fa8 - rustc_hir_analysis[b0cc240c6543ca0a]::check::check::check_item_type
  33:     0x7f96dbf6a45c - rustc_hir_analysis[b0cc240c6543ca0a]::check::wfcheck::check_well_formed
  34:     0x7f96dbf6a437 - rustc_query_impl[cd1ee47b75179b1c]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  35:     0x7f96dbb8b178 - rustc_query_impl[cd1ee47b75179b1c]::execution::try_execute_query::<rustc_data_structures[7c127a85152bc75d]::vec_cache::VecCache<rustc_span[17ae307486240b8b]::def_id::LocalDefId, rustc_middle[738dba01435f8feb]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[738dba01435f8feb]::dep_graph::graph::DepNodeIndex>, true>
  36:     0x7f96dbb8a7ba - rustc_query_impl[cd1ee47b75179b1c]::query_impl::check_well_formed::execute_query_incr::__rust_end_short_backtrace
  37:     0x7f96dbf66526 - rustc_hir_analysis[b0cc240c6543ca0a]::check::wfcheck::check_type_wf
  38:     0x7f96dbf663b9 - rustc_query_impl[cd1ee47b75179b1c]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  39:     0x7f96dcd8a5b1 - rustc_query_impl[cd1ee47b75179b1c]::execution::try_execute_query::<rustc_middle[738dba01435f8feb]::query::caches::SingleCache<rustc_middle[738dba01435f8feb]::query::erase::ErasedData<[u8; 1usize]>>, true>
  40:     0x7f96dcd89dcb - rustc_query_impl[cd1ee47b75179b1c]::query_impl::check_type_wf::execute_query_incr::__rust_end_short_backtrace
  41:     0x7f96dbcc9fdb - rustc_hir_analysis[b0cc240c6543ca0a]::check_crate
  42:     0x7f96dbcc5961 - rustc_interface[150676b9e5f03c12]::passes::analysis
  43:     0x7f96dcbfaa72 - rustc_query_impl[cd1ee47b75179b1c]::execution::try_execute_query::<rustc_middle[738dba01435f8feb]::query::caches::SingleCache<rustc_middle[738dba01435f8feb]::query::erase::ErasedData<[u8; 0usize]>>, true>
  44:     0x7f96dcbfa42a - rustc_query_impl[cd1ee47b75179b1c]::query_impl::analysis::execute_query_incr::__rust_end_short_backtrace
  45:     0x7f96dcb5d59b - rustc_interface[150676b9e5f03c12]::interface::run_compiler::<(), rustc_driver_impl[c8dd7defd295a0d5]::run_compiler::{closure#0}>::{closure#1}
  46:     0x7f96dcb97100 - std[96bb1fa33c82f88a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[150676b9e5f03c12]::util::run_in_thread_with_globals<rustc_interface[150676b9e5f03c12]::util::run_in_thread_pool_with_globals<rustc_interface[150676b9e5f03c12]::interface::run_compiler<(), rustc_driver_impl[c8dd7defd295a0d5]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  47:     0x7f96dcb977ed - <std[96bb1fa33c82f88a]::thread::lifecycle::spawn_unchecked<rustc_interface[150676b9e5f03c12]::util::run_in_thread_with_globals<rustc_interface[150676b9e5f03c12]::util::run_in_thread_pool_with_globals<rustc_interface[150676b9e5f03c12]::interface::run_compiler<(), rustc_driver_impl[c8dd7defd295a0d5]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a4b43c77cd16befc]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x7f96dcb985ec - <std[96bb1fa33c82f88a]::sys::thread::unix::Thread>::new::thread_start
  49:     0x7f96d629caa4 - start_thread
                               at ./nptl/pthread_create.c:447:8
  50:     0x7f96d6329c6c - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
  51:                0x0 - <unknown>

error: the compiler unexpectedly panicked. This is a bug

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/web/github/abundance/rustc-ice-2026-05-19T10_29_16-106119.txt` to your bug report

note: rustc 1.97.0-nightly (9eb3be26b 2026-05-18) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -Z next-solver=globally

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `<impl at crates/shared/ab-merkle-tree/src/lib.rs:13:1: 13:43>::all_proofs`
#1 [type_of_opaque] computing type of opaque `<impl at crates/shared/ab-merkle-tree/src/lib.rs:13:1: 13:43>::all_proofs::{opaque#0}`
... and 4 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
note: Clippy version: clippy 0.1.97 (9eb3be26b4 2026-05-18)

error: could not compile `ab-merkle-tree` (lib)

Caused by:
  process didn't exit successfully: `/home/nazar-pc/.rustup/toolchains/nightly-2026-05-19-x86_64-unknown-linux-gnu/bin/clippy-driver /home/nazar-pc/.rustup/toolchains/nightly-2026-05-19-x86_64-unknown-linux-gnu/bin/rustc --crate-name ab_merkle_tree --edition=2024 crates/shared/ab-merkle-tree/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=459 --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 --warn=unreachable_pub '--warn=clippy::undocumented_unsafe_blocks' --warn=rust_2018_idioms '--warn=clippy::ptr_as_ptr' --warn=missing_debug_implementations '--warn=clippy::cast_sign_loss' '--warn=clippy::cast_possible_wrap' '--warn=clippy::assigning_clones' '--deny=clippy::as_ptr_cast_mut' '--warn=clippy::as_pointer_underscore' '--warn=clippy::allow_attributes' --allow=unexpected_cfgs --check-cfg 'cfg(target_arch, values("spirv"))' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("alloc", "blake3", "no-panic"))' -C metadata=f792c5f40006f149 -C extra-filename=-6f3039ac4abb7c23 --out-dir /home/nazar-pc/.cache/cargo/target/debug/deps -C incremental=/home/nazar-pc/.cache/cargo/target/debug/incremental -L dependency=/home/nazar-pc/.cache/cargo/target/debug/deps --extern ab_blake3=/home/nazar-pc/.cache/cargo/target/debug/deps/libab_blake3-e5e42885f8ca777e.rmeta -Znext-solver=globally -L native=/home/nazar-pc/.cache/cargo/target/debug/build/blake3-6fbbe994c6e1f9b7/out -L native=/home/nazar-pc/.cache/cargo/target/debug/build/blake3-6fbbe994c6e1f9b7/out` (exit status: 101)

Backtrace

thread 'rustc' (108239) panicked at /rustc-dev/9eb3be26b46eccea1de7448ea9cc3c1d20bb1a35/compiler/rustc_borrowck/src/type_check/relate_tys.rs:449:9:
unexpected inference var ?8c
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: <rustc_borrowck::type_check::relate_tys::NllTypeRelating as rustc_type_ir::relate::TypeRelation<rustc_middle::ty::context::TyCtxt>>::consts
   3: rustc_type_ir::relate::structurally_relate_tys::<rustc_middle::ty::context::TyCtxt, rustc_borrowck::type_check::relate_tys::NllTypeRelating>::{closure#0}
   4: <rustc_borrowck::type_check::relate_tys::NllTypeRelating as rustc_type_ir::relate::TypeRelation<rustc_middle::ty::context::TyCtxt>>::tys
   5: <rustc_infer::infer::InferCtxt>::instantiate_var::<rustc_borrowck::type_check::relate_tys::NllTypeRelating>
   6: <rustc_borrowck::type_check::TypeChecker>::relate_types
   7: <rustc_borrowck::type_check::TypeChecker>::ascribe_user_type_skip_wf
   8: rustc_borrowck::type_check::type_check
   9: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  10: rustc_borrowck::mir_borrowck
      [... omitted 1 frame ...]
  11: rustc_hir_analysis::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
  12: rustc_hir_analysis::collect::type_of::type_of_opaque
  13: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefIdCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, true>
  14: rustc_hir_analysis::collect::type_of::type_of
      [... omitted 1 frame ...]
  15: rustc_hir_analysis::check::check::check_opaque
  16: rustc_hir_analysis::check::check::check_item_type
  17: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
  18: rustc_hir_analysis::check::wfcheck::check_type_wf
      [... omitted 1 frame ...]
  19: rustc_hir_analysis::check_crate
  20: rustc_interface::passes::analysis
  21: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, true>
  22: 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 `/web/github/abundance/rustc-ice-2026-05-19T10_32_02-108222.txt` to your bug report

note: rustc 1.97.0-nightly (9eb3be26b 2026-05-18) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -Z next-solver=globally

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `<impl at crates/shared/ab-merkle-tree/src/lib.rs:13:1: 13:43>::all_proofs`
#1 [type_of_opaque] computing type of opaque `<impl at crates/shared/ab-merkle-tree/src/lib.rs:13:1: 13:43>::all_proofs::{opaque#0}`
#2 [type_of] computing type of `<impl at crates/shared/ab-merkle-tree/src/lib.rs:13:1: 13:43>::all_proofs::{opaque#0}`
#3 [check_well_formed] checking that `<impl at crates/shared/ab-merkle-tree/src/lib.rs:13:1: 13:43>::all_proofs::{opaque#0}` is well-formed
#4 [check_type_wf] checking that types are well-formed
#5 [analysis] running analysis passes on crate `ab_merkle_tree`
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions