8247: internal: ensure that runaway type-inference doesn't block the main loop r=flodiebold a=matklad

We have a bug where type-checking `per_query_memory_usage` takes a
couple of seconds. It also reveals another bug: our type inference is
not cancellable.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2021-03-29 20:39:36 +00:00 committed by GitHub
commit b3ca06e4fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,6 +119,8 @@ impl<'a> InferenceContext<'a> {
}
fn infer_expr_inner(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
self.db.check_canceled();
let body = Arc::clone(&self.body); // avoid borrow checker problem
let ty = match &body[tgt_expr] {
Expr::Missing => self.err_ty(),