Skip to content

Commit 1b1f865

Browse files
committed
Auto merge of #130617 - lcnr:nalgebra-hang-3, r=<try>
bail if there are too many non-region infer vars in the query response A minimal fix for the hang in nalgebra. If the query response would result in too many distinct non-region inference variables, simply overwrite the result with overflow. This should either happen if the result already has too many distinct type inference variables, or if evaluating the query encountered a lot of ambiguous associated types. In both cases it's straightforward to wait until the aliases are no longer ambiguous and then try again. r? `@compiler-errors`
2 parents 2b11f26 + 5a219cb commit 1b1f865

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs

+7
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ where
157157
},
158158
);
159159

160+
let num_non_region_vars = canonical.variables.iter().filter(|c| !c.is_region()).count();
161+
if num_non_region_vars > self.cx().recursion_limit() {
162+
return Ok(self.make_ambiguous_response_no_constraints(MaybeCause::Overflow {
163+
suggest_increasing_limit: true,
164+
}));
165+
}
166+
160167
Ok(canonical)
161168
}
162169

tests/ui/traits/coherence-alias-hang.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//@ check-pass
2+
//@ revisions: current next
3+
//[next]@ compile-flags: -Znext-solver
24

35
// Regression test for nalgebra hang <https://github.com/rust-lang/rust/issues/130056>.
46

0 commit comments

Comments
 (0)