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 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 { Cons(T, @List), Nil, } #[deriving(Eq)] +#[allow(missing_doc)] pub enum MutList { MutCons(T, @mut MutList), 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 7eae6cf9094..d1c88fb7d64 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -1351,6 +1351,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 { @@ -1395,35 +1407,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 = &'static KeyValue; +#[allow(missing_doc)] pub enum KeyValue { 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 { 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() {}