mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
insert type vars in function arguments
This commit is contained in:
parent
615aaa4751
commit
c21d09f3cc
3 changed files with 45 additions and 4 deletions
|
@ -1025,7 +1025,8 @@ impl<'a> InferenceContext<'a> {
|
|||
)
|
||||
}
|
||||
};
|
||||
|
||||
// Try to evaluate unevaluated constant, and insert variable if is not possible.
|
||||
let len = self.table.insert_const_vars_shallow(len);
|
||||
TyKind::Array(elem_ty, len).intern(Interner)
|
||||
}
|
||||
|
||||
|
@ -1681,9 +1682,10 @@ impl<'a> InferenceContext<'a> {
|
|||
} else {
|
||||
param_ty
|
||||
};
|
||||
if !coercion_target.is_unknown()
|
||||
&& self.coerce(Some(arg), &ty, &coercion_target).is_err()
|
||||
{
|
||||
// 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() {
|
||||
self.result.type_mismatches.insert(
|
||||
arg.into(),
|
||||
TypeMismatch { expected: coercion_target, actual: ty.clone() },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue