@@ -1483,6 +1483,21 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14831483 return ;
14841484 }
14851485
1486+ let ( expected, found) = if label_expression_as_expected {
1487+ // In the case where this is a "forced unit", like
1488+ // `break`, we want to call the `()` "expected"
1489+ // since it is implied by the syntax.
1490+ // (Note: not all force-units work this way.)"
1491+ ( expression_ty, self . merged_ty ( ) )
1492+ } else {
1493+ // Otherwise, the "expected" type for error
1494+ // reporting is the current unification type,
1495+ // which is basically the LUB of the expressions
1496+ // we've seen so far (combined with the expected
1497+ // type)
1498+ ( self . merged_ty ( ) , expression_ty)
1499+ } ;
1500+
14861501 // Handle the actual type unification etc.
14871502 let result = if let Some ( expression) = expression {
14881503 if self . pushed == 0 {
@@ -1530,12 +1545,11 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
15301545 // Another example is `break` with no argument expression.
15311546 assert ! ( expression_ty. is_unit( ) , "if let hack without unit type" ) ;
15321547 fcx. at ( cause, fcx. param_env )
1533- // needed for tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
1534- . eq_exp (
1548+ . eq (
1549+ // needed for tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
15351550 DefineOpaqueTypes :: Yes ,
1536- label_expression_as_expected,
1537- expression_ty,
1538- self . merged_ty ( ) ,
1551+ expected,
1552+ found,
15391553 )
15401554 . map ( |infer_ok| {
15411555 fcx. register_infer_ok_obligations ( infer_ok) ;
@@ -1569,20 +1583,6 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
15691583 fcx. set_tainted_by_errors (
15701584 fcx. dcx ( ) . span_delayed_bug ( cause. span , "coercion error but no error emitted" ) ,
15711585 ) ;
1572- let ( expected, found) = if label_expression_as_expected {
1573- // In the case where this is a "forced unit", like
1574- // `break`, we want to call the `()` "expected"
1575- // since it is implied by the syntax.
1576- // (Note: not all force-units work this way.)"
1577- ( expression_ty, self . merged_ty ( ) )
1578- } else {
1579- // Otherwise, the "expected" type for error
1580- // reporting is the current unification type,
1581- // which is basically the LUB of the expressions
1582- // we've seen so far (combined with the expected
1583- // type)
1584- ( self . merged_ty ( ) , expression_ty)
1585- } ;
15861586 let ( expected, found) = fcx. resolve_vars_if_possible ( ( expected, found) ) ;
15871587
15881588 let mut err;
0 commit comments