@@ -214,9 +214,10 @@ impl MirPass for RestoreSubsliceArrayMoveOut {
214
214
None
215
215
} ) . collect ( ) ;
216
216
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 ) ;
218
218
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 ;
220
221
if let ty:: Array ( _, ref size_o) = src_ty. sty {
221
222
size_o. assert_usize ( tcx)
222
223
} else {
@@ -237,17 +238,17 @@ impl RestoreSubsliceArrayMoveOut {
237
238
// indices is an integer interval. If all checks pass do the replacent.
238
239
// items are Vec<Option<LocalUse, index in source array, source place for init local>>
239
240
fn check_and_patch < ' tcx > ( candidate : Location ,
240
- items : & [ Option < ( & LocalUse , u32 , Place < ' tcx > ) > ] ,
241
+ items : & [ Option < ( & LocalUse , u32 , PlaceRef < ' _ , ' tcx > ) > ] ,
241
242
opt_size : Option < u64 > ,
242
243
patch : & mut MirPatch < ' tcx > ,
243
244
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 ) ;
245
246
246
247
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 ( ) ;
249
250
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 ( ) ;
251
252
for i in 1 ..indices. len ( ) {
252
253
if indices[ i - 1 ] + 1 != indices[ i] {
253
254
return ;
@@ -258,7 +259,7 @@ impl RestoreSubsliceArrayMoveOut {
258
259
let max = * indices. last ( ) . unwrap ( ) ;
259
260
260
261
for item in items {
261
- let locals_use = item. clone ( ) . unwrap ( ) . 0 ;
262
+ let locals_use = item. unwrap ( ) . 0 ;
262
263
patch. make_nop ( locals_use. alive . unwrap ( ) ) ;
263
264
patch. make_nop ( locals_use. dead . unwrap ( ) ) ;
264
265
patch. make_nop ( locals_use. first_use . unwrap ( ) ) ;
@@ -279,7 +280,7 @@ impl RestoreSubsliceArrayMoveOut {
279
280
}
280
281
281
282
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 > ) > {
283
284
if let Some ( location) = local_use. first_use {
284
285
let block = & body[ location. block ] ;
285
286
if block. statements . len ( ) > location. statement_index {
@@ -298,9 +299,9 @@ impl RestoreSubsliceArrayMoveOut {
298
299
}
299
300
} ) ,
300
301
} ) ) ) = & 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,
304
305
} ) )
305
306
}
306
307
}
0 commit comments