missing match arms diagnostic

This commit is contained in:
Josh Mcguigan 2020-03-24 04:40:58 -07:00
parent b7e5d94bda
commit 8c378af721
12 changed files with 1048 additions and 11 deletions

View file

@ -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<ast::MatchArmList>,
}
impl Diagnostic for MissingMatchArms {
fn message(&self) -> String {
String::from("Missing match arm")
}
fn source(&self) -> InFile<SyntaxNodePtr> {
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,