From 8c378af72117e92bc894fd4a79e978ef0d1c0cc7 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Tue, 24 Mar 2020 04:40:58 -0700 Subject: missing match arms diagnostic --- crates/ra_hir_ty/src/diagnostics.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir_ty/src/diagnostics.rs') diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 0f8522021..3457905e2 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -6,7 +6,7 @@ use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr}; use stdx::format_to; -pub use hir_def::diagnostics::UnresolvedModule; +pub use hir_def::{diagnostics::UnresolvedModule, expr::MatchArm}; pub use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; #[derive(Debug)] @@ -62,6 +62,24 @@ impl AstDiagnostic for MissingFields { } } +#[derive(Debug)] +pub struct MissingMatchArms { + pub file: HirFileId, + pub arms: AstPtr, +} + +impl Diagnostic for MissingMatchArms { + fn message(&self) -> String { + String::from("Missing match arm") + } + fn source(&self) -> InFile { + InFile { file_id: self.file, value: self.arms.into() } + } + fn as_any(&self) -> &(dyn Any + Send + 'static) { + self + } +} + #[derive(Debug)] pub struct MissingOkInTailExpr { pub file: HirFileId, -- cgit v1.2.3 From da6752d5f9a18ba58adb6a2e72d30a83532ec8a6 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Mon, 6 Apr 2020 06:55:25 -0700 Subject: missing match arms diagnostic change source to match expression --- crates/ra_hir_ty/src/diagnostics.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir_ty/src/diagnostics.rs') diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 3457905e2..8cbce1168 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 -- cgit v1.2.3