about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2013-10-01 23:26:45 -0700
committerSteven Fackler <sfackler@gmail.com>2013-10-02 08:57:03 -0700
commitb7fe83d573d8073f7d663bee5c0b3e1493b9998d (patch)
tree7ee08b917b0875933e51d50ab92430cf1c5dc475
parent88b0b511beed1599c5bddaf05b9cd0f98bd714ca (diff)
downloadrust-b7fe83d573d8073f7d663bee5c0b3e1493b9998d.tar.gz
rust-b7fe83d573d8073f7d663bee5c0b3e1493b9998d.zip
Check enums in missing_doc lint
Closes #9671
-rw-r--r--src/libextra/getopts.rs5
-rw-r--r--src/libextra/list.rs2
-rw-r--r--src/libextra/semver.rs1
-rw-r--r--src/libextra/terminfo/parm.rs1
-rw-r--r--src/libextra/uuid.rs1
-rw-r--r--src/librustc/middle/lint.rs50
-rw-r--r--src/libstd/fmt/parse.rs5
-rw-r--r--src/libstd/local_data.rs1
-rw-r--r--src/libstd/option.rs1
-rw-r--r--src/libstd/send_str.rs1
-rw-r--r--src/test/compile-fail/lint-missing-doc.rs37
11 files changed, 93 insertions, 12 deletions
diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs
index e9ccbbf605a..a997d49fdde 100644
--- a/src/libextra/getopts.rs
+++ b/src/libextra/getopts.rs
@@ -85,6 +85,7 @@ use std::vec;
 
 /// Name of an option. Either a string or a single char.
 #[deriving(Clone, Eq)]
