Skip to content

Commit 5a219cb

Browse files
committed
bail if there are too many non-region infer vars
1 parent 2b11f26 commit 5a219cb

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)