rust-lang / rust-lang/rust

[ICE]: region parameter .. out of range when instantiating

Open
#159,018 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-final_associated_functions I-ICE needs-triage S-candidate-for-closing T-compiler WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
trait FinalSelfReturn {
    final fn self_return(&self) -> impl Sized {}
}
fn main() {
    let obj_return: &dyn FinalSelfReturn;
    obj_return.self_return();
}

original:

#![feature(final_associated_functions)]
trait FinalSelfReturn {
    final fn self_return(&self) -> impl Sized {}
}
fn main() {
    let obj_return: &dyn FinalSelfReturn;
    obj_return.self_return();
}

Version information

rustc 1.99.0-nightly (71c64160b 2026-07-09)
binary: rustc
commit-hash: 71c64160bd0f471bffdbdf7061fd62bab053d5b4
commit-date: 2026-07-09
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8

Possibly related line of code:
https://github.com/rust-lang/rust/blob/71c64160bd0f471bffdbdf7061fd62bab053d5b4/compiler/rustc_type_ir/src/binder.rs#L887-L899

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally

Program output

error[E0658]: `final` on trait functions is experimental
 --> /tmp/icemaker_global_tempdir.r4Wz6AyZx5S3/rustc_testrunner_tmpdir_reporting.UZbl8yLdq2B5/mvce.rs:2:5
  |
2 |     final fn self_return(&self) -> impl Sized {}
  |     ^^^^^
  |
  = note: see issue #131179 <https://github.com/rust-lang/rust/issues/131179> for more information
  = help: add `#![feature(final_associated_functions)]` to the crate attributes to enable
  = note: this compiler was built on 2026-07-09; consider upgrading it if it is out of date


