1
Fork 0

Use merged_ty method instead of rewriting it every time

This commit is contained in:
Guillaume Gomez 2022-08-16 15:33:46 +02:00
parent 14a459bf37
commit 1f7d1eae96

View file

@ -1488,14 +1488,14 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
// `break`, we want to call the `()` "expected" // `break`, we want to call the `()` "expected"
// since it is implied by the syntax. // since it is implied by the syntax.
// (Note: not all force-units work this way.)" // (Note: not all force-units work this way.)"
(expression_ty, self.final_ty.unwrap_or(self.expected_ty)) (expression_ty, self.merged_ty())
} else { } else {
// Otherwise, the "expected" type for error // Otherwise, the "expected" type for error
// reporting is the current unification type, // reporting is the current unification type,
// which is basically the LUB of the expressions // which is basically the LUB of the expressions
// we've seen so far (combined with the expected // we've seen so far (combined with the expected
// type) // type)
(self.final_ty.unwrap_or(self.expected_ty), expression_ty) (self.merged_ty(), expression_ty)
}; };
let (expected, found) = fcx.resolve_vars_if_possible((expected, found)); let (expected, found) = fcx.resolve_vars_if_possible((expected, found));