@@ -40,6 +40,7 @@ crate use outlives_suggestion::OutlivesSuggestionBuilder;
40
40
crate use region_errors:: { ErrorConstraintInfo , RegionErrorKind , RegionErrors } ;
41
41
crate use region_name:: { RegionName , RegionNameSource } ;
42
42
crate use rustc_const_eval:: util:: CallKind ;
43
+ use rustc_middle:: mir:: tcx:: PlaceTy ;
43
44
44
45
pub ( super ) struct IncludingDowncast ( pub ( super ) bool ) ;
45
46
@@ -329,30 +330,20 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
329
330
330
331
/// End-user visible description of the `field`nth field of `base`
331
332
fn describe_field ( & self , place : PlaceRef < ' tcx > , field : Field ) -> String {
332
- // FIXME Place2 Make this work iteratively
333
- match place {
334
- PlaceRef { local, projection : [ ] } => {
335
- let local = & self . body . local_decls [ local] ;
336
- self . describe_field_from_ty ( local. ty , field, None )
337
- }
333
+ let place_ty = match place {
334
+ PlaceRef { local, projection : [ ] } => PlaceTy :: from_ty ( self . body . local_decls [ local] . ty ) ,
338
335
PlaceRef { local, projection : [ proj_base @ .., elem] } => match elem {
339
- ProjectionElem :: Deref => {
340
- self . describe_field ( PlaceRef { local, projection : proj_base } , field)
341
- }
342
- ProjectionElem :: Downcast ( _, variant_index) => {
343
- let base_ty = place. ty ( self . body , self . infcx . tcx ) . ty ;
344
- self . describe_field_from_ty ( base_ty, field, Some ( * variant_index) )
345
- }
346
- ProjectionElem :: Field ( _, field_type) => {
347
- self . describe_field_from_ty ( * field_type, field, None )
348
- }
349
- ProjectionElem :: Index ( ..)
336
+ ProjectionElem :: Deref
337
+ | ProjectionElem :: Index ( ..)
350
338
| ProjectionElem :: ConstantIndex { .. }
351
339
| ProjectionElem :: Subslice { .. } => {
352
- self . describe_field ( PlaceRef { local, projection : proj_base } , field )
340
+ PlaceRef { local, projection : proj_base } . ty ( self . body , self . infcx . tcx )
353
341
}
342
+ ProjectionElem :: Downcast ( ..) => place. ty ( self . body , self . infcx . tcx ) ,
343
+ ProjectionElem :: Field ( _, field_type) => PlaceTy :: from_ty ( * field_type) ,
354
344
} ,
355
- }
345
+ } ;
346
+ self . describe_field_from_ty ( place_ty. ty , field, place_ty. variant_index )
356
347
}
357
348
358
349
/// End-user visible description of the `field_index`nth field of `ty`
0 commit comments