@@ -67,18 +67,10 @@ impl Visitor<()> for ParentVisitor {
6767 // they inherit privacy
6868 ast:: ItemEnum ( ref def, _) => {
6969 for variant in def. variants . iter ( ) {
70- // If variants are private, then their logical "parent" is
71- // the enclosing module because everyone in the enclosing
72- // module can still use the private variant
73- if variant. node . vis == ast:: Private {
74- self . parents . insert ( variant. node . id , self . curparent ) ;
75-
76- // Otherwise, if the variant is public, then the parent is
77- // considered the enclosing enum because the enum will
78- // dictate the privacy visibility of this variant instead.
79- } else {
80- self . parents . insert ( variant. node . id , item. id ) ;
81- }
70+ // The parent is considered the enclosing enum because the
71+ // enum will dictate the privacy visibility of this variant
72+ // instead.
73+ self . parents . insert ( variant. node . id , item. id ) ;
8274 }
8375 }
8476
@@ -224,9 +216,7 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> {
224216 // public all variants are public unless they're explicitly priv
225217 ast:: ItemEnum ( ref def, _) if public_first => {
226218 for variant in def. variants . iter ( ) {
227- if variant. node . vis != ast:: Private {
228- self . exported_items . insert ( variant. node . id ) ;
229- }
219+ self . exported_items . insert ( variant. node . id ) ;
230220 }
231221 }
232222
@@ -462,10 +452,7 @@ impl<'a> PrivacyVisitor<'a> {
462452 Some ( ast_map:: NodeForeignItem ( _) ) => {
463453 self . tcx . map . get_foreign_vis ( closest_private_id)
464454 }
465- Some ( ast_map:: NodeVariant ( ref v) ) => {
466- // sadly enum variants still inherit visibility, so only
467- // break out of this is explicitly private
468- if v. node . vis == ast:: Private { break }
455+ Some ( ast_map:: NodeVariant ( ..) ) => {
469456 ast:: Public // need to move up a level (to the enum)
470457 }
471458 _ => ast:: Public ,
@@ -997,10 +984,6 @@ impl<'a> Visitor<()> for SanePrivacyVisitor<'a> {
997984 fn visit_view_item ( & mut self , i : & ast:: ViewItem , _: ( ) ) {
998985 match i. vis {
999986 ast:: Inherited => { }
1000- ast:: Private => {
1001- self . tcx . sess . span_err ( i. span , "unnecessary visibility \
1002- qualifier") ;
1003- }
1004987 ast:: Public => {
1005988 if self . in_fn {
1006989 self . tcx . sess . span_err ( i. span , "unnecessary `pub`, imports \
@@ -1036,25 +1019,6 @@ impl<'a> SanePrivacyVisitor<'a> {
10361019 }
10371020 }
10381021 } ;
1039- let check_not_priv = |sp : Span , vis : ast:: Visibility , note : & str | {
1040- if vis == ast:: Private {
1041- tcx. sess . span_err ( sp, "unnecessary `priv` qualifier" ) ;
1042- if note. len ( ) > 0 {
1043- tcx. sess . span_note ( sp, note) ;
1044- }
1045- }
1046- } ;
1047- let check_struct = |def : & @ast:: StructDef | {
1048- for f in def. fields . iter ( ) {
1049- match f. node . kind {
1050- ast:: NamedField ( _, ast:: Private ) => {
1051- tcx. sess . span_err ( f. span , "unnecessary `priv` \
1052- visibility") ;
1053- }
1054- ast:: NamedField ( ..) | ast:: UnnamedField ( ..) => { }
1055- }
1056- }
1057- } ;
10581022 match item. node {
10591023 // implementations of traits don't need visibility qualifiers because
10601024 // that's controlled by having the trait in scope.
@@ -1067,22 +1031,14 @@ impl<'a> SanePrivacyVisitor<'a> {
10671031 }
10681032 }
10691033
1070- ast:: ItemImpl ( _ , _ , _ , ref methods ) => {
1034+ ast:: ItemImpl ( .. ) => {
10711035 check_inherited ( item. span , item. vis ,
10721036 "place qualifiers on individual methods instead" ) ;
1073- for i in methods. iter ( ) {
1074- check_not_priv ( i. span , i. vis , "functions are private by \
1075- default") ;
1076- }
10771037 }
1078- ast:: ItemForeignMod ( ref fm ) => {
1038+ ast:: ItemForeignMod ( .. ) => {
10791039 check_inherited ( item. span , item. vis ,
10801040 "place qualifiers on individual functions \
10811041 instead") ;
1082- for i in fm. items . iter ( ) {
1083- check_not_priv ( i. span , i. vis , "functions are private by \
1084- default") ;
1085- }
10861042 }
10871043
10881044 ast:: ItemEnum ( ref def, _) => {
@@ -1094,24 +1050,11 @@ impl<'a> SanePrivacyVisitor<'a> {
10941050 visibility") ;
10951051 }
10961052 }
1097- ast:: Private => {
1098- if item. vis != ast:: Public {
1099- tcx. sess . span_err ( v. span , "unnecessary `priv` \
1100- visibility") ;
1101- }
1102- }
11031053 ast:: Inherited => { }
11041054 }
1105-
1106- match v. node . kind {
1107- ast:: StructVariantKind ( ref s) => check_struct ( s) ,
1108- ast:: TupleVariantKind ( ..) => { }
1109- }
11101055 }
11111056 }
11121057
1113- ast:: ItemStruct ( ref def, _) => check_struct ( def) ,
1114-
11151058 ast:: ItemTrait ( _, _, ref methods) => {
11161059 for m in methods. iter ( ) {
11171060 match * m {
@@ -1124,12 +1067,9 @@ impl<'a> SanePrivacyVisitor<'a> {
11241067 }
11251068 }
11261069
1127- ast:: ItemStatic ( ..) |
1070+ ast:: ItemStatic ( ..) | ast :: ItemStruct ( .. ) |
11281071 ast:: ItemFn ( ..) | ast:: ItemMod ( ..) | ast:: ItemTy ( ..) |
1129- ast:: ItemMac ( ..) => {
1130- check_not_priv ( item. span , item. vis , "items are private by \
1131- default") ;
1132- }
1072+ ast:: ItemMac ( ..) => { }
11331073 }
11341074 }
11351075
0 commit comments