@@ -972,16 +972,23 @@ fn lint_unnecessary_allocations(cx: @mut Context) -> visit::vt<()> {
972
972
fn lint_missing_struct_doc( cx: @mut Context ) -> visit:: vt<( ) > {
973
973
visit:: mk_simple_visitor ( @visit:: SimpleVisitor {
974
974
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.") ;
980
991
}
981
- }
982
- if !has_doc {
983
- cx. span_lint ( missing_struct_doc, field. span , "missing documentation \
984
- for a field.") ;
985
992
}
986
993
} ,
987
994
.. * visit:: default_simple_visitor ( )
@@ -1003,18 +1010,22 @@ fn lint_missing_trait_doc(cx: @mut Context) -> visit::vt<()> {
1003
1010
m. span
1004
1011
} ,
1005
1012
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
+ }
1010
1021
}
1011
1022
}
1012
1023
m. span
1013
1024
}
1014
1025
} ;
1015
1026
if !has_doc {
1016
1027
cx. span_lint ( missing_trait_doc, span, "missing documentation \
1017
- for a method.") ;
1028
+ for a method.") ;
1018
1029
}
1019
1030
} ,
1020
1031
.. * visit:: default_simple_visitor ( )
0 commit comments