Handle impl Trait more correctly

When calling a function, argument-position impl Trait is transparent; same for
return-position impl Trait when inside the function. So in these cases, we need
to represent that type not by `Ty::Opaque`, but by a type variable that can be
unified with whatever flows into there.
This commit is contained in:
Florian Diebold 2019-12-15 18:56:38 +01:00
parent ac961b2614
commit 6e1c2d0df8
3 changed files with 56 additions and 1 deletions

View file

@ -613,6 +613,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
continue;
}
let param_ty = self.insert_vars_for_impl_trait(param_ty);
let param_ty = self.normalize_associated_types_in(param_ty);
self.infer_expr_coerce(arg, &Expectation::has_type(param_ty.clone()));
}