]> git.lizzy.rs Git - rust.git/commitdiff
Merge #8247
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>
Mon, 29 Mar 2021 20:39:36 +0000 (20:39 +0000)
committerGitHub <noreply@github.com>
Mon, 29 Mar 2021 20:39:36 +0000 (20:39 +0000)
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>
crates/hir_ty/src/infer/expr.rs

index e6ede05ca144289878dab272188da978f635a74a..6279aa572c565f8f0bb2c91bc01f0d33a5c15419 100644 (file)
@@ -119,6 +119,8 @@ pub(crate) fn callable_sig(&mut self, ty: &Ty, num_args: usize) -> Option<(Vec<T
     }
 
     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(),