@@ -1351,6 +1351,18 @@ impl MissingDocLintVisitor {
1351
1351
// otherwise, warn!
1352
1352
cx. span_lint ( missing_doc, sp, msg) ;
1353
1353
}
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
+ }
1354
1366
}
1355
1367
1356
1368
impl Visitor < @mut Context > for MissingDocLintVisitor {
@@ -1395,35 +1407,49 @@ impl SubitemStoppableVisitor for MissingDocLintVisitor {
1395
1407
}
1396
1408
1397
1409
fn visit_item_action ( & mut self , it : @ast:: item , cx : @mut Context ) {
1410
+ if it. vis != ast:: public {
1411
+ return ;
1412
+ }
1398
1413
1399
1414
match it. node {
1400
1415
// Go ahead and match the fields here instead of using
1401
1416
// visit_struct_field while we have access to the enclosing
1402
1417
// struct's visibility
1403
- ast:: item_struct( sdef, _) if it . vis == ast :: public => {
1418
+ ast:: item_struct( sdef, _) => {
1404
1419
self . check_attrs ( cx, it. attrs , it. span ,
1405
1420
"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) ;
1415
1422
}
1416
1423
1417
- ast:: item_trait( * ) if it . vis == ast :: public => {
1424
+ ast:: item_trait( * ) => {
1418
1425
self . check_attrs ( cx, it. attrs , it. span ,
1419
1426
"missing documentation for a trait" ) ;
1420
1427
}
1421
1428
1422
- ast:: item_fn( * ) if it . vis == ast :: public => {
1429
+ ast:: item_fn( * ) => {
1423
1430
self . check_attrs ( cx, it. attrs , it. span ,
1424
1431
"missing documentation for a function" ) ;
1425
1432
}
1426
1433
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
+
1427
1453
_ => { }
1428
1454
}
1429
1455
}
0 commit comments