aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/diagnostics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir/src/diagnostics.rs')
-rw-r--r--crates/hir/src/diagnostics.rs26
1 files changed, 2 insertions, 24 deletions
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![
35 BreakOutsideOfLoop, 35 BreakOutsideOfLoop,
36 InactiveCode, 36 InactiveCode,
37 MacroError, 37 MacroError,
38 MismatchedArgCount,
38 MissingFields, 39 MissingFields,
39 MissingUnsafe, 40 MissingUnsafe,
40 NoSuchField, 41 NoSuchField,
@@ -143,36 +144,13 @@ impl Diagnostic for ReplaceFilterMapNextWithFindMap {
143 } 144 }
144} 145}
145 146
146// Diagnostic: mismatched-arg-count
147//
148// This diagnostic is triggered if a function is invoked with an incorrect amount of arguments.
149#[derive(Debug)] 147#[derive(Debug)]
150pub struct MismatchedArgCount { 148pub struct MismatchedArgCount {
151 pub file: HirFileId, 149 pub call_expr: InFile<AstPtr<ast::Expr>>,
152 pub call_expr: AstPtr<ast::Expr>,
153 pub expected: usize, 150 pub expected: usize,
154 pub found: usize, 151 pub found: usize,
155} 152}
156 153
157impl Diagnostic for MismatchedArgCount {
158 fn code(&self) -> DiagnosticCode {
159 DiagnosticCode("mismatched-arg-count")
160 }
161 fn message(&self) -> String {
162 let s = if self.expected == 1 { "" } else { "s" };
163 format!("Expected {} argument{}, found {}", self.expected, s, self.found)
164 }
165 fn display_source(&self) -> InFile<SyntaxNodePtr> {
166 InFile { file_id: self.file, value: self.call_expr.clone().into() }
167 }
168 fn as_any(&self) -> &(dyn Any + Send + 'static) {
169 self
170 }
171 fn is_experimental(&self) -> bool {
172 true
173 }
174}
175
176#[derive(Debug)] 154#[derive(Debug)]
177pub struct RemoveThisSemicolon { 155pub struct RemoveThisSemicolon {
178 pub file: HirFileId, 156 pub file: HirFileId,