@@ -1387,6 +1387,7 @@ pub(crate) struct CoerceMany<'tcx, 'exprs, E: AsCoercionSite> {
13871387 final_ty : Option < Ty < ' tcx > > ,
13881388 expressions : Expressions < ' tcx , ' exprs , E > ,
13891389 pushed : usize ,
1390+ force_lub : bool ,
13901391}
13911392
13921393/// The type of a `CoerceMany` that is storing up the expressions into
@@ -1416,7 +1417,13 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14161417 }
14171418
14181419 fn make ( expected_ty : Ty < ' tcx > , expressions : Expressions < ' tcx , ' exprs , E > ) -> Self {
1419- CoerceMany { expected_ty, final_ty : None , expressions, pushed : 0 }
1420+ CoerceMany { expected_ty, final_ty : None , expressions, pushed : 0 , force_lub : false }
1421+ }
1422+
1423+ pub ( crate ) fn force_lub ( & mut self ) {
1424+ // Don't accidentally let someone switch this after coercing things
1425+ assert_eq ! ( self . pushed, 0 ) ;
1426+ self . force_lub = true ;
14201427 }
14211428
14221429 /// Returns the "expected type" with which this coercion was
@@ -1529,10 +1536,9 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
15291536
15301537 // Handle the actual type unification etc.
15311538 let result = if let Some ( expression) = expression {
1532- if self . pushed == 0 {
1533- // Special-case the first expression we are coercing.
1534- // To be honest, I'm not entirely sure why we do this.
1535- // We don't allow two-phase borrows, see comment in try_find_coercion_lub for why
1539+ if !self . force_lub && self . pushed == 0 {
1540+ // For this *first* expression, we do *not* use LUB
1541+ // (which `try_find_coercion_lub` does).
15361542 fcx. coerce (
15371543 expression,
15381544 expression_ty,
0 commit comments