aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_ty/src/expr.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs
index f36304669..53828d29d 100644
--- a/crates/ra_hir_ty/src/expr.rs
+++ b/crates/ra_hir_ty/src/expr.rs
@@ -157,18 +157,23 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
157 return Some(()); 157 return Some(());
158 } 158 }
159 159
160 let is_method_call;
160 let (callee, args) = match expr { 161 let (callee, args) = match expr {
161 Expr::Call { callee, args } => { 162 Expr::Call { callee, args } => {
163 is_method_call = false;
162 let callee = &self.infer.type_of_expr[*callee]; 164 let callee = &self.infer.type_of_expr[*callee];
163 let (callable, _) = callee.as_callable()?; 165 let (callable, _) = callee.as_callable()?;
164 let callee = match callable { 166 let callee = match callable {
165 CallableDef::FunctionId(func) => func, 167 CallableDef::FunctionId(func) => func,
168
169 // FIXME: Handle tuple struct/variant constructor calls.
166 _ => return None, 170 _ => return None,
167 }; 171 };
168 172
169 (callee, args.clone()) 173 (callee, args.clone())
170 } 174 }
171 Expr::MethodCall { receiver, args, .. } => { 175 Expr::MethodCall { receiver, args, .. } => {
176 is_method_call = true;
172 let callee = self.infer.method_resolution(call_id)?; 177 let callee = self.infer.method_resolution(call_id)?;
173 let mut args = args.clone(); 178 let mut args = args.clone();
174 args.insert(0, *receiver); 179 args.insert(0, *receiver);
@@ -182,15 +187,19 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
182 let params = ast.value.param_list()?; 187 let params = ast.value.param_list()?;
183 188
184 let mut param_count = params.params().count(); 189 let mut param_count = params.params().count();
190 let mut arg_count = args.len();
191
185 if params.self_param().is_some() { 192 if params.self_param().is_some() {
186 param_count += 1; 193 param_count += 1;
187 } 194 }
188 let arg_count = args.len();
189 195
190 if arg_count != param_count { 196 if arg_count != param_count {
191 let (_, source_map): (Arc<Body>, Arc<BodySourceMap>) = 197 let (_, source_map) = db.body_with_source_map(self.func.into());
192 db.body_with_source_map(self.func.into());
193 if let Ok(source_ptr) = source_map.expr_syntax(call_id) { 198 if let Ok(source_ptr) = source_map.expr_syntax(call_id) {
199 if is_method_call {
200 param_count -= 1;
201 arg_count -= 1;
202 }
194 self.sink.push(MismatchedArgCount { 203 self.sink.push(MismatchedArgCount {
195 file: source_ptr.file_id, 204 file: source_ptr.file_id,
196 call_expr: source_ptr.value, 205 call_expr: source_ptr.value,