@@ -11,7 +11,7 @@ use rustc_middle::mir::{
1111} ;
1212use rustc_middle:: ty:: print:: Print ;
1313use rustc_middle:: ty:: { self , DefIdTree , Ty , TyCtxt } ;
14- use rustc_span:: Span ;
14+ use rustc_span:: { symbol :: sym , Span } ;
1515use rustc_target:: abi:: VariantIdx ;
1616
1717use super :: borrow_set:: BorrowData ;
@@ -632,20 +632,20 @@ pub(super) enum BorrowedContentSource<'tcx> {
632632}
633633
634634impl BorrowedContentSource < ' tcx > {
635- pub ( super ) fn describe_for_unnamed_place ( & self ) -> String {
635+ pub ( super ) fn describe_for_unnamed_place ( & self , tcx : TyCtxt < ' _ > ) -> String {
636636 match * self {
637637 BorrowedContentSource :: DerefRawPointer => "a raw pointer" . to_string ( ) ,
638638 BorrowedContentSource :: DerefSharedRef => "a shared reference" . to_string ( ) ,
639639 BorrowedContentSource :: DerefMutableRef => "a mutable reference" . to_string ( ) ,
640- BorrowedContentSource :: OverloadedDeref ( ty) => {
641- if ty . is_rc ( ) {
640+ BorrowedContentSource :: OverloadedDeref ( ty) => match ty . kind {
641+ ty :: Adt ( def , _ ) if tcx . is_diagnostic_item ( sym :: Rc , def . did ) => {
642642 "an `Rc`" . to_string ( )
643- } else if ty. is_arc ( ) {
643+ }
644+ ty:: Adt ( def, _) if tcx. is_diagnostic_item ( sym:: Arc , def. did ) => {
644645 "an `Arc`" . to_string ( )
645- } else {
646- format ! ( "dereference of `{}`" , ty)
647646 }
648- }
647+ _ => format ! ( "dereference of `{}`" , ty) ,
648+ } ,
649649 BorrowedContentSource :: OverloadedIndex ( ty) => format ! ( "index of `{}`" , ty) ,
650650 }
651651 }
@@ -662,22 +662,22 @@ impl BorrowedContentSource<'tcx> {
662662 }
663663 }
664664
665- pub ( super ) fn describe_for_immutable_place ( & self ) -> String {
665+ pub ( super ) fn describe_for_immutable_place ( & self , tcx : TyCtxt < ' _ > ) -> String {
666666 match * self {
667667 BorrowedContentSource :: DerefRawPointer => "a `*const` pointer" . to_string ( ) ,
668668 BorrowedContentSource :: DerefSharedRef => "a `&` reference" . to_string ( ) ,
669669 BorrowedContentSource :: DerefMutableRef => {
670670 bug ! ( "describe_for_immutable_place: DerefMutableRef isn't immutable" )
671671 }
672- BorrowedContentSource :: OverloadedDeref ( ty) => {
673- if ty . is_rc ( ) {
672+ BorrowedContentSource :: OverloadedDeref ( ty) => match ty . kind {
673+ ty :: Adt ( def , _ ) if tcx . is_diagnostic_item ( sym :: Rc , def . did ) => {
674674 "an `Rc`" . to_string ( )
675- } else if ty. is_arc ( ) {
675+ }
676+ ty:: Adt ( def, _) if tcx. is_diagnostic_item ( sym:: Arc , def. did ) => {
676677 "an `Arc`" . to_string ( )
677- } else {
678- format ! ( "a dereference of `{}`" , ty)
679678 }
680- }
679+ _ => format ! ( "a dereference of `{}`" , ty) ,
680+ } ,
681681 BorrowedContentSource :: OverloadedIndex ( ty) => format ! ( "an index of `{}`" , ty) ,
682682 }
683683 }
0 commit comments