@@ -888,29 +888,14 @@ pub struct TestReachabilityVisitor<'tcx, 'a> {
888
888
effective_visibilities : & ' a EffectiveVisibilities ,
889
889
}
890
890
891
- fn vis_to_string < ' tcx > ( def_id : LocalDefId , vis : ty:: Visibility , tcx : TyCtxt < ' tcx > ) -> String {
892
- match vis {
893
- ty:: Visibility :: Restricted ( restricted_id) => {
894
- if restricted_id. is_top_level_module ( ) {
895
- "pub(crate)" . to_string ( )
896
- } else if restricted_id == tcx. parent_module_from_def_id ( def_id) . to_local_def_id ( ) {
897
- "pub(self)" . to_string ( )
898
- } else {
899
- format ! ( "pub({})" , tcx. item_name( restricted_id. to_def_id( ) ) )
900
- }
901
- }
902
- ty:: Visibility :: Public => "pub" . to_string ( ) ,
903
- }
904
- }
905
-
906
891
impl < ' tcx , ' a > TestReachabilityVisitor < ' tcx , ' a > {
907
892
fn effective_visibility_diagnostic ( & mut self , def_id : LocalDefId ) {
908
893
if self . tcx . has_attr ( def_id, sym:: rustc_effective_visibility) {
909
894
let mut error_msg = String :: new ( ) ;
910
895
let span = self . tcx . def_span ( def_id. to_def_id ( ) ) ;
911
896
if let Some ( effective_vis) = self . effective_visibilities . effective_vis ( def_id) {
912
897
for level in Level :: all_levels ( ) {
913
- let vis_str = vis_to_string ( def_id , * effective_vis. at_level ( level) , self . tcx ) ;
898
+ let vis_str = effective_vis. at_level ( level) . to_string ( def_id , self . tcx ) ;
914
899
if level != Level :: Direct {
915
900
error_msg. push_str ( ", " ) ;
916
901
}
@@ -1506,11 +1491,11 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
1506
1491
tcx : self . tcx ,
1507
1492
} )
1508
1493
. into ( ) ,
1509
- item_vis_descr : & vis_to_string ( self . item_def_id , reachable_at_vis , self . tcx ) ,
1494
+ item_vis_descr : & reachable_at_vis . to_string ( self . item_def_id , self . tcx ) ,
1510
1495
ty_span : vis_span,
1511
1496
ty_kind : kind,
1512
1497
ty_descr : descr. into ( ) ,
1513
- ty_vis_descr : & vis_to_string ( local_def_id, vis , self . tcx ) ,
1498
+ ty_vis_descr : & vis . to_string ( local_def_id, self . tcx ) ,
1514
1499
} ,
1515
1500
) ;
1516
1501
}
@@ -1589,8 +1574,8 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {
1589
1574
span,
1590
1575
kind : self . tcx . def_descr ( def_id. to_def_id ( ) ) ,
1591
1576
descr : ( & LazyDefPathStr { def_id : def_id. to_def_id ( ) , tcx : self . tcx } ) . into ( ) ,
1592
- reachable_vis : & vis_to_string ( def_id, * reachable_at_vis , self . tcx ) ,
1593
- reexported_vis : & vis_to_string ( def_id, * reexported_at_vis , self . tcx ) ,
1577
+ reachable_vis : & reachable_at_vis . to_string ( def_id, self . tcx ) ,
1578
+ reexported_vis : & reexported_at_vis . to_string ( def_id, self . tcx ) ,
1594
1579
} ,
1595
1580
) ;
1596
1581
}
0 commit comments