auto merge of #9675 : sfackler/rust/lint, r=alexcrichton

Closes #9671
This commit is contained in:
bors 2013-10-02 13:26:36 -07:00
commit 371a7ec569
11 changed files with 93 additions and 12 deletions

View File

@ -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_,

View File

@ -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,

View File

@ -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)

View File

@ -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)

View File

@ -116,6 +116,7 @@ struct UuidFields {
}
/// Error details for string parsing failures
#[allow(missing_doc)]
pub enum ParseError {
ErrorInvalidLength(uint),
ErrorInvalidCharacter(char, uint),

View File

@ -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);
}
_ => ()
}
}
}
_ => {}
}
}

View File

@ -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
}

View File

@ -59,6 +59,7 @@ use util;
*/
pub type Key<T> = &'static KeyValue<T>;
#[allow(missing_doc)]
pub enum KeyValue<T> { Key }
trait LocalData {}

View File

@ -56,6 +56,7 @@ use clone::DeepClone;
/// The option type
#[deriving(Clone, DeepClone, Eq)]
#[allow(missing_doc)]
pub enum Option<T> {
None,
Some(T),

View File

@ -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)

View File

@ -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() {}