rust-lang / rust-lang/rust

[ICE]: type parameter `/#1` (/#1/1) out of range when instantiating

Open
#162,313 0 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

Found by fuzzing with Rime.

Code

File: rime-04807f18.rs

#![crate_type = "lib"]
#![feature(generic_const_exprs)]

trait MyIterator {
    type Output;
}

trait Foo {
    const ABC: usize;
}

struct IteratorStruct<const N: usize> {}

struct Bar<const N: usize> {}

impl<const N: usize> MyIterator for IteratorStruct<N> {
    type Output = Bar<N>;
}

async fn test2<T: Foo>() -> impl MyIterator
where
    [(); T::ABC]:,
{
    IteratorStruct::<{ T::ABC }> {}
}

Compiler version
rustc 1.100.0-nightly (a69a63265 2026-09-03)
binary: rustc
commit-hash: a69a63265cfd9e006d43137f98301b8d274ad4c9
commit-date: 2026-09-03
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1
Crash signature
thread 'rustc' (4031688) panicked at .../compiler/rustc_type_ir/src/binder.rs:788:9:
type parameter `/#1` (/#1/1) out of range when instantiating, args=[T/#0]
stderr
time: {"pass":"parse_crate","time":0.000243139,"rss_start":33763328,"rss_end":36519936}
time: {"pass":"crate_injection","time":0.000060795,"rss_start":42205184,"rss_end":42471424}
time: {"pass":"expand_crate","time":0.002100143,"rss_start":42471424,"rss_end":50634752}
time: {"pass":"check_unused_macros","time":0.000020389,"rss_start":50634752,"rss_end":50634752}
time: {"pass":"macro_expand_crate","time":0.002166808,"rss_start":42471424,"rss_end":50634752}
time: {"pass":"maybe_building_test_harness","time":0.000017544,"rss_start":50634752,"rss_end":50634752}
time: {"pass":"AST_validation","time":0.000034865,"rss_start":50634752,"rss_end":50765824}
time: {"pass":"maybe_create_a_macro_crate","time":0.000017253,"rss_start":50765824,"rss_end":50765824}
time: {"pass":"finalize_imports","time":0.000018736,"rss_start":50765824,"rss_end":50765824}
time: {"pass":"compute_effective_visibilities","time":0.000018525,"rss_start":50831360,"rss_end":50831360}
time: {"pass":"lint_reexports","time":0.000017313,"rss_start":50831360,"rss_end":50831360}
time: {"pass":"finalize_macro_resolutions","time":0.000100589,"rss_start":50831360,"rss_end":50900992}
time: {"pass":"late_resolve_crate","time":0.000634617,"rss_start":50900992,"rss_end":57069568}
time: {"pass":"resolve_main","time":0.000017463,"rss_start":57069568,"rss_end":57069568}
time: {"pass":"resolve_check_unused","time":0.000022432,"rss_start":57069568,"rss_end":57135104}
time: {"pass":"resolve_report_errors","time":0.000017022,"rss_start":57135104,"rss_end":57135104}
time: {"pass":"resolve_postprocess","time":0.000028183,"rss_start":57135104,"rss_end":57266176}
time: {"pass":"resolve_crate","time":0.000983595,"rss_start":50765824,"rss_end":57266176}
time: {"pass":"write_dep_info","time":0.000044624,"rss_start":57475072,"rss_end":57606144}
warning: `feature(generic_const_exprs)` is not supported with the next-generation trait solver
 --> rime-04807f18.rs:3:12
  |
3 | #![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

time: {"pass":"complete_gated_feature_checking","time":0.000144833,"rss_start":57671680,"rss_end":58728448}
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and<path>cause compiler crashes
 --> rime-04807f18.rs:3:12
  |
3 | #![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

time: {"pass":"drop_ast","time":0.000023114,"rss_start":59990016,"rss_end":59990016}
time: {"pass":"drop_ast","time":0.000018294,"rss_start":60080128,"rss_end":60080128}
time: {"pass":"drop_ast","time":0.000018505,"rss_start":60157952,"rss_end":60157952}
time: {"pass":"drop_ast","time":0.000017683,"rss_start":60157952,"rss_end":60157952}
time: {"pass":"drop_ast","time":0.000071304,"rss_start":60157952,"rss_end":60157952}
time: {"pass":"drop_ast","time":0.000017854,"rss_start":60157952,"rss_end":60157952}
time: {"pass":"drop_ast","time":0.000017814,"rss_start":60223488,"rss_end":60223488}
time: {"pass":"drop_ast","time":0.000018194,"rss_start":60223488,"rss_end":60223488}
time: {"pass":"drop_ast","time":0.000025569,"rss_start":60223488,"rss_end":60223488}
time: {"pass":"drop_ast","time":0.000029135,"rss_start":60420096,"rss_end":60420096}
time: {"pass":"drop_ast","time":0.000018325,"rss_start":60420096,"rss_end":60420096}
time: {"pass":"drop_ast","time":0.00002071,"rss_start":60813312,"rss_end":60813312}
time: {"pass":"looking_for_entry_point","time":0.000017663,"rss_start":60813312,"rss_end":60813312}
time: {"pass":"check_externally_implementable_items","time":0.00003177,"rss_start":60813312,"rss_end":60825600}
time: {"pass":"looking_for_derive_registrar","time":0.000017664,"rss_start":60825600,"rss_end":60825600}
time: {"pass":"drop_ast","time":0.000019226,"rss_start":61669376,"rss_end":61669376}
time: {"pass":"unused_lib_feature_checking","time":0.000032953,"rss_start":61800448,"rss_end":61825024}
time: {"pass":"misc_checking_1","time":0.00030214,"rss_start":60813312,"rss_end":61890560}
time: {"pass":"emit_ast_lowering_delayed_lints","time":0.000017403,"rss_start":61890560,"rss_end":61890560}
time: {"pass":"drop_ast","time":0.000021471,"rss_start":65146880,"rss_end":65146880}
time: {"pass":"drop_ast","time":0.000022353,"rss_start":67895296,"rss_end":67895296}

thread 'rustc' (4031688) panicked at .../compiler/rustc_type_ir/src/binder.rs:788:9:
type parameter `/#1` (/#1/1) out of range when instantiating, args=[T/#0]
stack backtrace:
   0:     0x7f6b1068f0b6 - <<std[3415ff3f1179ee52]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[60059dc3f2d0ec08]::fmt::Display>::fmt
   1:     0x7f6b10e0ba4f - core[60059dc3f2d0ec08]::fmt::write
   2:     0x7f6b106a419c - <std[3415ff3f1179ee52]::sys::stdio::unix::Stderr as core[60059dc3f2d0ec08]::io::write::Write>::write_fmt
   3:     0x7f6b1066195a - std[3415ff3f1179ee52]::panicking::default_hook::{closure#0}
   4:     0x7f6b106833b3 - std[3415ff3f1179ee52]::panicking::default_hook
   5:     0x7f6b0f5dd90f - std[3415ff3f1179ee52]::panicking::update_hook::<alloc[4146c6fa462b7b89]::boxed::Box<rustc_driver_impl[f8a99b8cb8cfc92f]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f6b10683852 - std[3415ff3f1179ee52]::panicking::panic_with_hook
   7:     0x7f6b10661a12 - std[3415ff3f1179ee52]::panicking::panic_handler::{closure#0}
   8:     0x7f6b10658889 - std[3415ff3f1179ee52]::sys::backtrace::__rust_end_short_backtrace::<std[3415ff3f1179ee52]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f6b106635ed - __rustc[3a993b859608c480]::rust_begin_unwind
  10:     0x7f6b0d48736c - core[60059dc3f2d0ec08]::panicking::panic_fmt
  11:     0x7f6b0fbe7f65 - <rustc_type_ir[c97055a641c7288b]::binder::ArgFolder<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt>>::type_param_out_of_range
  12:     0x7f6b110d439b - <rustc_type_ir[c97055a641c7288b]::binder::ArgFolder<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt> as rustc_type_ir[c97055a641c7288b]::fold::TypeFolder<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt>>::fold_ty
  13:     0x7f6b110d1114 - <&rustc_middle[3853a6a1ca0e45f4]::ty::list::RawList<(), rustc_middle[3853a6a1ca0e45f4]::ty::generic_args::GenericArg> as rustc_type_ir[c97055a641c7288b]::fold::TypeFoldable<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt>>::fold_with::<rustc_type_ir[c97055a641c7288b]::binder::ArgFolder<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt>>
  14:     0x7f6b122c9386 - <rustc_type_ir[c97055a641c7288b]::binder::ArgFolder<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt> as rustc_type_ir[c97055a641c7288b]::fold::TypeFolder<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt>>::fold_const
  15:     0x7f6b110d3e8a - <rustc_type_ir[c97055a641c7288b]::binder::ArgFolder<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt> as rustc_type_ir[c97055a641c7288b]::fold::TypeFolder<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt>>::fold_ty
  16:     0x7f6b110d1114 - <&rustc_middle[3853a6a1ca0e45f4]::ty::list::RawList<(), rustc_middle[3853a6a1ca0e45f4]::ty::generic_args::GenericArg> as rustc_type_ir[c97055a641c7288b]::fold::TypeFoldable<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt>>::fold_with::<rustc_type_ir[c97055a641c7288b]::binder::ArgFolder<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt>>
  17:     0x7f6b110d40fb - <rustc_type_ir[c97055a641c7288b]::binder::ArgFolder<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt> as rustc_type_ir[c97055a641c7288b]::fold::TypeFolder<rustc_middle[3853a6a1ca0e45f4]::ty::context::TyCtxt>>::fold_ty
  18:     0x7f6b120c27c2 - <rustc_borrowck[889ac5e9118c83dd]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  19:     0x7f6b120be895 - rustc_borrowck[889ac5e9118c83dd]::mir_borrowck
  20:     0x7f6b120be599 - rustc_query_impl[9016699e7ca36e5]::query_vtables::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
  21:     0x7f6b116be9b5 - rustc_query_impl[9016699e7ca36e5]::execution::try_execute_query::<rustc_data_structures[b49e709c0ea11b52]::vec_cache::VecCache<rustc_span[3c4838eae61a81b3]::def_id::LocalDefId, rustc_middle[3853a6a1ca0e45f4]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[3853a6a1ca0e45f4]::dep_graph::graph::DepNodeIndex>, false>
  22:     0x7f6b116be527 - rustc_query_impl[9016699e7ca36e5]::query_vtables::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7f6b120609bf - rustc_hir_analysis[3f821efd814a8617]::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
  24:     0x7f6b120606ac - rustc_hir_analysis[3f821efd814a8617]::collect::type_of::type_of_opaque
  25:     0x7f6b10e3b17d - rustc_query_impl[9016699e7ca36e5]::execution::try_execute_query::<rustc_middle[3853a6a1ca0e45f4]::query::caches::DefIdCache<rustc_middle[3853a6a1ca0e45f4]::query::erase::ErasedData<[u8; 8usize]>>, false>
  26:     0x7f6b113b2a44 - rustc_query_impl[9016699e7ca36e5]::query_vtables::type_of_opaque::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f6b113acb33 - rustc_hir_analysis[3f821efd814a8617]::collect::type_of::type_of
  28:     0x7f6b113a2466 - rustc_query_impl[9016699e7ca36e5]::query_vtables::type_of::invoke_provider_fn::__rust_begin_short_backtrace
  29:     0x7f6b10e3b17d - rustc_query_impl[9016699e7ca36e5]::execution::try_execute_query::<rustc_middle[3853a6a1ca0e45f4]::query::caches::DefIdCache<rustc_middle[3853a6a1ca0e45f4]::query::erase::ErasedData<[u8; 8usize]>>, false>
  30:     0x7f6b10e3ae23 - rustc_query_impl[9016699e7ca36e5]::query_vtables::type_of::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7f6b12060ed2 - rustc_hir_analysis[3f821efd814a8617]::check::check::check_opaque
  32:     0x7f6b1207eedd - rustc_hir_analysis[3f821efd814a8617]::check::check::check_item_type
  33:     0x7f6b1207646e - rustc_hir_analysis[3f821efd814a8617]::check::wfcheck::check_well_formed
  34:     0x7f6b1207644f - rustc_query_impl[9016699e7ca36e5]::query_vtables::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  35:     0x7f6b12075a7d - rustc_query_impl[9016699e7ca36e5]::execution::try_execute_query::<rustc_data_structures[b49e709c0ea11b52]::vec_cache::VecCache<rustc_span[3c4838eae61a81b3]::def_id::LocalDefId, rustc_middle[3853a6a1ca0e45f4]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[3853a6a1ca0e45f4]::dep_graph::graph::DepNodeIndex>, false>
  36:     0x7f6b12075815 - rustc_query_impl[9016699e7ca36e5]::query_vtables::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  37:     0x7f6b1206ae30 - <rustc_middle[3853a6a1ca0e45f4]::hir::ModuleItems>::par_opaques::<rustc_hir_analysis[3f821efd814a8617]::check::wfcheck::check_type_wf::{closure#5}>
  38:     0x7f6b1207337e - rustc_hir_analysis[3f821efd814a8617]::check::wfcheck::check_type_wf
  39:     0x7f6b12072f15 - rustc_query_impl[9016699e7ca36e5]::query_vtables::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  40:     0x7f6b12058149 - rustc_query_impl[9016699e7ca36e5]::execution::try_execute_query::<rustc_middle[3853a6a1ca0e45f4]::query::caches::SingleCache<rustc_middle[3853a6a1ca0e45f4]::query::erase::ErasedData<[u8; 1usize]>>, false>
  41:     0x7f6b12057f2d - rustc_query_impl[9016699e7ca36e5]::query_vtables::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  42:     0x7f6b11428324 - rustc_hir_analysis[3f821efd814a8617]::check_crate
  43:     0x7f6b116bff08 - rustc_interface[236251bde598998e]::passes::analysis
  44:     0x7f6b12059a4a - rustc_query_impl[9016699e7ca36e5]::execution::try_execute_query::<rustc_middle[3853a6a1ca0e45f4]::query::caches::SingleCache<rustc_middle[3853a6a1ca0e45f4]::query::erase::ErasedData<[u8; 0usize]>>, false>
  45:     0x7f6b120597d3 - rustc_query_impl[9016699e7ca36e5]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  46:     0x7f6b122062a4 - rustc_interface[236251bde598998e]::interface::run_compiler::<(), rustc_driver_impl[f8a99b8cb8cfc92f]::run_compiler::{closure#0}>::{closure#2}
  47:     0x7f6b12291f82 - std[3415ff3f1179ee52]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[236251bde598998e]::util::run_in_thread_with_globals<rustc_interface[236251bde598998e]::util::run_in_thread_pool_with_globals<rustc_interface[236251bde598998e]::interface::run_compiler<(), rustc_driver_impl[f8a99b8cb8cfc92f]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  48:     0x7f6b12291d2d - <std[3415ff3f1179ee52]::thread::lifecycle::spawn_unchecked<rustc_interface[236251bde598998e]::util::run_in_thread_with_globals<rustc_interface[236251bde598998e]::util::run_in_thread_pool_with_globals<rustc_interface[236251bde598998e]::interface::run_compiler<(), rustc_driver_impl[f8a99b8cb8cfc92f]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[60059dc3f2d0ec08]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7f6b1228f747 - <std[3415ff3f1179ee52]::sys::thread::unix::Thread>::new::thread_start
  50:     0x7f6b0b479c19 - start_thread
  51:     0x7f6b0b4fd5cc - __clone3
  52:                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 `<path>to your bug report

note: rustc 1.100.0-nightly (a69a63265 2026-09-03) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z time-passes=yes -Z time-passes-format=json -Z mir-opt-level=4

query stack during panic:
#0 [mir_borrowck] borrow-checking `test2`
#1 [type_of_opaque] computing type of opaque `test2::{opaque#0}`
... and 4 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
time: {"pass":"coherence_checking","time":0.02109494,"rss_start":62021632,"rss_end":115437568}
time: {"pass":"type_check_crate","time":0.021139033,"rss_start":61956096,"rss_end":115503104}
warning: 2 warnings emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: OpaqueTypeStorage { opaque_types: {OpaqueTypeKey { def_id: DefId(0:17 ~ rime_20704cb2[d7c6]::test2::{opaque#0}), args: [T/#0] }: ProvisionalHiddenType { span: rime-04807f18.rs:29:69: 31:2 (#0), ty: Coroutine(DefId(0:19 ~ rime_20704cb2[d7c6]::test2::{closure#0}), [T/#0, (), std::future::ResumeTy, (), IteratorStruct<AliasConst(No, Alias { kind: Anon { def_id: DefId(0:20 ~ rime_20704cb2[d7c6]::test2::{closure#0}::{constant#0}) }, args: [T/#0, /#1, /#2, /#3, /#4, /#5], .. })>, ()]) }, OpaqueTypeKey { def_id: DefId(0:18 ~ rime_20704cb2[d7c6]::test2::{opaque#0}::{opaque#0}), args: [T/#0] }: ProvisionalHiddenType { span: rime-04807f18.rs:29:69: 31:2 (#0), ty: ?1t }}, duplicate_entries: [] }
  |
  = note: delayed at .../compiler/rustc_infer/src/infer/mod.rs:388:43 - disabled 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 `<path>to your bug report

note: rustc 1.100.0-nightly (a69a63265 2026-09-03) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z time-passes=yes -Z time-passes-format=json -Z mir-opt-level=4

query stack during panic:
end of query stack

Reproduction

Run:

'rustc' '--edition=2024' '-Ztime-passes=yes' '-Ztime-passes-format=json' '--emit=mir' '-Zmir-opt-level=4' 'rime-04807f18.rs'

The compiler exited with code 101 after 42 ms.

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 compiling the provided rime-04807f18.rs reproducer with the reported nightly and confirm the ICE. Read compiler/rustc_type_ir/src/binder.rs around the reported assertion, then follow the stack through rustc_borrowck::mir_borrowck and type_of_opaque. Done means this input no longer panics and regression coverage preserves the fix.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.