diff --git a/crates/ra_hir_ty/src/_match.rs b/crates/ra_hir_ty/src/_match.rs index f502a92086..02472e0c0e 100644 --- a/crates/ra_hir_ty/src/_match.rs +++ b/crates/ra_hir_ty/src/_match.rs @@ -545,7 +545,7 @@ mod tests { assert_snapshot!( check_diagnostic_message(content), - @"\"{\\n }\": Missing match arm\n" + @"\"()\": Missing match arm\n" ); } diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 3457905e22..8cbce11686 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -65,6 +65,7 @@ impl AstDiagnostic for MissingFields { #[derive(Debug)] pub struct MissingMatchArms { pub file: HirFileId, + pub match_expr: AstPtr, pub arms: AstPtr, } @@ -73,7 +74,7 @@ impl Diagnostic for MissingMatchArms { String::from("Missing match arm") } fn source(&self) -> InFile { - InFile { file_id: self.file, value: self.arms.into() } + InFile { file_id: self.file, value: self.match_expr.into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { self diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index 6efed6f9e2..19323fda12 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -125,9 +125,12 @@ impl<'a, 'b> ExprValidator<'a, 'b> { if let Some(expr) = source_ptr.value.left() { let root = source_ptr.file_syntax(db.upcast()); if let ast::Expr::MatchExpr(match_expr) = expr.to_node(&root) { - if let Some(arms) = match_expr.match_arm_list() { + if let (Some(match_expr), Some(arms)) = + (match_expr.expr(), match_expr.match_arm_list()) + { self.sink.push(MissingMatchArms { file: source_ptr.file_id, + match_expr: AstPtr::new(&match_expr), arms: AstPtr::new(&arms), }) }