@@ -331,18 +331,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
331
331
match place {
332
332
PlaceRef { local, projection : [ ] } => {
333
333
let local = & self . body . local_decls [ local] ;
334
- self . describe_field_from_ty ( & local. ty , field, None )
334
+ self . describe_field_from_ty ( local. ty , field, None )
335
335
}
336
336
PlaceRef { local, projection : [ proj_base @ .., elem] } => match elem {
337
337
ProjectionElem :: Deref => {
338
338
self . describe_field ( PlaceRef { local, projection : proj_base } , field)
339
339
}
340
340
ProjectionElem :: Downcast ( _, variant_index) => {
341
341
let base_ty = place. ty ( self . body , self . infcx . tcx ) . ty ;
342
- self . describe_field_from_ty ( & base_ty, field, Some ( * variant_index) )
342
+ self . describe_field_from_ty ( base_ty, field, Some ( * variant_index) )
343
343
}
344
344
ProjectionElem :: Field ( _, field_type) => {
345
- self . describe_field_from_ty ( & field_type, field, None )
345
+ self . describe_field_from_ty ( * field_type, field, None )
346
346
}
347
347
ProjectionElem :: Index ( ..)
348
348
| ProjectionElem :: ConstantIndex { .. }
@@ -362,7 +362,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
362
362
) -> String {
363
363
if ty. is_box ( ) {
364
364
// If the type is a box, the field is described from the boxed type
365
- self . describe_field_from_ty ( & ty. boxed_ty ( ) , field, variant_index)
365
+ self . describe_field_from_ty ( ty. boxed_ty ( ) , field, variant_index)
366
366
} else {
367
367
match * ty. kind ( ) {
368
368
ty:: Adt ( def, _) => {
@@ -376,10 +376,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
376
376
}
377
377
ty:: Tuple ( _) => field. index ( ) . to_string ( ) ,
378
378
ty:: Ref ( _, ty, _) | ty:: RawPtr ( ty:: TypeAndMut { ty, .. } ) => {
379
- self . describe_field_from_ty ( & ty, field, variant_index)
379
+ self . describe_field_from_ty ( ty, field, variant_index)
380
380
}
381
381
ty:: Array ( ty, _) | ty:: Slice ( ty) => {
382
- self . describe_field_from_ty ( & ty, field, variant_index)
382
+ self . describe_field_from_ty ( ty, field, variant_index)
383
383
}
384
384
ty:: Closure ( def_id, _) | ty:: Generator ( def_id, _, _) => {
385
385
// We won't be borrowck'ing here if the closure came from another crate,
@@ -497,14 +497,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
497
497
// We need to add synthesized lifetimes where appropriate. We do
498
498
// this by hooking into the pretty printer and telling it to label the
499
499
// lifetimes without names with the value `'0`.
500
- match ty. kind ( ) {
501
- ty :: Ref (
502
- ty:: RegionKind :: ReLateBound ( _, ty:: BoundRegion { kind : br, .. } )
503
- | ty:: RegionKind :: RePlaceholder ( ty:: PlaceholderRegion { name : br, .. } ) ,
504
- _ ,
505
- _ ,
506
- ) => printer . region_highlight_mode . highlighting_bound_region ( * br , counter ) ,
507
- _ => { }
500
+ if let ty :: Ref ( region , .. ) = ty. kind ( ) {
501
+ match * * region {
502
+ ty:: ReLateBound ( _, ty:: BoundRegion { kind : br, .. } )
503
+ | ty:: RePlaceholder ( ty:: PlaceholderRegion { name : br, .. } ) => {
504
+ printer . region_highlight_mode . highlighting_bound_region ( br , counter )
505
+ }
506
+ _ => { }
507
+ }
508
508
}
509
509
510
510
let _ = ty. print ( printer) ;
@@ -517,19 +517,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
517
517
let mut s = String :: new ( ) ;
518
518
let mut printer = ty:: print:: FmtPrinter :: new ( self . infcx . tcx , & mut s, Namespace :: TypeNS ) ;
519
519
520
- let region = match ty. kind ( ) {
521
- ty:: Ref ( region, _, _) => {
522
- match region {
523
- ty:: RegionKind :: ReLateBound ( _, ty:: BoundRegion { kind : br, .. } )
524
- | ty:: RegionKind :: RePlaceholder ( ty:: PlaceholderRegion { name : br, .. } ) => {
525
- printer. region_highlight_mode . highlighting_bound_region ( * br, counter)
526
- }
527
- _ => { }
520
+ let region = if let ty:: Ref ( region, ..) = ty. kind ( ) {
521
+ match * * region {
522
+ ty:: ReLateBound ( _, ty:: BoundRegion { kind : br, .. } )
523
+ | ty:: RePlaceholder ( ty:: PlaceholderRegion { name : br, .. } ) => {
524
+ printer. region_highlight_mode . highlighting_bound_region ( br, counter)
528
525
}
529
-
530
- region
526
+ _ => { }
531
527
}
532
- _ => bug ! ( "ty for annotation of borrow region is not a reference" ) ,
528
+ region
529
+ } else {
530
+ bug ! ( "ty for annotation of borrow region is not a reference" ) ;
533
531
} ;
534
532
535
533
let _ = region. print ( printer) ;
0 commit comments