@@ -563,6 +563,20 @@ impl<'self> PrivacyVisitor<'self> {
563563 }
564564 }
565565 } ;
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+ } ;
566580 match item. node {
567581 // implementations of traits don't need visibility qualifiers because
568582 // that's controlled by having the trait in scope.
@@ -610,24 +624,16 @@ impl<'self> PrivacyVisitor<'self> {
610624 }
611625 ast:: inherited => { }
612626 }
613- }
614- }
615627
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( * ) => { }
627631 }
628632 }
629633 }
630634
635+ ast:: item_struct( ref def, _) => check_struct ( def) ,
636+
631637 ast:: item_trait( _, _, ref methods) => {
632638 for m in methods. iter ( ) {
633639 match * m {
0 commit comments