+#[allow(missing_doc)]
 pub enum Name {
     Long(~str),
     Short(char),
@@ -92,6 +93,7 @@ pub enum Name {
 
 /// Describes whether an option has an argument.
 #[deriving(Clone, Eq)]
+#[allow(missing_doc)]
 pub enum HasArg {
     Yes,
     No,
@@ -100,6 +102,7 @@ pub enum HasArg {
 
 /// Describes how often an option may occur.
 #[deriving(Clone, Eq)]
+#[allow(missing_doc)]
 pub enum Occur {
     Req,
     Optional,
@@ -141,6 +144,7 @@ pub struct Matches {
 /// The type returned when the command line does not conform to the
 /// expected format. Pass this value to <fail_str> to get an error message.
 #[deriving(Clone, Eq, ToStr)]
+#[allow(missing_doc)]
 pub enum Fail_ {
     ArgumentMissing(~str),
     UnrecognizedOption(~str),
@@ -151,6 +155,7 @@ pub enum Fail_ {
 
 /// The type of failure that occured.
 #[deriving(Eq)]
+#[allow(missing_doc)]
 pub enum FailType {
     ArgumentMissing_,
     UnrecognizedOption_,
diff --git a/src/libextra/list.rs b/src/libextra/list.rs
index 5283edbf475..1e494a17913 100644
--- a/src/libextra/list.rs
+++ b/src/libextra/list.rs
@@ -13,12 +13,14 @@
 
 
 #[deriving(Clone, Eq)]
+#[allow(missing_doc)]
 pub enum List<T> {
     Cons(T, @List<T>),
     Nil,
 }
 
 #[deriving(Eq)]
+#[allow(missing_doc)]
 pub enum MutList<T> {
     MutCons(T, @mut MutList<T>),
     MutNil,
diff --git a/src/libextra/semver.rs b/src/libextra/semver.rs
index fff10533af1..8c7d656f541 100644
--- a/src/libextra/semver.rs
+++ b/src/libextra/semver.rs
@@ -38,6 +38,7 @@ use std::to_str::ToStr;
 /// An identifier in the pre-release or build metadata. If the identifier can
 /// be parsed as a decimal value, it will be represented with `Numeric`.
 #[deriving(Clone, Eq)]
+#[allow(missing_doc)]
 pub enum Identifier {
     Numeric(uint),
     AlphaNumeric(~str)
diff --git a/src/libextra/terminfo/parm.rs b/src/libextra/terminfo/parm.rs
index 81c4b35d8d0..d7944bad5fa 100644
--- a/src/libextra/terminfo/parm.rs
+++ b/src/libextra/terminfo/parm.rs
@@ -39,6 +39,7 @@ enum FormatState {
 
 /// Types of parameters a capability can use
 #[deriving(Clone)]
+#[allow(missing_doc)]
 pub enum Param {
     String(~str),
     Number(int)
diff --git a/src/libextra/uuid.rs b/src/libextra/uuid.rs
index 6da97d8628a..a219b8fb557 100644
--- a/src/libextra/uuid.rs
+++ b/src/libextra/uuid.rs
@@ -116,6 +116,7 @@ struct UuidFields {
 }
 
 /// Error details for string parsing failures
+#[allow(missing_doc)]
 pub enum ParseError {
     ErrorInvalidLength(uint),
     ErrorInvalidCharacter(char, uint),
diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs
index 591ca2ada5a..8a70a24bcfa 100644
--- a/src/librustc/middle/lint.rs
+++ b/src/librustc/middle/lint.rs
@@ -1327,6 +1327,18 @@ impl MissingDocLintVisitor {
         // otherwise, warn!
         cx.span_lint(missing_doc, sp, msg);
     }
+
+    fn check_struct(&mut self, cx: @mut Context, sdef: @ast::struct_def) {
+                        for field in sdef.fields.iter() {
+        match field.node.kind {
+            ast::named_field(_, vis) if vis != ast::private => {
+                self.check_attrs(cx, field.node.attrs, field.span,
+                        "missing documentation for a field");
+                }
+                ast::unnamed_field | ast::named_field(*) => {}
+            }
+        }
+    }
 }
 
 impl Visitor<@mut Context> for MissingDocLintVisitor {
@@ -1371,35 +1383,49 @@ impl SubitemStoppableVisitor for MissingDocLintVisitor {
     }
 
     fn visit_item_action(&mut self, it:@ast::item, cx:@mut Context) {
+            if it.vis != ast::public {
+                return;
+            }
 
             match it.node {
                 // Go ahead and match the fields here instead of using
                 // visit_struct_field while we have access to the enclosing
                 // struct's visibility
-                ast::item_struct(sdef, _) if it.vis == ast::public => {
+                ast::item_struct(sdef, _) => {
                     self.check_attrs(cx, it.attrs, it.span,
                                 "missing documentation for a struct");
-                    for field in sdef.fields.iter() {
-                        match field.node.kind {
-                            ast::named_field(_, vis) if vis != ast::private => {
-                                self.check_attrs(cx, field.node.attrs, field.span,
-                                            "missing documentation for a field");
-                            }
-                            ast::unnamed_field | ast::named_field(*) => {}
-                        }
-                    }
+                    self.check_struct(cx, sdef);
                 }
 
-                ast::item_trait(*) if it.vis == ast::public => {
+                ast::item_trait(*) => {
                     self.check_attrs(cx, it.attrs, it.span,
                                 "missing documentation for a trait");
                 }
 
-                ast::item_fn(*) if it.vis == ast::public => {
+                ast::item_fn(*) => {
                     self.check_attrs(cx, it.attrs, it.span,
                                 "missing documentation for a function");
                 }
 
+                ast::item_enum(ref edef, _) => {
+                    self.check_attrs(cx, it.attrs, it.span,
+                                "missing documentation for an enum");
+                    for variant in edef.variants.iter() {
+                        if variant.node.vis == ast::private {
+                            continue;
+                        }
+
+                        self.check_attrs(cx, variant.node.attrs, variant.span,
+                                        "missing documentation for a variant");
+                        match variant.node.kind {
+                            ast::struct_variant_kind(sdef) => {
+                                self.check_struct(cx, sdef);
+                            }
+                            _ => ()
+                        }
+                    }
+                }
+
                 _ => {}
             }
     }
diff --git a/src/libstd/fmt/parse.rs b/src/libstd/fmt/parse.rs
index b185b67d09c..a95bd563a81 100644
--- a/src/libstd/fmt/parse.rs
+++ b/src/libstd/fmt/parse.rs
@@ -61,17 +61,20 @@ pub struct FormatSpec<'self> {
 
 /// Enum describing where an argument for a format can be located.
 #[deriving(Eq)]
+#[allow(missing_doc)]
 pub enum Position<'self> {
     ArgumentNext, ArgumentIs(uint), ArgumentNamed(&'self str)
 }
 
 /// Enum of alignments which are supported.
 #[deriving(Eq)]
+#[allow(missing_doc)]
 pub enum Alignment { AlignLeft, AlignRight, AlignUnknown }
 
 /// Various flags which can be applied to format strings, the meaning of these
 /// flags is defined by the formatters themselves.
 #[deriving(Eq)]
+#[allow(missing_doc)]
 pub enum Flag {
     FlagSignPlus,
     FlagSignMinus,
@@ -82,6 +85,7 @@ pub enum Flag {
 /// A count is used for the precision and width parameters of an integer, and
 /// can reference either an argument or a literal integer.
 #[deriving(Eq)]
+#[allow(missing_doc)]
 pub enum Count {
     CountIs(uint),
     CountIsParam(uint),
@@ -126,6 +130,7 @@ pub struct PluralArm<'self> {
 ///
 /// http://www.icu-project.org/apiref/icu4c/classicu_1_1PluralRules.html
 #[deriving(Eq, IterBytes)]
+#[allow(missing_doc)]
 pub enum PluralKeyword {
     Zero, One, Two, Few, Many
 }
diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs
index 54c77e2d9f6..c4d0523fdf4 100644
--- a/src/libstd/local_data.rs
+++ b/src/libstd/local_data.rs
@@ -59,6 +59,7 @@ use util;
  */
 pub type Key<T> = &'static KeyValue<T>;
 
+#[allow(missing_doc)]
 pub enum KeyValue<T> { Key }
 
 trait LocalData {}
diff --git a/src/libstd/option.rs b/src/libstd/option.rs
index 033515875dd..5c7ae63d391 100644
--- a/src/libstd/option.rs
+++ b/src/libstd/option.rs
@@ -56,6 +56,7 @@ use clone::DeepClone;
 
 /// The option type
 #[deriving(Clone, DeepClone, Eq)]
+#[allow(missing_doc)]
 pub enum Option<T> {
     None,
     Some(T),
diff --git a/src/libstd/send_str.rs b/src/libstd/send_str.rs
index d674b4980dd..075c1abd25c 100644
--- a/src/libstd/send_str.rs
+++ b/src/libstd/send_str.rs
@@ -22,6 +22,7 @@ use to_bytes::{IterBytes, Cb};
 /// A SendStr is a string that can hold either a ~str or a &'static str.
 /// This can be useful as an optimization when an allocation is sometimes
 /// needed but the common case is statically known.
+#[allow(missing_doc)]
 pub enum SendStr {
     SendStrOwned(~str),
     SendStrStatic(&'static str)
diff --git a/src/test/compile-fail/lint-missing-doc.rs b/src/test/compile-fail/lint-missing-doc.rs
index 75bc93c6d0b..e155089c31a 100644
--- a/src/test/compile-fail/lint-missing-doc.rs
+++ b/src/test/compile-fail/lint-missing-doc.rs
@@ -77,6 +77,43 @@ mod a {
     }
 }
 
+enum Baz {
+    BazA {
+        a: int,
+        priv b: int
+    },
+    BarB
+}
+
+pub enum PubBaz { //~ ERROR: missing documentation
+    PubBazA { //~ ERROR: missing documentation
+        a: int, //~ ERROR: missing documentation
+        priv b: int
+    },
+
+    priv PubBazB
+}
+
+/// dox
+pub enum PubBaz2 {
+    /// dox
+    PubBaz2A {
+        /// dox
+        a: int,
+        priv b: int
+    },
+    priv PubBaz2B
+}
+
+#[allow(missing_doc)]
+pub enum PubBaz3 {
+    PubBaz3A {
+        a: int,
+        priv b: int
+    },
+    priv PubBaz3B
+}
+
 #[doc(hidden)]
 pub fn baz() {}