@@ -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 } ;
@@ -4810,8 +4810,33 @@ impl<'a> Resolver<'a> {
4810
4810
let mut reported_spans = FxHashSet :: default ( ) ;
4811
4811
for & PrivacyError ( dedup_span, ident, binding) in & self . privacy_errors {
4812
4812
if reported_spans. insert ( dedup_span) {
4813
- span_err ! ( self . session, ident. span, E0603 , "{} `{}` is private" ,
4814
- binding. descr( ) , ident. name) ;
4813
+ let mut err = struct_span_err ! (
4814
+ self . session,
4815
+ ident. span,
4816
+ E0603 ,
4817
+ "{} `{}` is private" ,
4818
+ binding. descr( ) ,
4819
+ ident. name,
4820
+ ) ;
4821
+ // FIXME: use the ctor's `def_id` to check wether any of the fields is not visible
4822
+ match binding. kind {
4823
+ NameBindingKind :: Res ( Res :: Def ( DefKind :: Ctor (
4824
+ CtorOf :: Struct ,
4825
+ CtorKind :: Fn ,
4826
+ ) , _def_id) , _) => {
4827
+ err. note ( "a tuple struct constructor is private if any of its fields \
4828
+ is private") ;
4829
+ }
4830
+ NameBindingKind :: Res ( Res :: Def ( DefKind :: Ctor (
4831
+ CtorOf :: Variant ,
4832
+ CtorKind :: Fn ,
4833
+ ) , _def_id) , _) => {
4834
+ err. note ( "a tuple variant constructor is private if any of its fields \
4835
+ is private") ;
4836
+ }
4837
+ _ => { }
4838
+ }
4839
+ err. emit ( ) ;
4815
4840
}
4816
4841
}
4817
4842
}
0 commit comments