@@ -387,7 +387,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
387387 current,
388388 place,
389389 ty,
390- vec ! [ ] ,
390+ Box :: new ( [ ] ) ,
391391 expr_id. into ( ) ,
392392 ) ?;
393393 }
@@ -561,7 +561,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
561561 } ;
562562 self . push_assignment ( current, ref_mut_iterator_place. clone ( ) , Rvalue :: Ref ( BorrowKind :: Mut { allow_two_phase_borrow : false } , iterator_place) , expr_id. into ( ) ) ;
563563 self . lower_loop ( current, place, label, expr_id. into ( ) , |this, begin| {
564- let Some ( current) = this. lower_call ( iter_next_fn_op, vec ! [ Operand :: Copy ( ref_mut_iterator_place) ] , option_item_place. clone ( ) , begin, false , expr_id. into ( ) ) ?
564+ let Some ( current) = this. lower_call ( iter_next_fn_op, Box :: new ( [ Operand :: Copy ( ref_mut_iterator_place) ] ) , option_item_place. clone ( ) , begin, false , expr_id. into ( ) ) ?
565565 else {
566566 return Ok ( ( ) ) ;
567567 } ;
@@ -758,8 +758,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
758758 match x {
759759 Some ( x) => x,
760760 None => {
761- let mut p = sp. clone ( ) ;
762- p. projection . push ( ProjectionElem :: Field ( FieldId {
761+ let p = sp. project ( ProjectionElem :: Field ( FieldId {
763762 parent : variant_id,
764763 local_id : LocalFieldId :: from_raw ( RawIdx :: from ( i as u32 ) ) ,
765764 } ) ) ;
@@ -782,10 +781,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
782781 } ;
783782 let local_id =
784783 variant_data. field ( name) . ok_or ( MirLowerError :: UnresolvedField ) ?;
785- let mut place = place;
786- place
787- . projection
788- . push ( PlaceElem :: Field ( FieldId { parent : union_id. into ( ) , local_id } ) ) ;
784+ let place = place. project ( PlaceElem :: Field ( FieldId { parent : union_id. into ( ) , local_id } ) ) ;
789785 self . lower_expr_to_place ( * expr, place, current)
790786 }
791787 }
@@ -826,8 +822,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
826822 let Some ( ( operand, current) ) = self . lower_expr_to_some_operand ( * expr, current) ? else {
827823 return Ok ( None ) ;
828824 } ;
829- let mut p = place;
830- p. projection . push ( ProjectionElem :: Deref ) ;
825+ let p = place. project ( ProjectionElem :: Deref ) ;
831826 self . push_assignment ( current, p, operand. into ( ) , expr_id. into ( ) ) ;
832827 Ok ( Some ( current) )
833828 } ,
@@ -1031,7 +1026,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
10311026 self . push_assignment (
10321027 current,
10331028 place,
1034- Rvalue :: Aggregate ( AggregateKind :: Closure ( ty) , operands) ,
1029+ Rvalue :: Aggregate ( AggregateKind :: Closure ( ty) , operands. into ( ) ) ,
10351030 expr_id. into ( ) ,
10361031 ) ;
10371032 Ok ( Some ( current) )
@@ -1128,11 +1123,11 @@ impl<'ctx> MirLowerCtx<'ctx> {
11281123 let index = name
11291124 . as_tuple_index ( )
11301125 . ok_or ( MirLowerError :: TypeError ( "named field on tuple" ) ) ?;
1131- place. projection . push ( ProjectionElem :: TupleOrClosureField ( index) )
1126+ * place = place . project ( ProjectionElem :: TupleOrClosureField ( index) )
11321127 } else {
11331128 let field =
11341129 self . infer . field_resolution ( expr_id) . ok_or ( MirLowerError :: UnresolvedField ) ?;
1135- place. projection . push ( ProjectionElem :: Field ( field) ) ;
1130+ * place = place . project ( ProjectionElem :: Field ( field) ) ;
11361131 }
11371132 } else {
11381133 not_supported ! ( "" )
@@ -1242,7 +1237,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
12421237 prev_block : BasicBlockId ,
12431238 place : Place ,
12441239 ty : Ty ,
1245- fields : Vec < Operand > ,
1240+ fields : Box < [ Operand ] > ,
12461241 span : MirSpan ,
12471242 ) -> Result < BasicBlockId > {
12481243 let subst = match ty. kind ( Interner ) {
@@ -1280,13 +1275,13 @@ impl<'ctx> MirLowerCtx<'ctx> {
12801275 else {
12811276 return Ok ( None ) ;
12821277 } ;
1283- self . lower_call ( func, args, place, current, is_uninhabited, span)
1278+ self . lower_call ( func, args. into ( ) , place, current, is_uninhabited, span)
12841279 }
12851280
12861281 fn lower_call (
12871282 & mut self ,
12881283 func : Operand ,
1289- args : Vec < Operand > ,
1284+ args : Box < [ Operand ] > ,
12901285 place : Place ,
12911286 current : BasicBlockId ,
12921287 is_uninhabited : bool ,
@@ -1744,12 +1739,13 @@ pub fn mir_body_for_closure_query(
17441739 match r {
17451740 Some ( x) => {
17461741 p. local = closure_local;
1747- let prev_projs =
1748- mem:: replace ( & mut p. projection , vec ! [ PlaceElem :: TupleOrClosureField ( x . 1 ) ] ) ;
1742+ let mut next_projs = vec ! [ PlaceElem :: TupleOrClosureField ( x . 1 ) ] ;
1743+ let prev_projs = mem:: take ( & mut p. projection ) ;
17491744 if x. 0 . kind != CaptureKind :: ByValue {
1750- p . projection . push ( ProjectionElem :: Deref ) ;
1745+ next_projs . push ( ProjectionElem :: Deref ) ;
17511746 }
1752- p. projection . extend ( prev_projs. into_iter ( ) . skip ( x. 0 . place . projections . len ( ) ) ) ;
1747+ next_projs. extend ( prev_projs. iter ( ) . cloned ( ) . skip ( x. 0 . place . projections . len ( ) ) ) ;
1748+ p. projection = next_projs. into ( ) ;
17531749 }
17541750 None => err = Some ( p. clone ( ) ) ,
17551751 }
@@ -1764,6 +1760,7 @@ pub fn mir_body_for_closure_query(
17641760 if let Some ( err) = err {
17651761 return Err ( MirLowerError :: UnresolvedUpvar ( err) ) ;
17661762 }
1763+ ctx. result . shrink_to_fit ( ) ;
17671764 Ok ( Arc :: new ( ctx. result ) )
17681765}
17691766
@@ -1780,7 +1777,8 @@ pub fn mir_body_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Result<Arc<Mi
17801777 } ) ;
17811778 let body = db. body ( def) ;
17821779 let infer = db. infer ( def) ;
1783- let result = lower_to_mir ( db, def, & body, & infer, body. body_expr ) ?;
1780+ let mut result = lower_to_mir ( db, def, & body, & infer, body. body_expr ) ?;
1781+ result. shrink_to_fit ( ) ;
17841782 Ok ( Arc :: new ( result) )
17851783}
17861784
0 commit comments