From 99516bbd67a0018c3c0bf94cb895896857d4263c Mon Sep 17 00:00:00 2001 From: Dawer <7803845+iDawer@users.noreply.github.com> Date: Tue, 1 Jun 2021 17:21:00 +0500 Subject: minor: Avoid eprintln on panic --- crates/hir_ty/src/diagnostics/match_check/usefulness.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'crates/hir_ty/src/diagnostics/match_check/usefulness.rs') diff --git a/crates/hir_ty/src/diagnostics/match_check/usefulness.rs b/crates/hir_ty/src/diagnostics/match_check/usefulness.rs index 83b094a89..bd76a606c 100644 --- a/crates/hir_ty/src/diagnostics/match_check/usefulness.rs +++ b/crates/hir_ty/src/diagnostics/match_check/usefulness.rs @@ -295,7 +295,7 @@ pub(crate) struct MatchCheckCtx<'a> { pub(crate) db: &'a dyn HirDatabase, /// Lowered patterns from arms plus generated by the check. pub(crate) pattern_arena: &'a RefCell, - pub(crate) eprint_panic_context: &'a dyn Fn(), + pub(crate) panic_context: &'a dyn Fn() -> String, } impl<'a> MatchCheckCtx<'a> { @@ -331,8 +331,7 @@ impl<'a> MatchCheckCtx<'a> { #[track_caller] pub(super) fn bug(&self, info: &str) -> ! { - (self.eprint_panic_context)(); - panic!("bug: {}", info); + panic!("bug: {}\n{}", info, (self.panic_context)()); } } -- cgit v1.2.3