mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Fix deduction of dyn Fn
closure parameter types
This commit is contained in:
parent
13cbe64a59
commit
88a86d4ff9
6 changed files with 139 additions and 21 deletions
|
@ -278,15 +278,13 @@ impl<'a> InferenceContext<'a> {
|
|||
.intern(&Interner);
|
||||
let closure_id = self.db.intern_closure((self.owner, tgt_expr)).into();
|
||||
let closure_ty =
|
||||
TyKind::Closure(closure_id, Substitution::from1(&Interner, sig_ty))
|
||||
TyKind::Closure(closure_id, Substitution::from1(&Interner, sig_ty.clone()))
|
||||
.intern(&Interner);
|
||||
|
||||
// Eagerly try to relate the closure type with the expected
|
||||
// type, otherwise we often won't have enough information to
|
||||
// infer the body.
|
||||
if let Some(t) = expected.only_has_type(&mut self.table) {
|
||||
self.coerce(&closure_ty, &t);
|
||||
}
|
||||
self.deduce_closure_type_from_expectations(&closure_ty, &sig_ty, expected);
|
||||
|
||||
// Now go through the argument patterns
|
||||
for (arg_pat, arg_ty) in args.iter().zip(sig_tys) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue