@@ -272,9 +272,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
272
272
let name = self . upvars [ var_index] . name . to_string ( ) ;
273
273
buf. push_str ( & name) ;
274
274
} else {
275
- let field_name = self . describe_field ( & Place {
276
- base : ( * base) . clone ( ) ,
277
- projection : proj. base . clone ( ) ,
275
+ let field_name = self . describe_field ( PlaceRef {
276
+ base : base,
277
+ projection : & proj. base ,
278
278
} , field) ;
279
279
self . append_place_to_string (
280
280
PlaceRef {
@@ -343,31 +343,32 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
343
343
}
344
344
345
345
/// End-user visible description of the `field`nth field of `base`
346
- fn describe_field ( & self , place : & Place < ' tcx > , field : Field ) -> String {
346
+ fn describe_field ( & self , place : PlaceRef < ' cx , ' tcx > , field : Field ) -> String {
347
347
// FIXME Place2 Make this work iteratively
348
348
match place {
349
- Place {
349
+ PlaceRef {
350
350
base : PlaceBase :: Local ( local) ,
351
351
projection : None ,
352
352
} => {
353
353
let local = & self . body . local_decls [ * local] ;
354
354
self . describe_field_from_ty ( & local. ty , field, None )
355
355
}
356
- Place {
356
+ PlaceRef {
357
357
base : PlaceBase :: Static ( static_) ,
358
358
projection : None ,
359
359
} =>
360
360
self . describe_field_from_ty ( & static_. ty , field, None ) ,
361
- Place {
361
+ PlaceRef {
362
362
base,
363
363
projection : Some ( proj) ,
364
364
} => match proj. elem {
365
- ProjectionElem :: Deref => self . describe_field ( & Place {
366
- base : base . clone ( ) ,
367
- projection : proj. base . clone ( ) ,
365
+ ProjectionElem :: Deref => self . describe_field ( PlaceRef {
366
+ base,
367
+ projection : & proj. base ,
368
368
} , field) ,
369
369
ProjectionElem :: Downcast ( _, variant_index) => {
370
- let base_ty = place. ty ( self . body , self . infcx . tcx ) . ty ;
370
+ let base_ty =
371
+ Place :: ty_from ( place. base , place. projection , self . body , self . infcx . tcx ) . ty ;
371
372
self . describe_field_from_ty ( & base_ty, field, Some ( variant_index) )
372
373
}
373
374
ProjectionElem :: Field ( _, field_type) => {
@@ -376,9 +377,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
376
377
ProjectionElem :: Index ( ..)
377
378
| ProjectionElem :: ConstantIndex { .. }
378
379
| ProjectionElem :: Subslice { .. } => {
379
- self . describe_field ( & Place {
380
- base : base . clone ( ) ,
381
- projection : proj. base . clone ( ) ,
380
+ self . describe_field ( PlaceRef {
381
+ base,
382
+ projection : & proj. base ,
382
383
} , field)
383
384
}
384
385
} ,
0 commit comments