From 74f3cca85ab870614f314c6180e2fbb883ad4fe3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 13 Jun 2021 20:13:15 +0300 Subject: internal: refactor remove this semicolon diagnostics --- crates/hir/src/diagnostics.rs | 22 ++-------------------- crates/hir/src/lib.rs | 5 +---- 2 files changed, 3 insertions(+), 24 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index f839616ce..b144bb335 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs @@ -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, -} - -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 { - InFile { file_id: self.file, value: self.expr.clone().into() } - } - - fn as_any(&self) -> &(dyn Any + Send + 'static) { - self - } + pub expr: InFile>, } // Diagnostic: missing-ok-or-some-in-tail-expr diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index c1af5f097..cb9bf60b8 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1184,10 +1184,7 @@ impl Function { } BodyValidationDiagnostic::RemoveThisSemicolon { expr } => { match source_map.expr_syntax(expr) { - Ok(source_ptr) => sink.push(RemoveThisSemicolon { - file: source_ptr.file_id, - expr: source_ptr.value, - }), + Ok(expr) => acc.push(RemoveThisSemicolon { expr }.into()), Err(SyntheticSyntax) => (), } } -- cgit v1.2.3