@@ -1038,7 +1038,7 @@ impl<'a, 'tcx> NamePrivacyVisitor<'a, 'tcx> {
10381038 def. variant_descr( ) ,
10391039 self . tcx. def_path_str( def. did)
10401040 )
1041- . span_label ( span, format ! ( "field `{}` is private" , field. ident ) )
1041+ . span_label ( span, " private field" )
10421042 . emit ( ) ;
10431043 }
10441044 }
@@ -1180,7 +1180,11 @@ impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> {
11801180 fn check_def_id ( & mut self , def_id : DefId , kind : & str , descr : & dyn fmt:: Display ) -> bool {
11811181 let is_error = !self . item_is_accessible ( def_id) ;
11821182 if is_error {
1183- self . tcx . sess . span_err ( self . span , & format ! ( "{} `{}` is private" , kind, descr) ) ;
1183+ self . tcx
1184+ . sess
1185+ . struct_span_err ( self . span , & format ! ( "{} `{}` is private" , kind, descr) )
1186+ . span_label ( self . span , & format ! ( "private {}" , kind) )
1187+ . emit ( ) ;
11841188 }
11851189 is_error
11861190 }
@@ -1313,8 +1317,12 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
13131317 hir:: QPath :: Resolved ( _, ref path) => path. to_string ( ) ,
13141318 hir:: QPath :: TypeRelative ( _, ref segment) => segment. ident . to_string ( ) ,
13151319 } ;
1316- let msg = format ! ( "{} `{}` is private" , kind. descr( def_id) , name) ;
1317- self . tcx . sess . span_err ( span, & msg) ;
1320+ let kind = kind. descr ( def_id) ;
1321+ self . tcx
1322+ . sess
1323+ . struct_span_err ( span, & format ! ( "{} `{}` is private" , kind, name) )
1324+ . span_label ( span, & format ! ( "private {}" , kind) )
1325+ . emit ( ) ;
13181326 return ;
13191327 }
13201328 }
0 commit comments