@@ -1479,6 +1479,21 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14791479 return ;
14801480 }
14811481
1482+ let ( expected, found) = if label_expression_as_expected {
1483+ // In the case where this is a "forced unit", like
1484+ // `break`, we want to call the `()` "expected"
1485+ // since it is implied by the syntax.
1486+ // (Note: not all force-units work this way.)"
1487+ ( expression_ty, self . merged_ty ( ) )
1488+ } else {
1489+ // Otherwise, the "expected" type for error
1490+ // reporting is the current unification type,
1491+ // which is basically the LUB of the expressions
1492+ // we've seen so far (combined with the expected
1493+ // type)
1494+ ( self . merged_ty ( ) , expression_ty)
1495+ } ;
1496+
14821497 // Handle the actual type unification etc.
14831498 let result = if let Some ( expression) = expression {
14841499 if self . pushed == 0 {
@@ -1526,12 +1541,11 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
15261541 // Another example is `break` with no argument expression.
15271542 assert ! ( expression_ty. is_unit( ) , "if let hack without unit type" ) ;
15281543 fcx. at ( cause, fcx. param_env )
1529- // needed for tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
1530- . eq_exp (
1544+ . eq (
1545+ // needed for tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
15311546 DefineOpaqueTypes :: Yes ,
1532- label_expression_as_expected,
1533- expression_ty,
1534- self . merged_ty ( ) ,
1547+ expected,
1548+ found,
15351549 )
15361550 . map ( |infer_ok| {
15371551 fcx. register_infer_ok_obligations ( infer_ok) ;
@@ -1565,20 +1579,6 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
15651579 fcx. set_tainted_by_errors (
15661580 fcx. dcx ( ) . span_delayed_bug ( cause. span , "coercion error but no error emitted" ) ,
15671581 ) ;
1568- let ( expected, found) = if label_expression_as_expected {
1569- // In the case where this is a "forced unit", like
1570- // `break`, we want to call the `()` "expected"
1571- // since it is implied by the syntax.
1572- // (Note: not all force-units work this way.)"
1573- ( expression_ty, self . merged_ty ( ) )
1574- } else {
1575- // Otherwise, the "expected" type for error
1576- // reporting is the current unification type,
1577- // which is basically the LUB of the expressions
1578- // we've seen so far (combined with the expected
1579- // type)
1580- ( self . merged_ty ( ) , expression_ty)
1581- } ;
15821582 let ( expected, found) = fcx. resolve_vars_if_possible ( ( expected, found) ) ;
15831583
15841584 let mut err;
0 commit comments