Skip to content

Commit

Permalink
don't bail when encountering many placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Oct 21, 2024
1 parent b64b25b commit 919b61a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ where
// causing a coherence error in diesel, see #131969. We still bail with verflow
// when later returning from the parent AliasRelate goal.
if !self.is_normalizes_to_goal {
let num_non_region_vars = canonical.variables.iter().filter(|c| !c.is_region()).count();
let num_non_region_vars =
canonical.variables.iter().filter(|c| !c.is_region() && c.is_existential()).count();
if num_non_region_vars > self.cx().recursion_limit() {
debug!(?num_non_region_vars, "too many inference variables -> overflow");
return Ok(self.make_ambiguous_response_no_constraints(MaybeCause::Overflow {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//@ compile-flags: -Znext-solver
//@ check-pass

// When canonicalizing responses, we bail if there are too many inference variables.
// We previously also counted placeholders, which is incorrect.
#![recursion_limit = "8"]

fn foo<T>() {}

fn bar<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>() {
// The query response will contain 10 placeholders, which previously
// caused us to bail here.
foo::<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)>();
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//~ ERROR overflow evaluating the requirement `Self: Trait`
//~^ ERROR overflow evaluating the requirement `Self well-formed`
// This is a non-regression test for issue #115351, where a recursion limit of 0 caused an ICE.
//@ check-pass
//@ compile-flags: -Znext-solver --crate-type=lib

// This is a non-regression test for issue #115351, where a recursion limit of 0 caused an ICE.

#![recursion_limit = "0"]
trait Trait {}
impl Trait for u32 {}

This file was deleted.

0 comments on commit 919b61a

Please sign in to comment.