aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/diagnostics/match_check/usefulness.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/diagnostics/match_check/usefulness.rs')
-rw-r--r--crates/hir_ty/src/diagnostics/match_check/usefulness.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/hir_ty/src/diagnostics/match_check/usefulness.rs b/crates/hir_ty/src/diagnostics/match_check/usefulness.rs
index 44e08b6e9..cb322a3de 100644
--- a/crates/hir_ty/src/diagnostics/match_check/usefulness.rs
+++ b/crates/hir_ty/src/diagnostics/match_check/usefulness.rs
@@ -295,6 +295,7 @@ pub(crate) struct MatchCheckCtx<'a> {
295 pub(crate) db: &'a dyn HirDatabase, 295 pub(crate) db: &'a dyn HirDatabase,
296 /// Lowered patterns from arms plus generated by the check. 296 /// Lowered patterns from arms plus generated by the check.
297 pub(crate) pattern_arena: &'a RefCell<PatternArena>, 297 pub(crate) pattern_arena: &'a RefCell<PatternArena>,
298 pub(crate) eprint_panic_context: &'a dyn Fn(),
298} 299}
299 300
300impl<'a> MatchCheckCtx<'a> { 301impl<'a> MatchCheckCtx<'a> {
@@ -327,6 +328,12 @@ impl<'a> MatchCheckCtx<'a> {
327 pub(super) fn type_of(&self, pat: PatId) -> Ty { 328 pub(super) fn type_of(&self, pat: PatId) -> Ty {
328 self.pattern_arena.borrow()[pat].ty.clone() 329 self.pattern_arena.borrow()[pat].ty.clone()
329 } 330 }
331
332 #[track_caller]
333 pub(super) fn bug(&self, info: &str) -> ! {
334 (self.eprint_panic_context)();
335 panic!("bug: {}", info);
336 }
330} 337}
331 338
332#[derive(Copy, Clone)] 339#[derive(Copy, Clone)]
@@ -737,7 +744,7 @@ impl SubPatSet {
737 } 744 }
738 Seq { subpats: new_subpats } 745 Seq { subpats: new_subpats }
739 } 746 }
740 Alt { .. } => panic!("bug"), 747 Alt { .. } => panic!("bug"), // `self` is a patstack
741 } 748 }
742 } 749 }
743 750