rust-lang / rust-lang/rust-analyzer
panic: `cannot relate bound region: '^1_0.Named(FunctionId("foo")) <= '?0`
Open
Nobody has claimed this yet.
A-lifetimes
A-new-solver
C-bug
I-panic
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
//@ check-pass
trait TraitA<'a> {
type AsA;
}
trait TraitB<'a, 'b> {
type AsB;
}
trait TraitC<'a, 'b, 'c> {}
struct X;
impl<'a, 'b, 'c> TraitC<'a, 'b, 'c> for X {}
struct Y;
impl<'a, 'b> TraitB<'a, 'b> for Y {
type AsB = X;
}
struct Z;
impl<'a> TraitA<'a> for Z {
type AsA = Y;
}
fn foo<T>()
where
for<'a> T: TraitA<'a, AsA: for<'b> TraitB<'a, 'b, AsB: for<'c> TraitC<'a, 'b, 'c>>>,
{
}
fn main() {
foo::<Z>();
}
this compiles with rustc
rust-analyzer analysis-stats . --run-all-ide-things
Database loaded: 560.07ms, 229minstr, 48mb (metadata 285.27ms, 1006kinstr, 150kb; build 29.71ms, 181kinstr, 1920b)
item trees: 1
dependency lines of code: 1_467_433, item trees: 2_948
dependency item stats: traits: 848, impl: 9_686, mods: 3_059, macro calls: 5_580, macro rules: 1_054
Item Tree Collection: 4.11s, 23ginstr, 427mb
Total Statistics:
crates: 1, mods: 1, decls: 10, bodies: 2, adts: 3, consts: 0, signatures: 13, variants: 3
Workspace:
traits: 3, macro_rules macros: 0, proc_macros: 0
lines of code: 37, item trees: 1
usages: traits: 3, impl: 3, mods: 0, macro calls: 0, macro rules: 0
Dependencies:
lines of code: 1_467_433, item trees: 2_948
declarations: traits: 848, impl: 9_686, mods: 3_059, macro calls: 5_580, macro rules: 1_054
Item Collection: 1.55s, 11ginstr, 179mb
Crate lang items: 233.21ms, 2474minstr, 31mb
Expression Store Lowering: 362.99µs, 953kinstr, 19kb
1/2 50% processing: ra::main
thread 'main' (1776853) panicked at src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/region_constraints/mod.rs:448:17:
cannot relate bound region: '^1_0.Named(FunctionId("foo")) <= '?0
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: <hir_ty::next_solver::infer::region_constraints::RegionConstraintCollector>::make_subregion
3: <hir_ty::next_solver::infer::region_constraints::RegionConstraintCollector>::make_eqregion
4: <ra_ap_rustc_type_ir::relate::solver_relating::SolverRelating<hir_ty::next_solver::infer::InferCtxt, hir_ty::next_solver::interner::DbInterner> as ra_ap_rustc_type_ir::relate::TypeRelation<hir_ty::next_solver::interner::DbInterner>>::relate::<hir_ty::next_solver::region::Region>
5: <hir_ty::next_solver::generic_arg::GenericArg as ra_ap_rustc_type_ir::relate::Relate<hir_ty::next_solver::interner::DbInterner>>::relate::<ra_ap_rustc_type_ir::relate::solver_relating::SolverRelating<hir_ty::next_solver::infer::InferCtxt, hir_ty::next_solver::interner::DbInterner>>
6: <ra_ap_rustc_type_ir::relate::solver_relating::SolverRelating<hir_ty::next_solver::infer::InferCtxt, hir_ty::next_solver::interner::DbInterner> as ra_ap_rustc_type_ir::relate::TypeRelation<hir_ty::next_solver::interner::DbInterner>>::relate_with_variance::<hir_ty::next_solver::generic_arg::GenericArg>
7: <core::result::Result<hir_ty::next_solver::generic_arg::GenericArg, ra_ap_rustc_type_ir::error::TypeError<hir_ty::next_solver::interner::DbInterner>> as ra_ap_rustc_type_ir::interner::CollectAndApply<hir_ty::next_solver::generic_arg::GenericArg, hir_ty::next_solver::generic_arg::GenericArgs>>::collect_and_apply::<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::copied::Copied<core::slice::iter::Iter<hir_ty::next_solver::generic_arg::GenericArg>>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<hir_ty::next_solver::generic_arg::GenericArg>>>, ra_ap_rustc_type_ir::relate::relate_args_invariantly<hir_ty::next_solver::interner::DbInterner, ra_ap_rustc_type_ir::relate::solver_relating::SolverRelating<hir_ty::next_solver::infer::InferCtxt, hir_ty::next_solver::interner::DbInterner>>::{closure#0}>, <hir_ty::next_solver::generic_arg::GenericArgs>::new_from_iter<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::copied::Copied<core::slice::iter::Iter<hir_ty::next_solver::generic_arg::GenericArg>>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<hir_ty::next_solver::generic_arg::GenericArg>>>, ra_ap_rustc_type_ir::relate::relate_args_invariantly<hir_ty::next_solver::interner::DbInterner, ra_ap_rustc_type_ir::relate::solver_relating::SolverRelating<hir_ty::next_solver::infer::InferCtxt, hir_ty::next_solver::interner::DbInterner>>::{closure#0}>, core::result::Result<hir_ty::next_solver::generic_arg::GenericArg, ra_ap_rustc_type_ir::error::TypeError<hir_ty::next_solver::interner::DbInterner>>>::{closure#0}>
8: <hir_ty::next_solver::infer::InferCtxt as ra_ap_rustc_type_ir::relate::solver_relating::RelateExt>::relate::<ra_ap_rustc_type_ir::predicate::TraitRef<hir_ty::next_solver::interner::DbInterner>>
9: <ra_ap_rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<hir_ty::next_solver::solver::SolverContext, hir_ty::next_solver::interner::DbInterner>>::eq::<ra_ap_rustc_type_ir::predicate::TraitRef<hir_ty::next_solver::interner::DbInterner>>
10: <ra_ap_rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<hir_ty::next_solver::solver::SolverContext, hir_ty::next_solver::interner::DbInterner>>::assemble_impl_candidates::<ra_ap_rustc_type_ir::predicate::TraitPredicate<hir_ty::next_solver::interner::DbInterner>>::{closure#0}
11: <hir_ty::next_solver::interner::DbInterner as ra_ap_rustc_type_ir::interner::Interner>::for_each_relevant_impl::<<ra_ap_rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<hir_ty::next_solver::solver::SolverContext, hir_ty::next_solver::interner::DbInterner>>::assemble_impl_candidates<ra_ap_rustc_type_ir::predicate::TraitPredicate<hir_ty::next_solver::interner::DbInterner>>::{closure#0}>::{closure#0}::{closure#1}
12: <hir_ty::method_resolution::TraitImpls>::for_each_crate_and_block_trait_and_type
13: <hir_ty::next_solver::interner::DbInterner as ra_ap_rustc_type_ir::interner::Interner>::for_each_relevant_impl::<<ra_ap_rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<hir_ty::next_solver::solver::SolverContext, hir_ty::next_solver::interner::DbInterner>>::assemble_impl_candidates<ra_ap_rustc_type_ir::predicate::TraitPredicate<hir_ty::next_solver::interner::DbInterner>>::{closure#0}>::{closure#0}
14: <ra_ap_rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<hir_ty::next_solver::solver::SolverContext, hir_ty::next_solver::interner::DbInterner>>::compute_trait_goal
15: <ra_ap_rustc_type_ir::search_graph::SearchGraph<ra_ap_rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<hir_ty::next_solver::solver::SolverContext>, hir_ty::next_solver::interner::DbInterner>>::evaluate_goal_in_task
16: <ra_ap_rustc_type_ir::search_graph::SearchGraph<ra_ap_rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<hir_ty::next_solver::solver::SolverContext>, hir_ty::next_solver::interner::DbInterner>>::evaluate_goal
17: <ra_ap_rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<hir_ty::next_solver::solver::SolverContext, hir_ty::next_solver::interner::DbInterner>>::evaluate_goal_raw
18: <ra_ap_rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<hir_ty::next_solver::solver::SolverContext, hir_ty::next_solver::interner::DbInterner>>::evaluate_goal
19: <hir_ty::next_solver::solver::SolverContext as ra_ap_rustc_next_trait_solver::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal
20: <hir_ty::next_solver::fulfill::FulfillmentCtxt>::try_evaluate_obligations
21: <hir_ty::infer::InferenceContext>::check_call_arguments
22: <hir_ty::infer::InferenceContext>::infer_call
23: <hir_ty::infer::InferenceContext>::infer_expr_inner
24: <hir_ty::infer::InferenceContext>::infer_expr_inner
25: <hir_ty::infer::InferenceContext>::infer_return
26: hir_ty::infer::infer_query_with_inspect
27: <salsa::function::IngredientImpl<<hir_ty::infer::InferenceResult>::for_body::_::for_body__Configuration_>>::execute
28: <salsa::attach::Attached>::attach::<dyn hir_ty::db::HirDatabase, &hir_ty::infer::InferenceResult, <hir_ty::infer::InferenceResult>::for_body::for_body_::{closure#0}>
29: <rust_analyzer::cli::flags::AnalysisStats>::run_inference
30: <rust_analyzer::cli::flags::AnalysisStats>::run::{closure#3}
31: <rust_analyzer::cli::flags::AnalysisStats>::run
32: rust_analyzer::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
infer panicked for ra::main: cannot relate bound region: '^1_0.Named(FunctionId("foo")) <= '?0
exprs: 1, ??ty: 0 (0%), ?ty: 0 (0%), !ty: 0
pats: 0, ??ty: 0 (100%), ?ty: 0 (100%), !ty: 0
panics: 1
Inference: 197.48ms, 1408minstr, 40mb
2/2 100% mir lowering: ra::main2026-07-29T18:23:25.854038858+02:00 WARN Propagating panic for cycle head that panicked in an earlier execution in that revision
rust-analyzer 1.99.0-nightly (26ae60a 2026-07-28)
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 reproducer in the issue and run rust-analyzer analysis-stats . --run-all-ide-things. Read src/tools/rust-analyzer/crates/hir-ty/src/next_solver/infer/region_constraints/mod.rs around RegionConstraintCollector::make_subregion and follow the reported inference path. Done means the example completes without the bound-region panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100