@@ -1038,7 +1038,7 @@ impl<'a, 'tcx> NamePrivacyVisitor<'a, 'tcx> {
1038
1038
def. variant_descr( ) ,
1039
1039
self . tcx. def_path_str( def. did)
1040
1040
)
1041
- . span_label ( span, format ! ( "field `{}` is private" , field. ident ) )
1041
+ . span_label ( span, " private field" )
1042
1042
. emit ( ) ;
1043
1043
}
1044
1044
}
@@ -1180,7 +1180,11 @@ impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> {
1180
1180
fn check_def_id ( & mut self , def_id : DefId , kind : & str , descr : & dyn fmt:: Display ) -> bool {
1181
1181
let is_error = !self . item_is_accessible ( def_id) ;
1182
1182
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 ( ) ;
1184
1188
}
1185
1189
is_error
1186
1190
}
@@ -1313,8 +1317,12 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
1313
1317
hir:: QPath :: Resolved ( _, ref path) => path. to_string ( ) ,
1314
1318
hir:: QPath :: TypeRelative ( _, ref segment) => segment. ident . to_string ( ) ,
1315
1319
} ;
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 ( ) ;
1318
1326
return ;
1319
1327
}
1320
1328
}
0 commit comments