@@ -50,7 +50,7 @@ use syntax::ast::{Item, ItemKind, ImplItem, ImplItemKind};
50
50
use syntax:: ast:: { Label , Local , Mutability , Pat , PatKind , Path } ;
51
51
use syntax:: ast:: { QSelf , TraitItem , TraitItemKind , TraitRef , Ty , TyKind } ;
52
52
use syntax:: ptr:: P ;
53
- use syntax:: { span_err , struct_span_err, unwrap_or, walk_list} ;
53
+ use syntax:: { struct_span_err, unwrap_or, walk_list} ;
54
54
55
55
use syntax_pos:: { Span , DUMMY_SP , MultiSpan } ;
56
56
use errors:: { Applicability , DiagnosticBuilder , DiagnosticId } ;
@@ -4789,8 +4789,33 @@ impl<'a> Resolver<'a> {
4789
4789
let mut reported_spans = FxHashSet :: default ( ) ;
4790
4790
for & PrivacyError ( dedup_span, ident, binding) in & self . privacy_errors {
4791
4791
if reported_spans. insert ( dedup_span) {
4792
- span_err ! ( self . session, ident. span, E0603 , "{} `{}` is private" ,
4793
- binding. descr( ) , ident. name) ;
4792
+ let mut err = struct_span_err ! (
4793
+ self . session,
4794
+ ident. span,
4795
+ E0603 ,
4796
+ "{} `{}` is private" ,
4797
+ binding. descr( ) ,
4798
+ ident. name,
4799
+ ) ;
4800
+ // FIXME: use the ctor's `def_id` to check wether any of the fields is not visible
4801
+ match binding. kind {
4802
+ NameBindingKind :: Res ( Res :: Def ( DefKind :: Ctor (
4803
+ CtorOf :: Struct ,
4804
+ CtorKind :: Fn ,
4805
+ ) , _def_id) , _) => {
4806
+ err. note ( "a tuple struct constructor is private if any of its fields \
4807
+ is private") ;
4808
+ }
4809
+ NameBindingKind :: Res ( Res :: Def ( DefKind :: Ctor (
4810
+ CtorOf :: Variant ,
4811
+ CtorKind :: Fn ,
4812
+ ) , _def_id) , _) => {
4813
+ err. note ( "a tuple variant constructor is private if any of its fields \
4814
+ is private") ;
4815
+ }
4816
+ _ => { }
4817
+ }
4818
+ err. emit ( ) ;
4794
4819
}
4795
4820
}
4796
4821
}
0 commit comments