@@ -1327,6 +1327,18 @@ impl MissingDocLintVisitor {
1327
1327
// otherwise, warn!
1328
1328
cx. span_lint ( missing_doc, sp, msg) ;
1329
1329
}
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
+ }
1330
1342
}
1331
1343
1332
1344
impl Visitor < @mut Context > for MissingDocLintVisitor {
@@ -1371,35 +1383,49 @@ impl SubitemStoppableVisitor for MissingDocLintVisitor {
1371
1383
}
1372
1384
1373
1385
fn visit_item_action ( & mut self , it : @ast:: item , cx : @mut Context ) {
1386
+ if it. vis != ast:: public {
1387
+ return ;
1388
+ }
1374
1389
1375
1390
match it. node {
1376
1391
// Go ahead and match the fields here instead of using
1377
1392
// visit_struct_field while we have access to the enclosing
1378
1393
// struct's visibility
1379
- ast:: item_struct( sdef, _) if it . vis == ast :: public => {
1394
+ ast:: item_struct( sdef, _) => {
1380
1395
self . check_attrs ( cx, it. attrs , it. span ,
1381
1396
"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) ;
1391
1398
}
1392
1399
1393
- ast:: item_trait( * ) if it . vis == ast :: public => {
1400
+ ast:: item_trait( * ) => {
1394
1401
self . check_attrs ( cx, it. attrs , it. span ,
1395
1402
"missing documentation for a trait" ) ;
1396
1403
}
1397
1404
1398
- ast:: item_fn( * ) if it . vis == ast :: public => {
1405
+ ast:: item_fn( * ) => {
1399
1406
self . check_attrs ( cx, it. attrs , it. span ,
1400
1407
"missing documentation for a function" ) ;
1401
1408
}
1402
1409
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
+
1403
1429
_ => { }
1404
1430
}
1405
1431
}
0 commit comments