@@ -47,7 +47,7 @@ mod region_errors;
47
47
48
48
pub ( crate ) use bound_region_errors:: { ToUniverseInfo , UniverseInfo } ;
49
49
pub ( crate ) use move_errors:: { IllegalMoveOriginKind , MoveError } ;
50
- pub ( crate ) use mutability_errors:: AccessKind ;
50
+ pub ( crate ) use mutability_errors:: { AccessKind , PlaceAndReason } ;
51
51
pub ( crate ) use outlives_suggestion:: OutlivesSuggestionBuilder ;
52
52
pub ( crate ) use region_errors:: { ErrorConstraintInfo , RegionErrorKind , RegionErrors } ;
53
53
pub ( crate ) use region_name:: { RegionName , RegionNameSource } ;
@@ -681,6 +681,7 @@ impl UseSpans<'_> {
681
681
}
682
682
}
683
683
684
+ #[ derive( Clone , Copy , Debug ) ]
684
685
pub ( super ) enum BorrowedContentSource < ' tcx > {
685
686
DerefRawPointer ,
686
687
DerefMutableRef ,
@@ -718,21 +719,22 @@ impl<'tcx> BorrowedContentSource<'tcx> {
718
719
}
719
720
}
720
721
721
- pub ( super ) fn describe_for_immutable_place ( & self , tcx : TyCtxt < ' _ > ) -> String {
722
+ // ready to remove
723
+ pub ( super ) fn describe_for_immutable_place ( & self , tcx : TyCtxt < ' _ > ) -> Option < String > {
722
724
match * self {
723
- BorrowedContentSource :: DerefRawPointer => "a `*const` pointer" . to_string ( ) ,
724
- BorrowedContentSource :: DerefSharedRef => "a `&` reference" . to_string ( ) ,
725
+ BorrowedContentSource :: DerefRawPointer => None ,
726
+ BorrowedContentSource :: DerefSharedRef => None ,
725
727
BorrowedContentSource :: DerefMutableRef => {
726
728
bug ! ( "describe_for_immutable_place: DerefMutableRef isn't immutable" )
727
729
}
728
730
BorrowedContentSource :: OverloadedDeref ( ty) => ty
729
731
. ty_adt_def ( )
730
732
. and_then ( |adt| match tcx. get_diagnostic_name ( adt. did ( ) ) ? {
731
- name @ ( sym:: Rc | sym:: Arc ) => Some ( format ! ( "an `{name}`" ) ) ,
733
+ name @ ( sym:: Rc | sym:: Arc ) => Some ( Some ( format ! ( "an `{name}`" ) ) ) ,
732
734
_ => None ,
733
735
} )
734
- . unwrap_or_else ( || format ! ( "dereference of `{ty}`" ) ) ,
735
- BorrowedContentSource :: OverloadedIndex ( ty) => format ! ( "an index of `{ty}`" ) ,
736
+ . unwrap_or_else ( || Some ( format ! ( "dereference of `{ty}`" ) ) ) ,
737
+ BorrowedContentSource :: OverloadedIndex ( ty) => Some ( format ! ( "`{ty}`" ) ) ,
736
738
}
737
739
}
738
740
0 commit comments