don't bail when encountering many placeholders

This commit is contained in:
lcnr 2024-10-21 17:51:43 +02:00
parent b64b25b99e
commit 919b61a6f4
4 changed files with 21 additions and 15 deletions

View File

@ -173,7 +173,8 @@ where
// causing a coherence error in diesel, see #131969. We still bail with verflow // causing a coherence error in diesel, see #131969. We still bail with verflow
// when later returning from the parent AliasRelate goal. // when later returning from the parent AliasRelate goal.
if !self.is_normalizes_to_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() { if num_non_region_vars > self.cx().recursion_limit() {
debug!(?num_non_region_vars, "too many inference variables -> overflow"); debug!(?num_non_region_vars, "too many inference variables -> overflow");
return Ok(self.make_ambiguous_response_no_constraints(MaybeCause::Overflow { return Ok(self.make_ambiguous_response_no_constraints(MaybeCause::Overflow {

View File

@ -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() {}

View File

@ -1,8 +1,8 @@
//~ ERROR overflow evaluating the requirement `Self: Trait` //@ check-pass
//~^ 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.
//@ compile-flags: -Znext-solver --crate-type=lib //@ 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"] #![recursion_limit = "0"]
trait Trait {} trait Trait {}
impl Trait for u32 {} impl Trait for u32 {}

View File

@ -1,11 +0,0 @@
error[E0275]: overflow evaluating the requirement `Self: Trait`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`)
error[E0275]: overflow evaluating the requirement `Self well-formed`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0275`.