about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGábor Horváth <xazax.hun@gmail.com>2013-05-24 14:13:41 +0200
committerGábor Horváth <xazax.hun@gmail.com>2013-05-24 14:13:41 +0200
commit3d61931fcac13aadc88ece7e48567f7ff503fba5 (patch)
tree5485cfc71da2f3d0cd594a2b3c134ff62dde8740
parentc6581325ac38ce3f96cb7a0ea0aad35feed173c1 (diff)
downloadrust-3d61931fcac13aadc88ece7e48567f7ff503fba5.tar.gz
rust-3d61931fcac13aadc88ece7e48567f7ff503fba5.zip
Only trigger missing documentation warnings to public functions and fields.
-rw-r--r--src/librustc/middle/lint.rs39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs
index 50d127869e5..a49dfc97f71 100644
--- a/src/librustc/middle/lint.rs
+++ b/src/librustc/middle/lint.rs
@@ -972,16 +972,23 @@ fn lint_unnecessary_allocations(cx: @mut Context) -> visit::vt<()> {
 fn lint_missing_struct_doc(cx: @mut Context) -> visit::vt<()> {
     visit::mk_simple_visitor(@visit::SimpleVisitor {
         visit_struct_field: |field| {
-            let mut has_doc = false;
-            for field.node.attrs.each |attr| {
-                if attr.node.is_sugared_doc {
-                    has_doc = true;
-                    break;
+            let relevant = match field.node.kind {
+                ast::named_field(_, vis) => vis != ast::private,
+                ast::unnamed_field => false,
+            };
+
+            if relevant {
+                let mut has_doc = false;
+                for field.node.attrs.each |attr| {
+                    if attr.node.is_sugared_doc {
+                        has_doc = true;
+                        break;
+                    }
+                }
+                if !has_doc {
+                    cx.span_lint(missing_struct_doc, field.span, "missing documentation \
+                                                                  for a field.");
                 }
-            }
-            if !has_doc {
-                cx.span_lint(missing_struct_doc, field.span, "missing documentation \
-                                                              for a field.");
             }
         },
         .. *visit::default_simple_visitor()
@@ -1003,10 +1010,14 @@ fn lint_missing_trait_doc(cx: @mut Context) -> visit::vt<()> {
                     m.span
                 },
                 ast::provided(m) => {
-                    for m.attrs.each |attr| {
-                        if attr.node.is_sugared_doc {
-                            has_doc = true;
-                            break;
+                    if m.vis == ast::private {
+                        has_doc = true;
+                    } else {
+                        for m.attrs.each |attr| {
+                            if attr.node.is_sugared_doc {
+                                has_doc = true;
+                                break;
+                            }
                         }
                     }
                     m.span
@@ -1014,7 +1025,7 @@ fn lint_missing_trait_doc(cx: @mut Context) -> visit::vt<()> {
             };
             if !has_doc {
                 cx.span_lint(missing_trait_doc, span, "missing documentation \
-                                                        for a method.");
+                                                       for a method.");
             }
         },
         .. *visit::default_simple_visitor()