@@ -1244,6 +1244,41 @@ impl<'ctx> MirLowerCtx<'ctx> {
12441244 }
12451245 }
12461246
1247+ fn lower_destructing_assignment (
1248+ & mut self ,
1249+ mut current : BasicBlockId ,
1250+ lhs : ExprId ,
1251+ rhs : Place ,
1252+ span : MirSpan ,
1253+ ) -> Result < Option < BasicBlockId > > {
1254+ match & self . body . exprs [ lhs] {
1255+ Expr :: Tuple { exprs, is_assignee_expr : _ } => {
1256+ for ( i, expr) in exprs. iter ( ) . enumerate ( ) {
1257+ let Some ( c) = self . lower_destructing_assignment (
1258+ current,
1259+ * expr,
1260+ rhs. project ( ProjectionElem :: TupleOrClosureField ( i) ) ,
1261+ span,
1262+ ) ? else {
1263+ return Ok ( None ) ;
1264+ } ;
1265+ current = c;
1266+ }
1267+ Ok ( Some ( current) )
1268+ }
1269+ Expr :: Underscore => Ok ( Some ( current) ) ,
1270+ _ => {
1271+ let Some ( ( lhs_place, current) ) =
1272+ self . lower_expr_as_place ( current, lhs, false ) ?
1273+ else {
1274+ return Ok ( None ) ;
1275+ } ;
1276+ self . push_assignment ( current, lhs_place, Operand :: Copy ( rhs) . into ( ) , span) ;
1277+ Ok ( Some ( current) )
1278+ }
1279+ }
1280+ }
1281+
12471282 fn lower_assignment (
12481283 & mut self ,
12491284 current : BasicBlockId ,
@@ -1259,6 +1294,15 @@ impl<'ctx> MirLowerCtx<'ctx> {
12591294 if matches ! ( & self . body. exprs[ lhs] , Expr :: Underscore ) {
12601295 return Ok ( Some ( current) ) ;
12611296 }
1297+ if matches ! (
1298+ & self . body. exprs[ lhs] ,
1299+ Expr :: Tuple { .. } | Expr :: RecordLit { .. } | Expr :: Call { .. }
1300+ ) {
1301+ let temp = self . temp ( self . expr_ty_after_adjustments ( rhs) , current, rhs. into ( ) ) ?;
1302+ let temp = Place :: from ( temp) ;
1303+ self . push_assignment ( current, temp. clone ( ) , rhs_op. into ( ) , span) ;
1304+ return self . lower_destructing_assignment ( current, lhs, temp, span) ;
1305+ }
12621306 let Some ( ( lhs_place, current) ) =
12631307 self . lower_expr_as_place ( current, lhs, false ) ?
12641308 else {
0 commit comments