@@ -36,7 +36,7 @@ use std::marker::PhantomData;
3636use std:: ops:: ControlFlow ;
3737use std:: { cmp, fmt, mem} ;
3838
39- use errors:: { FieldIsPrivate , FieldIsPrivateLabel , ItemIsPrivate } ;
39+ use errors:: { FieldIsPrivate , FieldIsPrivateLabel , ItemIsPrivate , UnnamedItemIsPrivate } ;
4040
4141////////////////////////////////////////////////////////////////////////////////
4242/// Generic infrastructure used to implement specific visitors below.
@@ -1248,13 +1248,10 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
12481248 hir:: QPath :: TypeRelative ( _, segment) => Some ( segment. ident . to_string ( ) ) ,
12491249 } ;
12501250 let kind = kind. descr ( def_id) ;
1251- let msg = match name {
1252- Some ( name) => format ! ( "{} `{}` is private" , kind, name) ,
1253- None => format ! ( "{} is private" , kind) ,
1251+ let _ = match name {
1252+ Some ( name) => sess . emit_err ( ItemIsPrivate { span , kind, descr : name } ) ,
1253+ None => sess . emit_err ( UnnamedItemIsPrivate { span , kind } ) ,
12541254 } ;
1255- sess. struct_span_err ( span, & msg)
1256- . span_label ( span, & format ! ( "private {}" , kind) )
1257- . emit ( ) ;
12581255 return ;
12591256 }
12601257 }
0 commit comments