@@ -11,7 +11,7 @@ use rustc_middle::mir::{
11
11
} ;
12
12
use rustc_middle:: ty:: print:: Print ;
13
13
use rustc_middle:: ty:: { self , DefIdTree , Ty , TyCtxt } ;
14
- use rustc_span:: Span ;
14
+ use rustc_span:: { symbol :: sym , Span } ;
15
15
use rustc_target:: abi:: VariantIdx ;
16
16
17
17
use super :: borrow_set:: BorrowData ;
@@ -632,20 +632,20 @@ pub(super) enum BorrowedContentSource<'tcx> {
632
632
}
633
633
634
634
impl BorrowedContentSource < ' tcx > {
635
- pub ( super ) fn describe_for_unnamed_place ( & self ) -> String {
635
+ pub ( super ) fn describe_for_unnamed_place ( & self , tcx : TyCtxt < ' _ > ) -> String {
636
636
match * self {
637
637
BorrowedContentSource :: DerefRawPointer => "a raw pointer" . to_string ( ) ,
638
638
BorrowedContentSource :: DerefSharedRef => "a shared reference" . to_string ( ) ,
639
639
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 ) => {
642
642
"an `Rc`" . to_string ( )
643
- } else if ty. is_arc ( ) {
643
+ }
644
+ ty:: Adt ( def, _) if tcx. is_diagnostic_item ( sym:: Arc , def. did ) => {
644
645
"an `Arc`" . to_string ( )
645
- } else {
646
- format ! ( "dereference of `{}`" , ty)
647
646
}
648
- }
647
+ _ => format ! ( "dereference of `{}`" , ty) ,
648
+ } ,
649
649
BorrowedContentSource :: OverloadedIndex ( ty) => format ! ( "index of `{}`" , ty) ,
650
650
}
651
651
}
@@ -662,22 +662,22 @@ impl BorrowedContentSource<'tcx> {
662
662
}
663
663
}
664
664
665
- pub ( super ) fn describe_for_immutable_place ( & self ) -> String {
665
+ pub ( super ) fn describe_for_immutable_place ( & self , tcx : TyCtxt < ' _ > ) -> String {
666
666
match * self {
667
667
BorrowedContentSource :: DerefRawPointer => "a `*const` pointer" . to_string ( ) ,
668
668
BorrowedContentSource :: DerefSharedRef => "a `&` reference" . to_string ( ) ,
669
669
BorrowedContentSource :: DerefMutableRef => {
670
670
bug ! ( "describe_for_immutable_place: DerefMutableRef isn't immutable" )
671
671
}
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 ) => {
674
674
"an `Rc`" . to_string ( )
675
- } else if ty. is_arc ( ) {
675
+ }
676
+ ty:: Adt ( def, _) if tcx. is_diagnostic_item ( sym:: Arc , def. did ) => {
676
677
"an `Arc`" . to_string ( )
677
- } else {
678
- format ! ( "a dereference of `{}`" , ty)
679
678
}
680
- }
679
+ _ => format ! ( "a dereference of `{}`" , ty) ,
680
+ } ,
681
681
BorrowedContentSource :: OverloadedIndex ( ty) => format ! ( "an index of `{}`" , ty) ,
682
682
}
683
683
}
0 commit comments