@@ -563,6 +563,20 @@ impl<'self> PrivacyVisitor<'self> {
563
563
}
564
564
}
565
565
} ;
566
+ let check_struct = |def : & @ast:: struct_def | {
567
+ for f in def. fields . iter ( ) {
568
+ match f. node . kind {
569
+ ast:: named_field( _, ast:: public) => {
570
+ tcx. sess . span_err ( f. span , "unnecessary `pub` \
571
+ visibility") ;
572
+ }
573
+ ast:: named_field( _, ast:: private) => {
574
+ // Fields should really be private by default...
575
+ }
576
+ ast:: named_field( * ) | ast:: unnamed_field => { }
577
+ }
578
+ }
579
+ } ;
566
580
match item. node {
567
581
// implementations of traits don't need visibility qualifiers because
568
582
// that's controlled by having the trait in scope.
@@ -610,24 +624,16 @@ impl<'self> PrivacyVisitor<'self> {
610
624
}
611
625
ast:: inherited => { }
612
626
}
613
- }
614
- }
615
627
616
- ast:: item_struct( ref def, _) => {
617
- for f in def. fields . iter ( ) {
618
- match f. node . kind {
619
- ast:: named_field( _, ast:: public) => {
620
- tcx. sess . span_err ( f. span , "unnecessary `pub` \
621
- visibility") ;
622
- }
623
- ast:: named_field( _, ast:: private) => {
624
- // Fields should really be private by default...
625
- }
626
- ast:: named_field( * ) | ast:: unnamed_field => { }
628
+ match v. node . kind {
629
+ ast:: struct_variant_kind( ref s) => check_struct ( s) ,
630
+ ast:: tuple_variant_kind( * ) => { }
627
631
}
628
632
}
629
633
}
630
634
635
+ ast:: item_struct( ref def, _) => check_struct ( def) ,
636
+
631
637
ast:: item_trait( _, _, ref methods) => {
632
638
for m in methods. iter ( ) {
633
639
match * m {
0 commit comments