@@ -214,9 +214,10 @@ impl MirPass for RestoreSubsliceArrayMoveOut {
214214 None
215215 } ) . collect ( ) ;
216216
217- let opt_src_place = items. first ( ) . and_then ( |x| x . clone ( ) ) . map ( |x| x. 2 ) ;
217+ let opt_src_place = items. first ( ) . and_then ( |x| * x ) . map ( |x| x. 2 ) ;
218218 let opt_size = opt_src_place. and_then ( |src_place| {
219- let src_ty = src_place. ty ( body, tcx) . ty ;
219+ let src_ty =
220+ Place :: ty_from ( src_place. base , src_place. projection , body, tcx) . ty ;
220221 if let ty:: Array ( _, ref size_o) = src_ty. sty {
221222 size_o. assert_usize ( tcx)
222223 } else {
@@ -237,17 +238,17 @@ impl RestoreSubsliceArrayMoveOut {
237238 // indices is an integer interval. If all checks pass do the replacent.
238239 // items are Vec<Option<LocalUse, index in source array, source place for init local>>
239240 fn check_and_patch < ' tcx > ( candidate : Location ,
240- items : & [ Option < ( & LocalUse , u32 , Place < ' tcx > ) > ] ,
241+ items : & [ Option < ( & LocalUse , u32 , PlaceRef < ' _ , ' tcx > ) > ] ,
241242 opt_size : Option < u64 > ,
242243 patch : & mut MirPatch < ' tcx > ,
243244 dst_place : & Place < ' tcx > ) {
244- let opt_src_place = items. first ( ) . and_then ( |x| x . clone ( ) ) . map ( |x| x. 2 ) ;
245+ let opt_src_place = items. first ( ) . and_then ( |x| * x ) . map ( |x| x. 2 ) ;
245246
246247 if opt_size. is_some ( ) && items. iter ( ) . all (
247- |l| l. is_some ( ) && l. clone ( ) . unwrap ( ) . 2 == opt_src_place. clone ( ) . unwrap ( ) ) {
248- let src_place = opt_src_place. clone ( ) . unwrap ( ) ;
248+ |l| l. is_some ( ) && l. unwrap ( ) . 2 == opt_src_place. unwrap ( ) ) {
249+ let src_place = opt_src_place. unwrap ( ) ;
249250
250- let indices: Vec < _ > = items. iter ( ) . map ( |x| x. clone ( ) . unwrap ( ) . 1 ) . collect ( ) ;
251+ let indices: Vec < _ > = items. iter ( ) . map ( |x| x. unwrap ( ) . 1 ) . collect ( ) ;
251252 for i in 1 ..indices. len ( ) {
252253 if indices[ i - 1 ] + 1 != indices[ i] {
253254 return ;
@@ -258,7 +259,7 @@ impl RestoreSubsliceArrayMoveOut {
258259 let max = * indices. last ( ) . unwrap ( ) ;
259260
260261 for item in items {
261- let locals_use = item. clone ( ) . unwrap ( ) . 0 ;
262+ let locals_use = item. unwrap ( ) . 0 ;
262263 patch. make_nop ( locals_use. alive . unwrap ( ) ) ;
263264 patch. make_nop ( locals_use. dead . unwrap ( ) ) ;
264265 patch. make_nop ( locals_use. first_use . unwrap ( ) ) ;
@@ -279,7 +280,7 @@ impl RestoreSubsliceArrayMoveOut {
279280 }
280281
281282 fn try_get_item_source < ' a , ' tcx > ( local_use : & LocalUse ,
282- body : & ' a Body < ' tcx > ) -> Option < ( u32 , Place < ' tcx > ) > {
283+ body : & ' a Body < ' tcx > ) -> Option < ( u32 , PlaceRef < ' a , ' tcx > ) > {
283284 if let Some ( location) = local_use. first_use {
284285 let block = & body[ location. block ] ;
285286 if block. statements . len ( ) > location. statement_index {
@@ -298,9 +299,9 @@ impl RestoreSubsliceArrayMoveOut {
298299 }
299300 } ) ,
300301 } ) ) ) = & statement. kind {
301- return Some ( ( * offset, Place {
302- base : base . clone ( ) ,
303- projection : proj_base. clone ( ) ,
302+ return Some ( ( * offset, PlaceRef {
303+ base,
304+ projection : proj_base,
304305 } ) )
305306 }
306307 }
0 commit comments