@@ -1351,6 +1351,18 @@ impl MissingDocLintVisitor {
13511351 // otherwise, warn!
13521352 cx. span_lint ( missing_doc, sp, msg) ;
13531353 }
1354+
1355+ fn check_struct ( & mut self , cx : @mut Context , sdef : @ast:: struct_def ) {
1356+ for field in sdef. fields . iter ( ) {
1357+ match field. node . kind {
1358+ ast:: named_field( _, vis) if vis != ast:: private => {
1359+ self . check_attrs ( cx, field. node . attrs , field. span ,
1360+ "missing documentation for a field" ) ;
1361+ }
1362+ ast:: unnamed_field | ast:: named_field( * ) => { }
1363+ }
1364+ }
1365+ }
13541366}
13551367
13561368impl Visitor < @mut Context > for MissingDocLintVisitor {
@@ -1395,35 +1407,49 @@ impl SubitemStoppableVisitor for MissingDocLintVisitor {
13951407 }
13961408
13971409 fn visit_item_action ( & mut self , it : @ast:: item , cx : @mut Context ) {
1410+ if it. vis != ast:: public {
1411+ return ;
1412+ }
13981413
13991414 match it. node {
14001415 // Go ahead and match the fields here instead of using
14011416 // visit_struct_field while we have access to the enclosing
14021417 // struct's visibility
1403- ast:: item_struct( sdef, _) if it . vis == ast :: public => {
1418+ ast:: item_struct( sdef, _) => {
14041419 self . check_attrs ( cx, it. attrs , it. span ,
14051420 "missing documentation for a struct" ) ;
1406- for field in sdef. fields . iter ( ) {
1407- match field. node . kind {
1408- ast:: named_field( _, vis) if vis != ast:: private => {
1409- self . check_attrs ( cx, field. node . attrs , field. span ,
1410- "missing documentation for a field" ) ;
1411- }
1412- ast:: unnamed_field | ast:: named_field( * ) => { }
1413- }
1414- }
1421+ self . check_struct ( cx, sdef) ;
14151422 }
14161423
1417- ast:: item_trait( * ) if it . vis == ast :: public => {
1424+ ast:: item_trait( * ) => {
14181425 self . check_attrs ( cx, it. attrs , it. span ,
14191426 "missing documentation for a trait" ) ;
14201427 }
14211428
1422- ast:: item_fn( * ) if it . vis == ast :: public => {
1429+ ast:: item_fn( * ) => {
14231430 self . check_attrs ( cx, it. attrs , it. span ,
14241431 "missing documentation for a function" ) ;
14251432 }
14261433
1434+ ast:: item_enum( ref edef, _) => {
1435+ self . check_attrs ( cx, it. attrs , it. span ,
1436+ "missing documentation for an enum" ) ;
1437+ for variant in edef. variants . iter ( ) {
1438+ if variant. node . vis == ast:: private {
1439+ continue ;
1440+ }
1441+
1442+ self . check_attrs ( cx, variant. node . attrs , variant. span ,
1443+ "missing documentation for a variant" ) ;
1444+ match variant. node . kind {
1445+ ast:: struct_variant_kind( sdef) => {
1446+ self . check_struct ( cx, sdef) ;
1447+ }
1448+ _ => ( )
1449+ }
1450+ }
1451+ }
1452+
14271453 _ => { }
14281454 }
14291455 }
0 commit comments