@@ -47,7 +47,7 @@ mod region_errors;
4747
4848pub ( crate ) use bound_region_errors:: { ToUniverseInfo , UniverseInfo } ;
4949pub ( crate ) use move_errors:: { IllegalMoveOriginKind , MoveError } ;
50- pub ( crate ) use mutability_errors:: AccessKind ;
50+ pub ( crate ) use mutability_errors:: { AccessKind , PlaceAndReason } ;
5151pub ( crate ) use outlives_suggestion:: OutlivesSuggestionBuilder ;
5252pub ( crate ) use region_errors:: { ErrorConstraintInfo , RegionErrorKind , RegionErrors } ;
5353pub ( crate ) use region_name:: { RegionName , RegionNameSource } ;
@@ -681,6 +681,7 @@ impl UseSpans<'_> {
681681 }
682682}
683683
684+ #[ derive( Clone , Copy , Debug ) ]
684685pub ( super ) enum BorrowedContentSource < ' tcx > {
685686 DerefRawPointer ,
686687 DerefMutableRef ,
@@ -718,21 +719,22 @@ impl<'tcx> BorrowedContentSource<'tcx> {
718719 }
719720 }
720721
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 > {
722724 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 ,
725727 BorrowedContentSource :: DerefMutableRef => {
726728 bug ! ( "describe_for_immutable_place: DerefMutableRef isn't immutable" )
727729 }
728730 BorrowedContentSource :: OverloadedDeref ( ty) => ty
729731 . ty_adt_def ( )
730732 . 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}`" ) ) ) ,
732734 _ => None ,
733735 } )
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}`" ) ) ,
736738 }
737739 }
738740
0 commit comments