From 8d391ec981562785ec92ce3afe950972c523f925 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 13 Jun 2021 20:06:25 +0300 Subject: internal: refactor mismatched args count diagnostic --- crates/hir/src/diagnostics.rs | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'crates/hir/src/diagnostics.rs') diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index f7bf63215..f839616ce 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs @@ -35,6 +35,7 @@ diagnostics![ BreakOutsideOfLoop, InactiveCode, MacroError, + MismatchedArgCount, MissingFields, MissingUnsafe, NoSuchField, @@ -143,36 +144,13 @@ impl Diagnostic for ReplaceFilterMapNextWithFindMap { } } -// Diagnostic: mismatched-arg-count -// -// This diagnostic is triggered if a function is invoked with an incorrect amount of arguments. #[derive(Debug)] pub struct MismatchedArgCount { - pub file: HirFileId, - pub call_expr: AstPtr, + pub call_expr: InFile>, pub expected: usize, pub found: usize, } -impl Diagnostic for MismatchedArgCount { - fn code(&self) -> DiagnosticCode { - DiagnosticCode("mismatched-arg-count") - } - fn message(&self) -> String { - let s = if self.expected == 1 { "" } else { "s" }; - format!("Expected {} argument{}, found {}", self.expected, s, self.found) - } - fn display_source(&self) -> InFile { - InFile { file_id: self.file, value: self.call_expr.clone().into() } - } - fn as_any(&self) -> &(dyn Any + Send + 'static) { - self - } - fn is_experimental(&self) -> bool { - true - } -} - #[derive(Debug)] pub struct RemoveThisSemicolon { pub file: HirFileId, -- cgit v1.2.3