aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/diagnostics.rs26
-rw-r--r--crates/hir/src/lib.rs9
2 files changed, 5 insertions, 30 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,
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 16f862707..c1af5f097 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1176,12 +1176,9 @@ impl Function {
1176 } 1176 }
1177 BodyValidationDiagnostic::MismatchedArgCount { call_expr, expected, found } => { 1177 BodyValidationDiagnostic::MismatchedArgCount { call_expr, expected, found } => {
1178 match source_map.expr_syntax(call_expr) { 1178 match source_map.expr_syntax(call_expr) {
1179 Ok(source_ptr) => sink.push(MismatchedArgCount { 1179 Ok(source_ptr) => acc.push(
1180 file: source_ptr.file_id, 1180 MismatchedArgCount { call_expr: source_ptr, expected, found }.into(),
1181 call_expr: source_ptr.value, 1181 ),
1182 expected,
1183 found,
1184 }),
1185 Err(SyntheticSyntax) => (), 1182 Err(SyntheticSyntax) => (),
1186 } 1183 }
1187 } 1184 }