@@ -1327,6 +1327,18 @@ impl MissingDocLintVisitor {
13271327 // otherwise, warn!
13281328 cx. span_lint ( missing_doc, sp, msg) ;
13291329 }
1330+
1331+ fn check_struct ( & mut self , cx : @mut Context , sdef : @ast:: struct_def ) {
1332+ for field in sdef. fields . iter ( ) {
1333+ match field. node . kind {
1334+ ast:: named_field( _, vis) if vis != ast:: private => {
1335+ self . check_attrs ( cx, field. node . attrs , field. span ,
1336+ "missing documentation for a field" ) ;
1337+ }
1338+ ast:: unnamed_field | ast:: named_field( * ) => { }
1339+ }
1340+ }
1341+ }
13301342}
13311343
13321344impl Visitor < @mut Context > for MissingDocLintVisitor {
@@ -1371,35 +1383,49 @@ impl SubitemStoppableVisitor for MissingDocLintVisitor {
13711383 }
13721384
13731385 fn visit_item_action ( & mut self , it : @ast:: item , cx : @mut Context ) {
1386+ if it. vis != ast:: public {
1387+ return ;
1388+ }
13741389
13751390 match it. node {
13761391 // Go ahead and match the fields here instead of using
13771392 // visit_struct_field while we have access to the enclosing
13781393 // struct's visibility
1379- ast:: item_struct( sdef, _) if it . vis == ast :: public => {
1394+ ast:: item_struct( sdef, _) => {
13801395 self . check_attrs ( cx, it. attrs , it. span ,
13811396 "missing documentation for a struct" ) ;
1382- for field in sdef. fields . iter ( ) {
1383- match field. node . kind {
1384- ast:: named_field( _, vis) if vis != ast:: private => {
1385- self . check_attrs ( cx, field. node . attrs , field. span ,
1386- "missing documentation for a field" ) ;
1387- }
1388- ast:: unnamed_field | ast:: named_field( * ) => { }
1389- }
1390- }
1397+ self . check_struct ( cx, sdef) ;
13911398 }
13921399
1393- ast:: item_trait( * ) if it . vis == ast :: public => {
1400+ ast:: item_trait( * ) => {
13941401 self . check_attrs ( cx, it. attrs , it. span ,
13951402 "missing documentation for a trait" ) ;
13961403 }
13971404
1398- ast:: item_fn( * ) if it . vis == ast :: public => {
1405+ ast:: item_fn( * ) => {
13991406 self . check_attrs ( cx, it. attrs , it. span ,
14001407 "missing documentation for a function" ) ;
14011408 }
14021409
1410+ ast:: item_enum( ref edef, _) => {
1411+ self . check_attrs ( cx, it. attrs , it. span ,
1412+ "missing documentation for an enum" ) ;
1413+ for variant in edef. variants . iter ( ) {
1414+ if variant. node . vis == ast:: private {
1415+ continue ;
1416+ }
1417+
1418+ self . check_attrs ( cx, variant. node . attrs , variant. span ,
1419+ "missing documentation for a variant" ) ;
1420+ match variant. node . kind {
1421+ ast:: struct_variant_kind( sdef) => {
1422+ self . check_struct ( cx, sdef) ;
1423+ }
1424+ _ => ( )
1425+ }
1426+ }
1427+ }
1428+
14031429 _ => { }
14041430 }
14051431 }
0 commit comments