internal: refactor remove this semicolon diagnostics

This commit is contained in:
Aleksey Kladov 2021-06-13 20:13:15 +03:00
parent 8d391ec981
commit 74f3cca85a
8 changed files with 71 additions and 83 deletions

View file

@ -39,6 +39,7 @@ diagnostics![
MissingFields,
MissingUnsafe,
NoSuchField,
RemoveThisSemicolon,
UnimplementedBuiltinMacro,
UnresolvedExternCrate,
UnresolvedImport,
@ -153,26 +154,7 @@ pub struct MismatchedArgCount {
#[derive(Debug)]
pub struct RemoveThisSemicolon {
pub file: HirFileId,
pub expr: AstPtr<ast::Expr>,
}
impl Diagnostic for RemoveThisSemicolon {
fn code(&self) -> DiagnosticCode {
DiagnosticCode("remove-this-semicolon")
}
fn message(&self) -> String {
"Remove this semicolon".to_string()
}
fn display_source(&self) -> InFile<SyntaxNodePtr> {
InFile { file_id: self.file, value: self.expr.clone().into() }
}
fn as_any(&self) -> &(dyn Any + Send + 'static) {
self
}
pub expr: InFile<AstPtr<ast::Expr>>,
}
// Diagnostic: missing-ok-or-some-in-tail-expr