thread 'rustc' (765789) panicked at /rustc-dev/71c64160bd0f471bffdbdf7061fd62bab053d5b4/compiler/rustc_type_ir/src/binder.rs:893:9:
region parameter `'_/#1` ('_/#1/1) out of range when instantiating args=[dyn [Binder { value: Trait(FinalSelfReturn), bound_vars: [] }] + '!0]
stack backtrace:
   0:     0x7fd7438e4b06 - <<std[17923d02bb28d89c]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[bf6eba7c7efba28b]::fmt::Display>::fmt
   1:     0x7fd74400eede - core[bf6eba7c7efba28b]::fmt::write
   2:     0x7fd7438f9eec - <std[17923d02bb28d89c]::sys::stdio::unix::Stderr as std[17923d02bb28d89c]::io::Write>::write_fmt
   3:     0x7fd7438b8e0a - std[17923d02bb28d89c]::panicking::default_hook::{closure#0}
   4:     0x7fd7438d71c3 - std[17923d02bb28d89c]::panicking::default_hook
   5:     0x7fd7428bf148 - std[17923d02bb28d89c]::panicking::update_hook::<alloc[57d3a8d7fe6e581c]::boxed::Box<rustc_driver_impl[b4f847f556f8ec97]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fd7438d7662 - std[17923d02bb28d89c]::panicking::panic_with_hook
   7:     0x7fd7438b8ec2 - std[17923d02bb28d89c]::panicking::panic_handler::{closure#0}
   8:     0x7fd7438ad3a9 - std[17923d02bb28d89c]::sys::backtrace::__rust_end_short_backtrace::<std[17923d02bb28d89c]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fd7438ba82d - __rustc[74db064d05eb3a7]::rust_begin_unwind
  10:     0x7fd740a1910c - core[bf6eba7c7efba28b]::panicking::panic_fmt
  11:     0x7fd742ea26d5 - <rustc_type_ir[7c6e04240091539c]::binder::ArgFolder<rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::region_param_out_of_range
  12:     0x7fd74404e373 - <rustc_type_ir[7c6e04240091539c]::binder::ArgFolder<rustc_middle[15e230250490b43e]::ty::context::TyCtxt> as rustc_type_ir[7c6e04240091539c]::fold::TypeFolder<rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::fold_ty
  13:     0x7fd744047903 - <rustc_middle[15e230250490b43e]::ty::predicate::Clause as rustc_type_ir[7c6e04240091539c]::fold::TypeFoldable<rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::fold_with::<rustc_type_ir[7c6e04240091539c]::binder::ArgFolder<rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>
  14:     0x7fd744d78ef0 - rustc_next_trait_solver[e63ddd75daf7c8da]::solve::assembly::structural_traits::predicates_for_object_candidate::<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>
  15:     0x7fd744d78950 - <rustc_type_ir[7c6e04240091539c]::predicate::TraitPredicate<rustc_middle[15e230250490b43e]::ty::context::TyCtxt> as rustc_next_trait_solver[e63ddd75daf7c8da]::solve::assembly::GoalKind<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::match_assumption::<<rustc_type_ir[7c6e04240091539c]::predicate::TraitPredicate<rustc_middle[15e230250490b43e]::ty::context::TyCtxt> as rustc_next_trait_solver[e63ddd75daf7c8da]::solve::assembly::GoalKind<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::probe_and_consider_object_bound_candidate::{closure#0}>
  16:     0x7fd744d7c8cc - <rustc_type_ir[7c6e04240091539c]::predicate::TraitPredicate<rustc_middle[15e230250490b43e]::ty::context::TyCtxt> as rustc_next_trait_solver[e63ddd75daf7c8da]::solve::assembly::GoalKind<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::probe_and_match_goal_against_assumption::<<rustc_type_ir[7c6e04240091539c]::predicate::TraitPredicate<rustc_middle[15e230250490b43e]::ty::context::TyCtxt> as rustc_next_trait_solver[e63ddd75daf7c8da]::solve::assembly::GoalKind<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::probe_and_consider_object_bound_candidate::{closure#0}>
  17:     0x7fd74554c115 - <rustc_next_trait_solver[e63ddd75daf7c8da]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::compute_trait_goal
  18:     0x7fd7451b9216 - <rustc_next_trait_solver[e63ddd75daf7c8da]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate> as rustc_type_ir[7c6e04240091539c]::search_graph::Delegate>::compute_goal::{closure#0}
  19:     0x7fd741254b13 - <rustc_type_ir[7c6e04240091539c]::search_graph::SearchGraph<rustc_next_trait_solver[e63ddd75daf7c8da]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate>, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::evaluate_goal::{closure#0}
  20:     0x7fd744d33e5b - <rustc_next_trait_solver[e63ddd75daf7c8da]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::evaluate_goal_cold
  21:     0x7fd744207d72 - <rustc_next_trait_solver[e63ddd75daf7c8da]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::evaluate_added_goals_step
  22:     0x7fd744d84f03 - <rustc_next_trait_solver[e63ddd75daf7c8da]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::evaluate_added_goals_and_make_canonical_response::{closure#0}
  23:     0x7fd7451b98d0 - <rustc_next_trait_solver[e63ddd75daf7c8da]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate> as rustc_type_ir[7c6e04240091539c]::search_graph::Delegate>::compute_goal::{closure#0}
  24:     0x7fd741254b13 - <rustc_type_ir[7c6e04240091539c]::search_graph::SearchGraph<rustc_next_trait_solver[e63ddd75daf7c8da]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate>, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::evaluate_goal::{closure#0}
  25:     0x7fd744d33e5b - <rustc_next_trait_solver[e63ddd75daf7c8da]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate, rustc_middle[15e230250490b43e]::ty::context::TyCtxt>>::evaluate_goal_cold
  26:     0x7fd744d33220 - <rustc_trait_selection[244cc590383734dc]::solve::delegate::SolverDelegate as rustc_next_trait_solver[e63ddd75daf7c8da]::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal
  27:     0x7fd74421018b - <rustc_trait_selection[244cc590383734dc]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[244cc590383734dc]::traits::FulfillmentError> as rustc_infer[6562bab0b11b09a7]::traits::engine::TraitEngine<rustc_trait_selection[244cc590383734dc]::traits::FulfillmentError>>::try_evaluate_obligations
  28:     0x7fd744416468 - <core[bf6eba7c7efba28b]::iter::adapters::filter::Filter<core[bf6eba7c7efba28b]::iter::adapters::map::Map<core[bf6eba7c7efba28b]::iter::adapters::filter::Filter<core[bf6eba7c7efba28b]::slice::iter::Iter<rustc_hir_typeck[a102fae51bb8b632]::method::probe::Candidate>, <rustc_hir_typeck[a102fae51bb8b632]::method::probe::ProbeContext>::consider_candidates::{closure#0}>, <rustc_hir_typeck[a102fae51bb8b632]::method::probe::ProbeContext>::consider_candidates::{closure#1}>, <rustc_hir_typeck[a102fae51bb8b632]::method::probe::ProbeContext>::consider_candidates::{closure#2}> as core[bf6eba7c7efba28b]::iter::traits::iterator::Iterator>::next
  29:     0x7fd74440cb0b - <rustc_hir_typeck[a102fae51bb8b632]::method::probe::ProbeContext>::pick_all_method
  30:     0x7fd74502b972 - <rustc_hir_typeck[a102fae51bb8b632]::fn_ctxt::FnCtxt>::lookup_probe
  31:     0x7fd7442c4aba - <rustc_hir_typeck[a102fae51bb8b632]::fn_ctxt::FnCtxt>::check_expr_method_call
  32:     0x7fd7442df900 - <rustc_hir_typeck[a102fae51bb8b632]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  33:     0x7fd7442b6433 - <rustc_hir_typeck[a102fae51bb8b632]::fn_ctxt::FnCtxt>::check_expr_block
  34:     0x7fd7442df92d - <rustc_hir_typeck[a102fae51bb8b632]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  35:     0x7fd74429688c - rustc_hir_typeck[a102fae51bb8b632]::check::check_fn
  36:     0x7fd744e81201 - rustc_hir_typeck[a102fae51bb8b632]::typeck_with_inspect::{closure#0}
  37:     0x7fd744e7fc00 - rustc_query_impl[d58a7b813a5b7f55]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  38:     0x7fd7443f81a9 - rustc_query_impl[d58a7b813a5b7f55]::execution::try_execute_query::<rustc_data_structures[fd85311d7f0af68d]::vec_cache::VecCache<rustc_span[c5a5c3dd8ccfd604]::def_id::LocalDefId, rustc_middle[15e230250490b43e]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[15e230250490b43e]::dep_graph::graph::DepNodeIndex>, false>
  39:     0x7fd7443f7c03 - rustc_query_impl[d58a7b813a5b7f55]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  40:     0x7fd7443f5173 - <rustc_middle[15e230250490b43e]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[b04cde925e264121]::check_crate::{closure#1}>::{closure#0}
  41:     0x7fd7443f4ab1 - rustc_hir_analysis[b04cde925e264121]::check_crate
  42:     0x7fd7443f8eba - rustc_interface[e6f7a441c6fe091c]::passes::analysis
  43:     0x7fd745108387 - rustc_query_impl[d58a7b813a5b7f55]::execution::try_execute_query::<rustc_middle[15e230250490b43e]::query::caches::SingleCache<rustc_middle[15e230250490b43e]::query::erase::ErasedData<[u8; 0usize]>>, false>
  44:     0x7fd745108069 - rustc_query_impl[d58a7b813a5b7f55]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  45:     0x7fd745144140 - rustc_interface[e6f7a441c6fe091c]::interface::run_compiler::<(), rustc_driver_impl[b4f847f556f8ec97]::run_compiler::{closure#0}>::{closure#1}
  46:     0x7fd74511ccfa - std[17923d02bb28d89c]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e6f7a441c6fe091c]::util::run_in_thread_with_globals<rustc_interface[e6f7a441c6fe091c]::util::run_in_thread_pool_with_globals<rustc_interface[e6f7a441c6fe091c]::interface::run_compiler<(), rustc_driver_impl[b4f847f556f8ec97]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  47:     0x7fd74511caad - <std[17923d02bb28d89c]::thread::lifecycle::spawn_unchecked<rustc_interface[e6f7a441c6fe091c]::util::run_in_thread_with_globals<rustc_interface[e6f7a441c6fe091c]::util::run_in_thread_pool_with_globals<rustc_interface[e6f7a441c6fe091c]::interface::run_compiler<(), rustc_driver_impl[b4f847f556f8ec97]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[bf6eba7c7efba28b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x7fd745112e90 - <std[17923d02bb28d89c]::sys::thread::unix::Thread>::new::thread_start
  49:     0x7fd73ea981b9 - <unknown>
  50:     0x7fd73eb1d21c - <unknown>
  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/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: rustc 1.99.0-nightly (71c64160b 2026-07-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck_root] type-checking `main`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.

@rustbot label +F-final_associated_functions +WG-trait-system-refactor

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

Reproduce the reduced example in a.rs with rustc -Znext-solver=globally, then inspect compiler/rustc_type_ir/src/binder.rs around lines 887-899 and the reported trait-solver call path. Done means this input reports the relevant feature or type-checking error without triggering the region-parameter ICE; add or run a regression test if the surrounding compiler tests identify an appropriate location.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.