Skip to content

Check enums in missing_doc lint #9675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libextra/getopts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ 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),
}

/// Describes whether an option has an argument.
#[deriving(Clone, Eq)]
#[allow(missing_doc)]
pub enum HasArg {
Yes,
No,
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -151,6 +155,7 @@ pub enum Fail_ {

/// The type of failure that occured.
#[deriving(Eq)]
#[allow(missing_doc)]
pub enum FailType {
ArgumentMissing_,
UnrecognizedOption_,
Expand Down
2 changes: 2 additions & 0 deletions src/libextra/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/libextra/semver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/libextra/terminfo/parm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/libextra/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ struct UuidFields {
}

/// Error details for string parsing failures
#[allow(missing_doc)]
pub enum ParseError {
ErrorInvalidLength(uint),
ErrorInvalidCharacter(char, uint),
Expand Down
50 changes: 38 additions & 12 deletions src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
_ => ()
}
}
}

_ => {}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/libstd/fmt/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/libstd/local_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use util;
*/
pub type Key<T> = &'static KeyValue<T>;

#[allow(missing_doc)]
pub enum KeyValue<T> { Key }

trait LocalData {}
Expand Down
1 change: 1 addition & 0 deletions src/libstd/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ use clone::DeepClone;

/// The option type
#[deriving(Clone, DeepClone, Eq)]
#[allow(missing_doc)]
pub enum Option<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

None,
Some(T),
Expand Down
1 change: 1 addition & 0 deletions src/libstd/send_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
37 changes: 37 additions & 0 deletions src/test/compile-fail/lint-missing-doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand Down