@@ -888,29 +888,14 @@ pub struct TestReachabilityVisitor<'tcx, 'a> {
888888 effective_visibilities : & ' a EffectiveVisibilities ,
889889}
890890
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-
906891impl < ' tcx , ' a > TestReachabilityVisitor < ' tcx , ' a > {
907892 fn effective_visibility_diagnostic ( & mut self , def_id : LocalDefId ) {
908893 if self . tcx . has_attr ( def_id, sym:: rustc_effective_visibility) {
909894 let mut error_msg = String :: new ( ) ;
910895 let span = self . tcx . def_span ( def_id. to_def_id ( ) ) ;
911896 if let Some ( effective_vis) = self . effective_visibilities . effective_vis ( def_id) {
912897 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 ) ;
914899 if level != Level :: Direct {
915900 error_msg. push_str ( ", " ) ;
916901 }
@@ -1506,11 +1491,11 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
15061491 tcx : self . tcx ,
15071492 } )
15081493 . 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 ) ,
15101495 ty_span : vis_span,
15111496 ty_kind : kind,
15121497 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 ) ,
15141499 } ,
15151500 ) ;
15161501 }
@@ -1589,8 +1574,8 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {
15891574 span,
15901575 kind : self . tcx . def_descr ( def_id. to_def_id ( ) ) ,
15911576 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 ) ,
15941579 } ,
15951580 ) ;
15961581 }
0 commit comments