@@ -1479,6 +1479,21 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1479
1479
return ;
1480
1480
}
1481
1481
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
+
1482
1497
// Handle the actual type unification etc.
1483
1498
let result = if let Some ( expression) = expression {
1484
1499
if self . pushed == 0 {
@@ -1526,12 +1541,11 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1526
1541
// Another example is `break` with no argument expression.
1527
1542
assert ! ( expression_ty. is_unit( ) , "if let hack without unit type" ) ;
1528
1543
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
1531
1546
DefineOpaqueTypes :: Yes ,
1532
- label_expression_as_expected,
1533
- expression_ty,
1534
- self . merged_ty ( ) ,
1547
+ expected,
1548
+ found,
1535
1549
)
1536
1550
. map ( |infer_ok| {
1537
1551
fcx. register_infer_ok_obligations ( infer_ok) ;
@@ -1565,20 +1579,6 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1565
1579
fcx. set_tainted_by_errors (
1566
1580
fcx. dcx ( ) . span_delayed_bug ( cause. span , "coercion error but no error emitted" ) ,
1567
1581
) ;
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
- } ;
1582
1582
let ( expected, found) = fcx. resolve_vars_if_possible ( ( expected, found) ) ;
1583
1583
1584
1584
let mut err;
0 commit comments