From e16f413582ea45d6b318337ea2c7838fdc3b82a4 Mon Sep 17 00:00:00 2001 From: Dawer <7803845+iDawer@users.noreply.github.com> Date: Wed, 19 May 2021 18:00:25 +0500 Subject: eprint panic context --- crates/hir_ty/src/diagnostics/expr.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'crates/hir_ty/src/diagnostics/expr.rs') diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 0a7e6ee52..44d5f6b22 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs @@ -357,6 +357,18 @@ impl<'a, 'b> ExprValidator<'a, 'b> { infer: &infer, db, pattern_arena: &pattern_arena, + eprint_panic_context: &|| { + use syntax::AstNode; + if let Ok(scrutinee_sptr) = source_map.expr_syntax(match_expr) { + let root = scrutinee_sptr.file_syntax(db.upcast()); + if let Some(match_ast) = scrutinee_sptr.value.to_node(&root).syntax().parent() { + eprintln!( + "Match checking is about to panic on this expression:\n{}", + match_ast.to_string(), + ); + } + } + }, }; let report = compute_match_usefulness(&cx, &m_arms); -- cgit v1.2.3