diff options
Diffstat (limited to 'crates/hir_ty/src/diagnostics/expr.rs')
-rw-r--r-- | crates/hir_ty/src/diagnostics/expr.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 3efbce773..a2a4d61db 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs | |||
@@ -357,17 +357,20 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
357 | infer: &infer, | 357 | infer: &infer, |
358 | db, | 358 | db, |
359 | pattern_arena: &pattern_arena, | 359 | pattern_arena: &pattern_arena, |
360 | eprint_panic_context: &|| { | 360 | panic_context: &|| { |
361 | use syntax::AstNode; | 361 | use syntax::AstNode; |
362 | if let Ok(scrutinee_sptr) = source_map.expr_syntax(match_expr) { | 362 | let match_expr_text = source_map |
363 | let root = scrutinee_sptr.file_syntax(db.upcast()); | 363 | .expr_syntax(match_expr) |
364 | if let Some(match_ast) = scrutinee_sptr.value.to_node(&root).syntax().parent() { | 364 | .ok() |
365 | eprintln!( | 365 | .and_then(|scrutinee_sptr| { |
366 | "Match checking is about to panic on this expression:\n{}", | 366 | let root = scrutinee_sptr.file_syntax(db.upcast()); |
367 | match_ast.to_string(), | 367 | scrutinee_sptr.value.to_node(&root).syntax().parent() |
368 | ); | 368 | }) |
369 | } | 369 | .map(|node| node.to_string()); |
370 | } | 370 | format!( |
371 | "expression:\n{}", | ||
372 | match_expr_text.as_deref().unwrap_or("<synthesized expr>") | ||
373 | ) | ||
371 | }, | 374 | }, |
372 | }; | 375 | }; |
373 | let report = compute_match_usefulness(&cx, &m_arms); | 376 | let report = compute_match_usefulness(&cx, &m_arms); |