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