diff options
author | Dawer <[email protected]> | 2021-05-19 14:00:25 +0100 |
---|---|---|
committer | Dawer <[email protected]> | 2021-05-31 20:49:44 +0100 |
commit | e16f413582ea45d6b318337ea2c7838fdc3b82a4 (patch) | |
tree | 2fbd3e339ca0d5d3f05e1d5888e5c530e7c207c7 /crates/hir_ty/src/diagnostics/match_check/usefulness.rs | |
parent | f571b62a13aff662c9d1c17206342479f8529633 (diff) |
eprint panic context
Diffstat (limited to 'crates/hir_ty/src/diagnostics/match_check/usefulness.rs')
-rw-r--r-- | crates/hir_ty/src/diagnostics/match_check/usefulness.rs | 9 |
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 | ||
300 | impl<'a> MatchCheckCtx<'a> { | 301 | impl<'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 | ||