@@ -1483,6 +1483,21 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1483
1483
return ;
1484
1484
}
1485
1485
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
+
1486
1501
// Handle the actual type unification etc.
1487
1502
let result = if let Some ( expression) = expression {
1488
1503
if self . pushed == 0 {
@@ -1530,12 +1545,11 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1530
1545
// Another example is `break` with no argument expression.
1531
1546
assert ! ( expression_ty. is_unit( ) , "if let hack without unit type" ) ;
1532
1547
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
1535
1550
DefineOpaqueTypes :: Yes ,
1536
- label_expression_as_expected,
1537
- expression_ty,
1538
- self . merged_ty ( ) ,
1551
+ expected,
1552
+ found,
1539
1553
)
1540
1554
. map ( |infer_ok| {
1541
1555
fcx. register_infer_ok_obligations ( infer_ok) ;
@@ -1569,20 +1583,6 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1569
1583
fcx. set_tainted_by_errors (
1570
1584
fcx. dcx ( ) . span_delayed_bug ( cause. span , "coercion error but no error emitted" ) ,
1571
1585
) ;
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
- } ;
1586
1586
let ( expected, found) = fcx. resolve_vars_if_possible ( ( expected, found) ) ;
1587
1587
1588
1588
let mut err;
0 commit comments