Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer/expr.rs')
-rw-r--r--crates/hir-ty/src/infer/expr.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/hir-ty/src/infer/expr.rs b/crates/hir-ty/src/infer/expr.rs
index 3d762b174a..f5eb37f427 100644
--- a/crates/hir-ty/src/infer/expr.rs
+++ b/crates/hir-ty/src/infer/expr.rs
@@ -1759,13 +1759,14 @@ impl InferenceContext<'_> {
skip_indices: &[u32],
is_varargs: bool,
) {
- if args.len() != param_tys.len() + skip_indices.len() && !is_varargs {
+ let arg_count_mismatch = args.len() != param_tys.len() + skip_indices.len() && !is_varargs;
+ if arg_count_mismatch {
self.push_diagnostic(InferenceDiagnostic::MismatchedArgCount {
call_expr: expr,
expected: param_tys.len() + skip_indices.len(),
found: args.len(),
});
- }
+ };
// Quoting https://github.com/rust-lang/rust/blob/6ef275e6c3cb1384ec78128eceeb4963ff788dca/src/librustc_typeck/check/mod.rs#L3325 --
// We do this in a pretty awful way: first we type-check any arguments
@@ -1819,7 +1820,7 @@ impl InferenceContext<'_> {
// The function signature may contain some unknown types, so we need to insert
// type vars here to avoid type mismatch false positive.
let coercion_target = self.insert_type_vars(coercion_target);
- if self.coerce(Some(arg), &ty, &coercion_target).is_err() {
+ if self.coerce(Some(arg), &ty, &coercion_target).is_err() && !arg_count_mismatch {
self.result.type_mismatches.insert(
arg.into(),
TypeMismatch { expected: coercion_target, actual: ty.clone() },