Skip to content

Commit b7fe83d

Browse files
committed
Check enums in missing_doc lint
Closes #9671
1 parent 88b0b51 commit b7fe83d

File tree

11 files changed

+93
-12
lines changed

11 files changed

+93
-12
lines changed

src/libextra/getopts.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ use std::vec;
8585

8686
/// Name of an option. Either a string or a single char.
8787
#[deriving(Clone, Eq)]
88+
#[allow(missing_doc)]
8889
pub enum Name {
8990
Long(~str),
9091
Short(char),
9192
}
9293

9394
/// Describes whether an option has an argument.
9495
#[deriving(Clone, Eq)]
96+
#[allow(missing_doc)]
9597
pub enum HasArg {
9698
Yes,
9799
No,
@@ -100,6 +102,7 @@ pub enum HasArg {
100102

101103
/// Describes how often an option may occur.
102104
#[deriving(Clone, Eq)]
105+
#[allow(missing_doc)]
103106
pub enum Occur {
104107
Req,
105108
Optional,
@@ -141,6 +144,7 @@ pub struct Matches {
141144
/// The type returned when the command line does not conform to the
142145
/// expected format. Pass this value to <fail_str> to get an error message.
143146
#[deriving(Clone, Eq, ToStr)]
147+
#[allow(missing_doc)]
144148
pub enum Fail_ {
145149
ArgumentMissing(~str),
146150
UnrecognizedOption(~str),
@@ -151,6 +155,7 @@ pub enum Fail_ {
151155

152156
/// The type of failure that occured.
153157
#[deriving(Eq)]
158+
#[allow(missing_doc)]
154159
pub enum FailType {
155160
ArgumentMissing_,
156161
UnrecognizedOption_,

src/libextra/list.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313

1414

1515
#[deriving(Clone, Eq)]
16+
#[allow(missing_doc)]
1617
pub enum List<T> {
1718
Cons(T, @List<T>),
1819
Nil,
1920
}
2021

2122
#[deriving(Eq)]
23+
#[allow(missing_doc)]
2224
pub enum MutList<T> {
2325
MutCons(T, @mut MutList<T>),
2426
MutNil,

src/libextra/semver.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use std::to_str::ToStr;
3838
/// An identifier in the pre-release or build metadata. If the identifier can
3939
/// be parsed as a decimal value, it will be represented with `Numeric`.
4040
#[deriving(Clone, Eq)]
41+
#[allow(missing_doc)]
4142
pub enum Identifier {
4243
Numeric(uint),
4344
AlphaNumeric(~str)

src/libextra/terminfo/parm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ enum FormatState {
3939

4040
/// Types of parameters a capability can use
4141
#[deriving(Clone)]
42+
#[allow(missing_doc)]
4243
pub enum Param {
4344
String(~str),
4445
Number(int)

src/libextra/uuid.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ struct UuidFields {
116116
}
117117

118118
/// Error details for string parsing failures
119+
#[allow(missing_doc)]
119120
pub enum ParseError {
120121
ErrorInvalidLength(uint),
121122
ErrorInvalidCharacter(char, uint),

src/librustc/middle/lint.rs

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,18 @@ impl MissingDocLintVisitor {
13271327
// otherwise, warn!
13281328
cx.span_lint(missing_doc, sp, msg);
13291329
}
1330+
1331+
fn check_struct(&mut self, cx: @mut Context, sdef: @ast::struct_def) {
1332+
for field in sdef.fields.iter() {
1333+
match field.node.kind {
1334+
ast::named_field(_, vis) if vis != ast::private => {
1335+
self.check_attrs(cx, field.node.attrs, field.span,
1336+
"missing documentation for a field");
1337+
}
1338+
ast::unnamed_field | ast::named_field(*) => {}
1339+
}
1340+
}
1341+
}
13301342
}
13311343

13321344
impl Visitor<@mut Context> for MissingDocLintVisitor {
@@ -1371,35 +1383,49 @@ impl SubitemStoppableVisitor for MissingDocLintVisitor {
13711383
}
13721384

13731385
fn visit_item_action(&mut self, it:@ast::item, cx:@mut Context) {
1386+
if it.vis != ast::public {
1387+
return;
1388+
}
13741389

13751390
match it.node {
13761391
// Go ahead and match the fields here instead of using
13771392
// visit_struct_field while we have access to the enclosing
13781393
// struct's visibility
1379-
ast::item_struct(sdef, _) if it.vis == ast::public => {
1394+
ast::item_struct(sdef, _) => {
13801395
self.check_attrs(cx, it.attrs, it.span,
13811396
"missing documentation for a struct");
1382-
for field in sdef.fields.iter() {
1383-
match field.node.kind {
1384-
ast::named_field(_, vis) if vis != ast::private => {
1385-
self.check_attrs(cx, field.node.attrs, field.span,
1386-
"missing documentation for a field");
1387-
}
1388-
ast::unnamed_field | ast::named_field(*) => {}
1389-
}
1390-
}
1397+
self.check_struct(cx, sdef);
13911398
}
13921399

1393-
ast::item_trait(*) if it.vis == ast::public => {
1400+
ast::item_trait(*) => {
13941401
self.check_attrs(cx, it.attrs, it.span,
13951402
"missing documentation for a trait");
13961403
}
13971404

1398-
ast::item_fn(*) if it.vis == ast::public => {
1405+
ast::item_fn(*) => {
13991406
self.check_attrs(cx, it.attrs, it.span,
14001407
"missing documentation for a function");
14011408
}
14021409

1410+
ast::item_enum(ref edef, _) => {
1411+
self.check_attrs(cx, it.attrs, it.span,
1412+
"missing documentation for an enum");
1413+
for variant in edef.variants.iter() {
1414+
if variant.node.vis == ast::private {
1415+
continue;
1416+
}
1417+
1418+
self.check_attrs(cx, variant.node.attrs, variant.span,
1419+
"missing documentation for a variant");
1420+
match variant.node.kind {
1421+
ast::struct_variant_kind(sdef) => {
1422+
self.check_struct(cx, sdef);
1423+
}
1424+
_ => ()
1425+
}
1426+
}
1427+
}
1428+
14031429
_ => {}
14041430
}
14051431
}

src/libstd/fmt/parse.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,20 @@ pub struct FormatSpec<'self> {
6161

6262
/// Enum describing where an argument for a format can be located.
6363
#[deriving(Eq)]
64+
#[allow(missing_doc)]
6465
pub enum Position<'self> {
6566
ArgumentNext, ArgumentIs(uint), ArgumentNamed(&'self str)
6667
}
6768

6869
/// Enum of alignments which are supported.
6970
#[deriving(Eq)]
71+
#[allow(missing_doc)]
7072
pub enum Alignment { AlignLeft, AlignRight, AlignUnknown }
7173

7274
/// Various flags which can be applied to format strings, the meaning of these
7375
/// flags is defined by the formatters themselves.
7476
#[deriving(Eq)]
77+
#[allow(missing_doc)]
7578
pub enum Flag {
7679
FlagSignPlus,
7780
FlagSignMinus,
@@ -82,6 +85,7 @@ pub enum Flag {
8285
/// A count is used for the precision and width parameters of an integer, and
8386
/// can reference either an argument or a literal integer.
8487
#[deriving(Eq)]
88+
#[allow(missing_doc)]
8589
pub enum Count {
8690
CountIs(uint),
8791
CountIsParam(uint),
@@ -126,6 +130,7 @@ pub struct PluralArm<'self> {
126130
///
127131
/// http://www.icu-project.org/apiref/icu4c/classicu_1_1PluralRules.html
128132
#[deriving(Eq, IterBytes)]
133+
#[allow(missing_doc)]
129134
pub enum PluralKeyword {
130135
Zero, One, Two, Few, Many
131136
}

src/libstd/local_data.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ use util;
5959
*/
6060
pub type Key<T> = &'static KeyValue<T>;
6161

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

6465
trait LocalData {}

src/libstd/option.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ use clone::DeepClone;
5656

5757
/// The option type
5858
#[deriving(Clone, DeepClone, Eq)]
59+
#[allow(missing_doc)]
5960
pub enum Option<T> {
6061
None,
6162
Some(T),

src/libstd/send_str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use to_bytes::{IterBytes, Cb};
2222
/// A SendStr is a string that can hold either a ~str or a &'static str.
2323
/// This can be useful as an optimization when an allocation is sometimes
2424
/// needed but the common case is statically known.
25+
#[allow(missing_doc)]
2526
pub enum SendStr {
2627
SendStrOwned(~str),
2728
SendStrStatic(&'static str)

src/test/compile-fail/lint-missing-doc.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,43 @@ mod a {
7777
}
7878
}
7979

80+
enum Baz {
81+
BazA {
82+
a: int,
83+
priv b: int
84+
},
85+
BarB
86+
}
87+
88+
pub enum PubBaz { //~ ERROR: missing documentation
89+
PubBazA { //~ ERROR: missing documentation
90+
a: int, //~ ERROR: missing documentation
91+
priv b: int
92+
},
93+
94+
priv PubBazB
95+
}
96+
97+
/// dox
98+
pub enum PubBaz2 {
99+
/// dox
100+
PubBaz2A {
101+
/// dox
102+
a: int,
103+
priv b: int
104+
},
105+
priv PubBaz2B
106+
}
107+
108+
#[allow(missing_doc)]
109+
pub enum PubBaz3 {
110+
PubBaz3A {
111+
a: int,
112+
priv b: int
113+
},
114+
priv PubBaz3B
115+
}
116+
80117
#[doc(hidden)]
81118
pub fn baz() {}
82119

0 commit comments

Comments
 (0)