@@ -67,18 +67,10 @@ impl Visitor<()> for ParentVisitor {
67
67
// they inherit privacy
68
68
ast:: ItemEnum ( ref def, _) => {
69
69
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 ) ;
82
74
}
83
75
}
84
76
@@ -224,9 +216,7 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> {
224
216
// public all variants are public unless they're explicitly priv
225
217
ast:: ItemEnum ( ref def, _) if public_first => {
226
218
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 ) ;
230
220
}
231
221
}
232
222
@@ -462,10 +452,7 @@ impl<'a> PrivacyVisitor<'a> {
462
452
Some ( ast_map:: NodeForeignItem ( _) ) => {
463
453
self . tcx . map . get_foreign_vis ( closest_private_id)
464
454
}
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 ( ..) ) => {
469
456
ast:: Public // need to move up a level (to the enum)
470
457
}
471
458
_ => ast:: Public ,
@@ -997,10 +984,6 @@ impl<'a> Visitor<()> for SanePrivacyVisitor<'a> {
997
984
fn visit_view_item ( & mut self , i : & ast:: ViewItem , _: ( ) ) {
998
985
match i. vis {
999
986
ast:: Inherited => { }
1000
- ast:: Private => {
1001
- self . tcx . sess . span_err ( i. span , "unnecessary visibility \
1002
- qualifier") ;
1003
- }
1004
987
ast:: Public => {
1005
988
if self . in_fn {
1006
989
self . tcx . sess . span_err ( i. span , "unnecessary `pub`, imports \
@@ -1036,25 +1019,6 @@ impl<'a> SanePrivacyVisitor<'a> {
1036
1019
}
1037
1020
}
1038
1021
} ;
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
- } ;
1058
1022
match item. node {
1059
1023
// implementations of traits don't need visibility qualifiers because
1060
1024
// that's controlled by having the trait in scope.
@@ -1067,22 +1031,14 @@ impl<'a> SanePrivacyVisitor<'a> {
1067
1031
}
1068
1032
}
1069
1033
1070
- ast:: ItemImpl ( _ , _ , _ , ref methods ) => {
1034
+ ast:: ItemImpl ( .. ) => {
1071
1035
check_inherited ( item. span , item. vis ,
1072
1036
"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
- }
1077
1037
}
1078
- ast:: ItemForeignMod ( ref fm ) => {
1038
+ ast:: ItemForeignMod ( .. ) => {
1079
1039
check_inherited ( item. span , item. vis ,
1080
1040
"place qualifiers on individual functions \
1081
1041
instead") ;
1082
- for i in fm. items . iter ( ) {
1083
- check_not_priv ( i. span , i. vis , "functions are private by \
1084
- default") ;
1085
- }
1086
1042
}
1087
1043
1088
1044
ast:: ItemEnum ( ref def, _) => {
@@ -1094,24 +1050,11 @@ impl<'a> SanePrivacyVisitor<'a> {
1094
1050
visibility") ;
1095
1051
}
1096
1052
}
1097
- ast:: Private => {
1098
- if item. vis != ast:: Public {
1099
- tcx. sess . span_err ( v. span , "unnecessary `priv` \
1100
- visibility") ;
1101
- }
1102
- }
1103
1053
ast:: Inherited => { }
1104
1054
}
1105
-
1106
- match v. node . kind {
1107
- ast:: StructVariantKind ( ref s) => check_struct ( s) ,
1108
- ast:: TupleVariantKind ( ..) => { }
1109
- }
1110
1055
}
1111
1056
}
1112
1057
1113
- ast:: ItemStruct ( ref def, _) => check_struct ( def) ,
1114
-
1115
1058
ast:: ItemTrait ( _, _, ref methods) => {
1116
1059
for m in methods. iter ( ) {
1117
1060
match * m {
@@ -1124,12 +1067,9 @@ impl<'a> SanePrivacyVisitor<'a> {
1124
1067
}
1125
1068
}
1126
1069
1127
- ast:: ItemStatic ( ..) |
1070
+ ast:: ItemStatic ( ..) | ast :: ItemStruct ( .. ) |
1128
1071
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 ( ..) => { }
1133
1073
}
1134
1074
}
1135
1075
0 commit comments