@@ -599,6 +599,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
599
599
let ty = place. ty ( self . mir , self . infcx . tcx ) . ty ;
600
600
ty. ty_adt_def ( ) . filter ( |adt| adt. is_union ( ) ) . map ( |_| ty)
601
601
} ;
602
+ let describe_place = |place| self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ;
602
603
603
604
// Start with an empty tuple, so we can use the functions on `Option` to reduce some
604
605
// code duplication (particularly around returning an empty description in the failure
@@ -633,19 +634,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
633
634
if let ProjectionElem :: Field ( field, _) = elem {
634
635
if let Some ( union_ty) = union_ty ( base) {
635
636
if field != target_field && base == target_base {
636
- let desc_base =
637
- self . describe_place ( base) . unwrap_or_else ( || "_" . to_owned ( ) ) ;
638
- let desc_first = self
639
- . describe_place ( first_borrowed_place)
640
- . unwrap_or_else ( || "_" . to_owned ( ) ) ;
641
- let desc_second = self
642
- . describe_place ( second_borrowed_place)
643
- . unwrap_or_else ( || "_" . to_owned ( ) ) ;
644
-
645
637
return Some ( (
646
- desc_base ,
647
- desc_first ,
648
- desc_second ,
638
+ describe_place ( base ) ,
639
+ describe_place ( first_borrowed_place ) ,
640
+ describe_place ( second_borrowed_place ) ,
649
641
union_ty. to_string ( ) ,
650
642
) ) ;
651
643
}
@@ -659,9 +651,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
659
651
. unwrap_or_else ( || {
660
652
// If we didn't find a field access into a union, or both places match, then
661
653
// only return the description of the first place.
662
- let desc_place = self . describe_place ( first_borrowed_place)
663
- . unwrap_or_else ( || "_" . to_owned ( ) ) ;
664
- ( desc_place, "" . to_string ( ) , "" . to_string ( ) , "" . to_string ( ) )
654
+ (
655
+ describe_place ( first_borrowed_place) ,
656
+ "" . to_string ( ) ,
657
+ "" . to_string ( ) ,
658
+ "" . to_string ( ) ,
659
+ )
665
660
} )
666
661
}
667
662
0 commit comments