aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty')
-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) {