@@ -1493,6 +1493,21 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14931493 return ;
14941494 }
14951495
1496+ let ( expected, found) = if label_expression_as_expected {
1497+ // In the case where this is a "forced unit", like
1498+ // `break`, we want to call the `()` "expected"
1499+ // since it is implied by the syntax.
1500+ // (Note: not all force-units work this way.)"
1501+ ( expression_ty, self . merged_ty ( ) )
1502+ } else {
1503+ // Otherwise, the "expected" type for error
1504+ // reporting is the current unification type,
1505+ // which is basically the LUB of the expressions
1506+ // we've seen so far (combined with the expected
1507+ // type)
1508+ ( self . merged_ty ( ) , expression_ty)
1509+ } ;
1510+
14961511 // Handle the actual type unification etc.
14971512 let result = if let Some ( expression) = expression {
14981513 if self . pushed == 0 {
@@ -1540,12 +1555,11 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
15401555 // Another example is `break` with no argument expression.
15411556 assert ! ( expression_ty. is_unit( ) , "if let hack without unit type" ) ;
15421557 fcx. at ( cause, fcx. param_env )
1543- // needed for tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
1544- . eq_exp (
1558+ . eq (
1559+ // needed for tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
15451560 DefineOpaqueTypes :: Yes ,
1546- label_expression_as_expected,
1547- expression_ty,
1548- self . merged_ty ( ) ,
1561+ expected,
1562+ found,
15491563 )
15501564 . map ( |infer_ok| {
15511565 fcx. register_infer_ok_obligations ( infer_ok) ;
@@ -1579,20 +1593,6 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
15791593 fcx. set_tainted_by_errors (
15801594 fcx. dcx ( ) . span_delayed_bug ( cause. span , "coercion error but no error emitted" ) ,
15811595 ) ;
1582- let ( expected, found) = if label_expression_as_expected {
1583- // In the case where this is a "forced unit", like
1584- // `break`, we want to call the `()` "expected"
1585- // since it is implied by the syntax.
1586- // (Note: not all force-units work this way.)"
1587- ( expression_ty, self . merged_ty ( ) )
1588- } else {
1589- // Otherwise, the "expected" type for error
1590- // reporting is the current unification type,
1591- // which is basically the LUB of the expressions
1592- // we've seen so far (combined with the expected
1593- // type)
1594- ( self . merged_ty ( ) , expression_ty)
1595- } ;
15961596 let ( expected, found) = fcx. resolve_vars_if_possible ( ( expected, found) ) ;
15971597
15981598 let mut err;
0 commit comments