aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/diagnostics
diff options
context:
space:
mode:
authorDawer <[email protected]>2021-05-06 09:32:35 +0100
committerDawer <[email protected]>2021-05-31 20:03:47 +0100
commite50ce67631bc8f8e28042112a924b73c6081dc71 (patch)
tree28efd509d92bdd9fa33b072c873d1b5268eb32ee /crates/hir_ty/src/diagnostics
parentde6f430140a49e3ecf34dcb914326bb5b9789772 (diff)
Do not do match check if lowering failed.
Diffstat (limited to 'crates/hir_ty/src/diagnostics')
-rw-r--r--crates/hir_ty/src/diagnostics/expr.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs
index 8f141a308..929c4a9cc 100644
--- a/crates/hir_ty/src/diagnostics/expr.rs
+++ b/crates/hir_ty/src/diagnostics/expr.rs
@@ -388,14 +388,26 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
388 388
389 let pattern_arena = RefCell::new(PatternArena::new()); 389 let pattern_arena = RefCell::new(PatternArena::new());
390 390
391 let mut have_errors = false;
391 let m_arms: Vec<_> = arms 392 let m_arms: Vec<_> = arms
392 .iter() 393 .iter()
393 .map(|arm| usefulness::MatchArm { 394 .map(|arm| usefulness::MatchArm {
394 pat: self.lower_pattern(arm.pat, &mut pattern_arena.borrow_mut(), db, &body), 395 pat: self.lower_pattern(
396 arm.pat,
397 &mut pattern_arena.borrow_mut(),
398 db,
399 &body,
400 &mut have_errors,
401 ),
395 has_guard: arm.guard.is_some(), 402 has_guard: arm.guard.is_some(),
396 }) 403 })
397 .collect(); 404 .collect();
398 405
406 // Bail out early if lowering failed.
407 if have_errors {
408 return;
409 }
410
399 let cx = usefulness::MatchCheckCtx { 411 let cx = usefulness::MatchCheckCtx {
400 module: self.owner.module(db.upcast()), 412 module: self.owner.module(db.upcast()),
401 match_expr, 413 match_expr,
@@ -442,10 +454,15 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
442 pattern_arena: &mut PatternArena, 454 pattern_arena: &mut PatternArena,
443 db: &dyn HirDatabase, 455 db: &dyn HirDatabase,
444 body: &Body, 456 body: &Body,
457 have_errors: &mut bool,
445 ) -> pattern::PatId { 458 ) -> pattern::PatId {
446 let mut patcx = pattern::PatCtxt::new(db, &self.infer, body); 459 let mut patcx = pattern::PatCtxt::new(db, &self.infer, body);
447 let pattern = patcx.lower_pattern(pat); 460 let pattern = patcx.lower_pattern(pat);
448 pattern_arena.alloc(expand_pattern(pattern)) 461 let pattern = pattern_arena.alloc(expand_pattern(pattern));
462 if !patcx.errors.is_empty() {
463 *have_errors = true;
464 }
465 pattern
449 } 466 }
450 467
451 fn validate_results_in_tail_expr(&mut self, body_id: ExprId, id: ExprId, db: &dyn HirDatabase) { 468 fn validate_results_in_tail_expr(&mut self, body_id: ExprId, id: ExprId, db: &dyn HirDatabase) {