@@ -38,8 +38,9 @@ use std::ops::ControlFlow;
38
38
use std:: { cmp, fmt, mem} ;
39
39
40
40
use errors:: {
41
- FieldIsPrivate , FieldIsPrivateLabel , FromPrivateDependencyInPublicInterface , InPublicInterface ,
42
- InPublicInterfaceTraits , ItemIsPrivate , PrivateInPublicLint , UnnamedItemIsPrivate ,
41
+ FieldIsPrivate , FieldIsPrivateLabel , FromDisplay , FromPrivateDependencyInPublicInterface ,
42
+ InPublicInterface , InPublicInterfaceTraits , ItemIsPrivate , PrivateInPublicLint ,
43
+ UnnamedItemIsPrivate ,
43
44
} ;
44
45
45
46
////////////////////////////////////////////////////////////////////////////////
@@ -1082,7 +1083,7 @@ impl<'tcx> TypePrivacyVisitor<'tcx> {
1082
1083
self . tcx . sess . emit_err ( ItemIsPrivate {
1083
1084
span : self . span ,
1084
1085
kind,
1085
- descr : descr . to_string ( ) ,
1086
+ descr : FromDisplay ( descr ) ,
1086
1087
} ) ;
1087
1088
}
1088
1089
is_error
@@ -1255,7 +1256,9 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
1255
1256
} ;
1256
1257
let kind = kind. descr ( def_id) ;
1257
1258
let _ = match name {
1258
- Some ( name) => sess. emit_err ( ItemIsPrivate { span, kind, descr : name } ) ,
1259
+ Some ( name) => {
1260
+ sess. emit_err ( ItemIsPrivate { span, kind, descr : FromDisplay ( & name) } )
1261
+ }
1259
1262
None => sess. emit_err ( UnnamedItemIsPrivate { span, kind } ) ,
1260
1263
} ;
1261
1264
return ;
@@ -1723,7 +1726,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
1723
1726
self . tcx . def_span ( self . item_def_id . to_def_id ( ) ) ,
1724
1727
FromPrivateDependencyInPublicInterface {
1725
1728
kind,
1726
- descr : descr . to_string ( ) ,
1729
+ descr : FromDisplay ( descr ) ,
1727
1730
krate : self . tcx . crate_name ( def_id. krate ) ,
1728
1731
} ,
1729
1732
) ;
@@ -1750,7 +1753,6 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
1750
1753
}
1751
1754
} ;
1752
1755
let span = self . tcx . def_span ( self . item_def_id . to_def_id ( ) ) ;
1753
- let descr = descr. to_string ( ) ;
1754
1756
if self . has_old_errors
1755
1757
|| self . in_assoc_ty
1756
1758
|| self . tcx . resolutions ( ( ) ) . has_pub_restricted
@@ -1761,15 +1763,15 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
1761
1763
span,
1762
1764
vis_descr,
1763
1765
kind,
1764
- descr,
1766
+ descr : FromDisplay ( descr ) ,
1765
1767
vis_span,
1766
1768
} ) ;
1767
1769
} else {
1768
1770
self . tcx . sess . emit_err ( InPublicInterface {
1769
1771
span,
1770
1772
vis_descr,
1771
1773
kind,
1772
- descr,
1774
+ descr : FromDisplay ( descr ) ,
1773
1775
vis_span,
1774
1776
} ) ;
1775
1777
}
@@ -1778,7 +1780,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
1778
1780
lint:: builtin:: PRIVATE_IN_PUBLIC ,
1779
1781
hir_id,
1780
1782
span,
1781
- PrivateInPublicLint { vis_descr, kind, descr } ,
1783
+ PrivateInPublicLint { vis_descr, kind, descr : FromDisplay ( descr ) } ,
1782
1784
) ;
1783
1785
}
1784
1786
}
0 commit comments