@@ -972,16 +972,23 @@ fn lint_unnecessary_allocations(cx: @mut Context) -> visit::vt<()> {
972972fn lint_missing_struct_doc( cx: @mut Context ) -> visit:: vt<( ) > {
973973 visit:: mk_simple_visitor ( @visit:: SimpleVisitor {
974974 visit_struct_field : |field| {
975- let mut has_doc = false ;
976- for field. node. attrs. each |attr| {
977- if attr. node . is_sugared_doc {
978- has_doc = true ;
979- break ;
975+ let relevant = match field. node . kind {
976+ ast:: named_field( _, vis) => vis != ast:: private,
977+ ast:: unnamed_field => false ,
978+ } ;
979+
980+ if relevant {
981+ let mut has_doc = false ;
982+ for field. node. attrs. each |attr| {
983+ if attr. node . is_sugared_doc {
984+ has_doc = true ;
985+ break ;
986+ }
987+ }
988+ if !has_doc {
989+ cx. span_lint ( missing_struct_doc, field. span , "missing documentation \
990+ for a field.") ;
980991 }
981- }
982- if !has_doc {
983- cx. span_lint ( missing_struct_doc, field. span , "missing documentation \
984- for a field.") ;
985992 }
986993 } ,
987994 .. * visit:: default_simple_visitor ( )
@@ -1003,18 +1010,22 @@ fn lint_missing_trait_doc(cx: @mut Context) -> visit::vt<()> {
10031010 m. span
10041011 } ,
10051012 ast:: provided( m) => {
1006- for m. attrs. each |attr| {
1007- if attr. node . is_sugared_doc {
1008- has_doc = true ;
1009- break ;
1013+ if m. vis == ast:: private {
1014+ has_doc = true ;
1015+ } else {
1016+ for m. attrs . each |attr| {
1017+ if attr. node . is_sugared_doc {
1018+ has_doc = true ;
1019+ break ;
1020+ }
10101021 }
10111022 }
10121023 m. span
10131024 }
10141025 } ;
10151026 if !has_doc {
10161027 cx. span_lint ( missing_trait_doc, span, "missing documentation \
1017- for a method.") ;
1028+ for a method.") ;
10181029 }
10191030 } ,
10201031 .. * visit:: default_simple_visitor ( )
0 commit comments