@@ -1493,6 +1493,21 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1493
1493
return ;
1494
1494
}
1495
1495
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
+
1496
1511
// Handle the actual type unification etc.
1497
1512
let result = if let Some ( expression) = expression {
1498
1513
if self . pushed == 0 {
@@ -1540,12 +1555,11 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1540
1555
// Another example is `break` with no argument expression.
1541
1556
assert ! ( expression_ty. is_unit( ) , "if let hack without unit type" ) ;
1542
1557
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
1545
1560
DefineOpaqueTypes :: Yes ,
1546
- label_expression_as_expected,
1547
- expression_ty,
1548
- self . merged_ty ( ) ,
1561
+ expected,
1562
+ found,
1549
1563
)
1550
1564
. map ( |infer_ok| {
1551
1565
fcx. register_infer_ok_obligations ( infer_ok) ;
@@ -1579,20 +1593,6 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1579
1593
fcx. set_tainted_by_errors (
1580
1594
fcx. dcx ( ) . span_delayed_bug ( cause. span , "coercion error but no error emitted" ) ,
1581
1595
) ;
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
- } ;
1596
1596
let ( expected, found) = fcx. resolve_vars_if_possible ( ( expected, found) ) ;
1597
1597
1598
1598
let mut err;
0 commit comments