[ICE]: `cannot relate bound region`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
auto-reduced (treereduce-rust):
//@compile-flags: -Znext-solver=globally
pub struct Foo;
fn foo(foos: Option<Foo>) {
let foos = foos.as_ref();
Bar.bar(foos);
}
struct Bar;
impl Bar {
pub fn bar<I>(&self, iter: I)
where
for<'a> &'a I: Trait<Assoc = &'a Foo>,
{
}
}
trait Trait {
type Assoc;
}
impl Trait for Option<Foo> {
type Assoc = Foo;
}
impl<'a> Trait for Option<&'a Foo> {
type Assoc = &'a Foo;
}
impl<'a, 'b> Trait for &'a Option<&'b Foo> {
type Assoc = &'b Foo;
}
pub fn main() {}
original:
pub struct Foo;
fn foo(foos: Option<Foo>) {
let foos = foos.as_ref();
Bar.bar(foos);
}
struct Bar;
impl Bar {
pub fn bar<I>(&self, iter: I)
where
for<'a> &'a I: Trait<Assoc = &'a Foo>,
{
}
}
trait Trait {
type Assoc;
}
impl Trait for Option<Foo> {
type Assoc = Foo;
}
impl<'a> Trait for Option<&'a Foo> {
type Assoc = &'a Foo;
}
impl<'a, 'b> Trait for &'a Option<&'b Foo> {
type Assoc = &'b Foo;
}
impl<'a> Trait for &'a i32 {
type Assoc = &'a Foo;
}
fn main() {}
Version information
rustc 1.95.0-nightly (621d76794 2026-01-18)
binary: rustc
commit-hash: 621d76794c76fc21c0a6151fbc090120e0230a91
commit-date: 2026-01-18
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8
Possibly related line of code:
https://github.com/rust-lang/rust/blob/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_infer/src/infer/region_constraints/mod.rs#L468-L480
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally
Program output
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.KRLumYtswIX5/rustc_testrunner_tmpdir_reporting.UtxgZ44lD4Ij/mvce.rs:30:2
|
30 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.KRLumYtswIX5/rustc_testrunner_tmpdir_reporting.UtxgZ44lD4Ij/mvce.rs`
error: internal compiler error: /rustc-dev/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_infer/src/infer/region_constraints/mod.rs:474:17: cannot relate bound region: '^0.Named(DefId(0:11 ~ mvce[a621]::{impl#0}::bar::'a)) <= '?1
thread 'rustc' (1321978) panicked at /rustc-dev/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_infer/src/infer/region_constraints/mod.rs:474:17:
Box<dyn Any>
stack backtrace:
0: 0x7f0b6f233fd3 - <<std[287527946f71f0bc]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[7477a31a1a34cc49]::fmt::Display>::fmt
1: 0x7f0b6f80e2c8 - core[7477a31a1a34cc49]::fmt::write
2: 0x7f0b6f24a9c6 - <std[287527946f71f0bc]::sys::stdio::unix::Stderr as std[287527946f71f0bc]::io::Write>::write_fmt
3: 0x7f0b6f20a048 - std[287527946f71f0bc]::panicking::default_hook::{closure#0}
4: 0x7f0b6f227703 - std[287527946f71f0bc]::panicking::default_hook
5: 0x7f0b6e1fbb8a - std[287527946f71f0bc]::panicking::update_hook::<alloc[979041e9952e771b]::boxed::Box<rustc_driver_impl[517260a07841a630]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f0b6f2279e2 - std[287527946f71f0bc]::panicking::panic_with_hook
7: 0x7f0b6e238bc1 - std[287527946f71f0bc]::panicking::begin_panic::<rustc_errors[26c9ea40265c581b]::ExplicitBug>::{closure#0}
8: 0x7f0b6e228fe6 - std[287527946f71f0bc]::sys::backtrace::__rust_end_short_backtrace::<std[287527946f71f0bc]::panicking::begin_panic<rustc_errors[26c9ea40265c581b]::ExplicitBug>::{closure#0}, !>
9: 0x7f0b6e2264b9 - std[287527946f71f0bc]::panicking::begin_panic::<rustc_errors[26c9ea40265c581b]::ExplicitBug>
10: 0x7f0b6e256901 - <rustc_errors[26c9ea40265c581b]::diagnostic::BugAbort as rustc_errors[26c9ea40265c581b]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7f0b6e7e492c - <rustc_errors[26c9ea40265c581b]::DiagCtxtHandle>::span_bug::<rustc_span[851f35e07e3c2dd4]::span_encoding::Span, alloc[979041e9952e771b]::string::String>
12: 0x7f0b6e8074d6 - rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt::<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}
13: 0x7f0b6e807682 - rustc_middle[725063e074f29df]::ty::context::tls::with_opt::<rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x7f0b6e7f8cab - rustc_middle[725063e074f29df]::ty::context::tls::with_context_opt::<rustc_middle[725063e074f29df]::ty::context::tls::with_opt<rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x7f0b6c0afa68 - rustc_middle[725063e074f29df]::util::bug::span_bug_fmt::<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>
16: 0x7f0b6fe7cfb7 - <rustc_infer[5a785d1c27494969]::infer::region_constraints::RegionConstraintCollector>::make_eqregion
17: 0x7f0b6fe688f3 - rustc_type_ir[b93cf349b3a4f34d]::relate::structurally_relate_tys::<rustc_middle[725063e074f29df]::ty::context::TyCtxt, rustc_type_ir[b93cf349b3a4f34d]::relate::solver_relating::SolverRelating<rustc_infer[5a785d1c27494969]::infer::InferCtxt, rustc_middle[725063e074f29df]::ty::context::TyCtxt>>
18: 0x7f0b6fe67098 - <rustc_type_ir[b93cf349b3a4f34d]::relate::solver_relating::SolverRelating<rustc_infer[5a785d1c27494969]::infer::InferCtxt, rustc_middle[725063e074f29df]::ty::context::TyCtxt> as rustc_type_ir[b93cf349b3a4f34d]::relate::TypeRelation<rustc_middle[725063e074f29df]::ty::context::TyCtxt>>::tys
19: 0x7f0b6fe66305 - <rustc_infer[5a785d1c27494969]::infer::InferCtxt as rustc_type_ir[b93cf349b3a4f34d]::relate::solver_relating::RelateExt>::relate::<rustc_middle[725063e074f29df]::ty::Ty>
20: 0x7f0b70211c83 - <rustc_trait_selection[9fee51d8a10a777c]::traits::engine::ObligationCtxt>::eq::<rustc_middle[725063e074f29df]::ty::Ty>
21: 0x7f0b6ef3510a - <rustc_trait_selection[9fee51d8a10a777c]::error_reporting::TypeErrCtxt>::point_at_chain::<rustc_span[851f35e07e3c2dd4]::ErrorGuaranteed>
22: 0x7f0b6ef55f43 - <rustc_trait_selection[9fee51d8a10a777c]::error_reporting::TypeErrCtxt>::note_function_argument_obligation::<rustc_span[851f35e07e3c2dd4]::ErrorGuaranteed>
23: 0x7f0b6ef4a6d7 - <rustc_trait_selection[9fee51d8a10a777c]::error_reporting::TypeErrCtxt>::note_obligation_cause_code::<rustc_span[851f35e07e3c2dd4]::ErrorGuaranteed, rustc_middle[725063e074f29df]::ty::predicate::Predicate>
24: 0x7f0b6f00e6d4 - <rustc_trait_selection[9fee51d8a10a777c]::error_reporting::TypeErrCtxt>::note_obligation_cause
25: 0x7f0b6db2659e - <rustc_trait_selection[9fee51d8a10a777c]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
26: 0x7f0b6fbed721 - <rustc_hir_typeck[ed5453188701a25b]::fn_ctxt::FnCtxt>::check_expr_method_call
27: 0x7f0b6fc19963 - <rustc_hir_typeck[ed5453188701a25b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
28: 0x7f0b6fc14ac2 - <rustc_hir_typeck[ed5453188701a25b]::fn_ctxt::FnCtxt>::check_expr_block
29: 0x7f0b6fc1998b - <rustc_hir_typeck[ed5453188701a25b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
30: 0x7f0b6fbfa1a6 - rustc_hir_typeck[ed5453188701a25b]::check::check_fn
31: 0x7f0b705b3d33 - rustc_hir_typeck[ed5453188701a25b]::typeck_with_inspect::{closure#0}
32: 0x7f0b705b26b4 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 8usize]>>
33: 0x7f0b6f95522a - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_data_structures[e0d8483206daafa2]::vec_cache::VecCache<rustc_span[851f35e07e3c2dd4]::def_id::LocalDefId, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[b7e73caa2c2ad9a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
34: 0x7f0b6f954b09 - rustc_query_impl[f20b8284200e680a]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
35: 0x7f0b7033fdb5 - <rustc_middle[725063e074f29df]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[1a80394817eddfdd]::check_crate::{closure#2}>::{closure#0}
36: 0x7f0b7033f7c4 - rustc_hir_analysis[1a80394817eddfdd]::check_crate
37: 0x7f0b6f9493db - rustc_interface[5c48368f5debe80d]::passes::analysis
38: 0x7f0b6f949035 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>
39: 0x7f0b709a4be3 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::SingleCache<rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
40: 0x7f0b709a49ce - rustc_query_impl[f20b8284200e680a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
41: 0x7f0b70b82c11 - <rustc_interface[5c48368f5debe80d]::passes::create_and_enter_global_ctxt<core[7477a31a1a34cc49]::option::Option<rustc_interface[5c48368f5debe80d]::queries::Linker>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[7477a31a1a34cc49]::ops::function::FnOnce<(&rustc_session[eb79e6d3104f29ae]::session::Session, rustc_middle[725063e074f29df]::ty::context::CurrentGcx, alloc[979041e9952e771b]::sync::Arc<rustc_data_structures[e0d8483206daafa2]::jobserver::Proxy>, &std[287527946f71f0bc]::sync::once_lock::OnceLock<rustc_middle[725063e074f29df]::ty::context::GlobalCtxt>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_middle[725063e074f29df]::arena::Arena>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_hir[7eac7792dedc1861]::Arena>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
42: 0x7f0b709f5d34 - rustc_interface[5c48368f5debe80d]::interface::run_compiler::<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}
43: 0x7f0b7095aa3a - std[287527946f71f0bc]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
44: 0x7f0b7095a7fe - <std[287527946f71f0bc]::thread::lifecycle::spawn_unchecked<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7477a31a1a34cc49]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
45: 0x7f0b7095c5c4 - <std[287527946f71f0bc]::sys::thread::unix::Thread>::new::thread_start
46: 0x7f0b6a29698b - <unknown>
47: 0x7f0b6a31a9cc - <unknown>
48: 0x0 - <unknown>
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.95.0-nightly (621d76794 2026-01-18) 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] type-checking `foo`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0601`.
@rustbot label +WG-trait-system-refactor
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reduced Rust program and reproduce it using -Znext-solver=globally. Read compiler/rustc_infer/src/infer/region_constraints/mod.rs around lines 468-480 and trace the make_eqregion path shown in the backtrace; done means the program no longer produces 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
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100