From 9613f487ae0e8c563caffad4ffdede3296002457 Mon Sep 17 00:00:00 2001 From: lcnr Date: Fri, 20 Sep 2024 14:49:03 +0000 Subject: [PATCH] add comment --- .../rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs index 3887f9c529cd..4d743c051902 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs @@ -157,6 +157,10 @@ pub(in crate::solve) fn evaluate_added_goals_and_make_canonical_response( }, ); + // HACK: We bail with overflow if the response would have too many non-region + // inference variables. This tends to only happen if we encounter a lot of + // ambiguous alias types which get replaced with fresh inference variables + // during generalization. This prevents a hang in nalgebra. let num_non_region_vars = canonical.variables.iter().filter(|c| !c.is_region()).count(); if num_non_region_vars > self.cx().recursion_limit() { return Ok(self.make_ambiguous_response_no_constraints(MaybeCause::Overflow {