Skip to content

Commit 12f05e3

Browse files
committed
---
yaml --- r: 95147 b: refs/heads/dist-snap c: ccd9a96 h: refs/heads/master i: 95145: 9b12126 95143: b21569f v: v3
1 parent 8034106 commit 12f05e3

File tree

26 files changed

+384
-270
lines changed

26 files changed

+384
-270
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 4dc3ff9c80bab9da65f3a8323882ec082a80bbeb
9+
refs/heads/dist-snap: ccd9a963f75074da506c05fece1e3c965e742c51
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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_,

branches/dist-snap/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,

branches/dist-snap/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)

branches/dist-snap/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)

branches/dist-snap/src/libextra/time.rs

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,60 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
734734
}
735735

736736
fn do_strftime(format: &str, tm: &Tm) -> ~str {
737+
fn days_in_year(year: int) -> i32 {
738+
if ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))) {
739+
366 /* Days in a leap year */
740+
} else {
741+
365 /* Days in a non-leap year */
742+
}
743+
}
744+
745+
fn iso_week_days(yday: i32, wday: i32) -> int {
746+
/* The number of days from the first day of the first ISO week of this
747+
* year to the year day YDAY with week day WDAY.
748+
* ISO weeks start on Monday. The first ISO week has the year's first
749+
* Thursday.
750+
* YDAY may be as small as yday_minimum.
751+
*/
752+
let yday: int = yday as int;
753+
let wday: int = wday as int;
754+
let iso_week_start_wday: int = 1; /* Monday */
755+
let iso_week1_wday: int = 4; /* Thursday */
756+
let yday_minimum: int = 366;
757+
/* Add enough to the first operand of % to make it nonnegative. */
758+
let big_enough_multiple_of_7: int = (yday_minimum / 7 + 2) * 7;
759+
760+
yday - (yday - wday + iso_week1_wday + big_enough_multiple_of_7) % 7
761+
+ iso_week1_wday - iso_week_start_wday
762+
}
763+
764+
fn iso_week(ch:char, tm: &Tm) -> ~str {
765+
let mut year: int = tm.tm_year as int + 1900;
766+
let mut days: int = iso_week_days (tm.tm_yday, tm.tm_wday);
767+
768+
if (days < 0) {
769+
/* This ISO week belongs to the previous year. */
770+
year -= 1;
771+
days = iso_week_days (tm.tm_yday + (days_in_year(year)), tm.tm_wday);
772+
} else {
773+
let d: int = iso_week_days (tm.tm_yday - (days_in_year(year)),
774+
tm.tm_wday);
775+
if (0 <= d) {
776+
/* This ISO week belongs to the next year. */
777+
year += 1;
778+
days = d;
779+
}
780+
}
781+
782+
match ch {
783+
'G' => format!("{}", year),
784+
'g' => format!("{:02d}", (year % 100 + 100) % 100),
785+
'V' => format!("{:02d}", days / 7 + 1),
786+
_ => ~""
787+
}
788+
}
789+
737790
fn parse_type(ch: char, tm: &Tm) -> ~str {
738-
//FIXME (#2350): Implement missing types.
739791
let die = || format!("strftime: can't understand this format {} ", ch);
740792
match ch {
741793
'A' => match tm.tm_wday as int {
@@ -812,8 +864,8 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
812864
parse_type('m', tm),
813865
parse_type('d', tm))
814866
}
815-
//'G' {}
816-
//'g' {}
867+
'G' => iso_week('G', tm),
868+
'g' => iso_week('g', tm),
817869
'H' => format!("{:02d}", tm.tm_hour),
818870
'I' => {
819871
let mut h = tm.tm_hour;
@@ -855,22 +907,21 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
855907
parse_type('S', tm))
856908
}
857909
't' => ~"\t",
858-
//'U' {}
910+
'U' => format!("{:02d}", (tm.tm_yday - tm.tm_wday + 7) / 7),
859911
'u' => {
860912
let i = tm.tm_wday as int;
861913
(if i == 0 { 7 } else { i }).to_str()
862914
}
863-
//'V' {}
915+
'V' => iso_week('V', tm),
864916
'v' => {
865917
format!("{}-{}-{}",
866918
parse_type('e', tm),
867919
parse_type('b', tm),
868920
parse_type('Y', tm))
869921
}
870-
//'W' {}
922+
'W' => format!("{:02d}", (tm.tm_yday - (tm.tm_wday - 1 + 7) % 7 + 7)
923+
/ 7),
871924
'w' => (tm.tm_wday as int).to_str(),
872-
//'X' {}
873-
//'x' {}
874925
'Y' => (tm.tm_year as int + 1900).to_str(),
875926
'y' => format!("{:02d}", (tm.tm_year as int + 1900) % 100),
876927
'Z' => tm.tm_zone.clone(),
@@ -881,7 +932,7 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
881932
m -= h * 60_i32;
882933
format!("{}{:02d}{:02d}", sign, h, m)
883934
}
884-
//'+' {}
935+
'+' => tm.rfc3339(),
885936
'%' => ~"%",
886937
_ => die()
887938
}
@@ -1222,8 +1273,8 @@ mod tests {
12221273
assert_eq!(local.strftime("%e"), ~"13");
12231274
assert_eq!(local.strftime("%f"), ~"000054321");
12241275
assert_eq!(local.strftime("%F"), ~"2009-02-13");
1225-
// assert!(local.strftime("%G") == "2009");
1226-
// assert!(local.strftime("%g") == "09");
1276+
assert_eq!(local.strftime("%G"), ~"2009");
1277+
assert_eq!(local.strftime("%g"), ~"09");
12271278
assert_eq!(local.strftime("%H"), ~"15");
12281279
assert_eq!(local.strftime("%I"), ~"03");
12291280
assert_eq!(local.strftime("%j"), ~"044");
@@ -1240,16 +1291,17 @@ mod tests {
12401291
assert_eq!(local.strftime("%s"), ~"1234567890");
12411292
assert_eq!(local.strftime("%T"), ~"15:31:30");
12421293
assert_eq!(local.strftime("%t"), ~"\t");
1243-
// assert!(local.strftime("%U") == "06");
1294+
assert_eq!(local.strftime("%U"), ~"06");
12441295
assert_eq!(local.strftime("%u"), ~"5");
1245-
// assert!(local.strftime("%V") == "07");
1296+
assert_eq!(local.strftime("%V"), ~"07");
12461297
assert_eq!(local.strftime("%v"), ~"13-Feb-2009");
1247-
// assert!(local.strftime("%W") == "06");
1298+
assert_eq!(local.strftime("%W"), ~"06");
12481299
assert_eq!(local.strftime("%w"), ~"5");
1249-
// handle "%X"
1250-
// handle "%x"
1300+
assert_eq!(local.strftime("%X"), ~"15:31:30"); // FIXME (#2350): support locale
1301+
assert_eq!(local.strftime("%x"), ~"02/13/09"); // FIXME (#2350): support locale
12511302
assert_eq!(local.strftime("%Y"), ~"2009");
12521303
assert_eq!(local.strftime("%y"), ~"09");
1304+
assert_eq!(local.strftime("%+"), ~"2009-02-13T15:31:30-08:00");
12531305
12541306
// FIXME (#2350): We should probably standardize on the timezone
12551307
// abbreviation.

branches/dist-snap/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),

branches/dist-snap/src/librustc/middle/lint.rs

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,18 @@ impl MissingDocLintVisitor {
13511351
// otherwise, warn!
13521352
cx.span_lint(missing_doc, sp, msg);
13531353
}
1354+
1355+
fn check_struct(&mut self, cx: @mut Context, sdef: @ast::struct_def) {
1356+
for field in sdef.fields.iter() {
1357+
match field.node.kind {
1358+
ast::named_field(_, vis) if vis != ast::private => {
1359+
self.check_attrs(cx, field.node.attrs, field.span,
1360+
"missing documentation for a field");
1361+
}
1362+
ast::unnamed_field | ast::named_field(*) => {}
1363+
}
1364+
}
1365+
}
13541366
}
13551367

13561368
impl Visitor<@mut Context> for MissingDocLintVisitor {
@@ -1395,35 +1407,49 @@ impl SubitemStoppableVisitor for MissingDocLintVisitor {
13951407
}
13961408

13971409
fn visit_item_action(&mut self, it:@ast::item, cx:@mut Context) {
1410+
if it.vis != ast::public {
1411+
return;
1412+
}
13981413

13991414
match it.node {
14001415
// Go ahead and match the fields here instead of using
14011416
// visit_struct_field while we have access to the enclosing
14021417
// struct's visibility
1403-
ast::item_struct(sdef, _) if it.vis == ast::public => {
1418+
ast::item_struct(sdef, _) => {
14041419
self.check_attrs(cx, it.attrs, it.span,
14051420
"missing documentation for a struct");
1406-
for field in sdef.fields.iter() {
1407-
match field.node.kind {
1408-
ast::named_field(_, vis) if vis != ast::private => {
1409-
self.check_attrs(cx, field.node.attrs, field.span,
1410-
"missing documentation for a field");
1411-
}
1412-
ast::unnamed_field | ast::named_field(*) => {}
1413-
}
1414-
}
1421+
self.check_struct(cx, sdef);
14151422
}
14161423

1417-
ast::item_trait(*) if it.vis == ast::public => {
1424+
ast::item_trait(*) => {
14181425
self.check_attrs(cx, it.attrs, it.span,
14191426
"missing documentation for a trait");
14201427
}
14211428

1422-
ast::item_fn(*) if it.vis == ast::public => {
1429+
ast::item_fn(*) => {
14231430
self.check_attrs(cx, it.attrs, it.span,
14241431
"missing documentation for a function");
14251432
}
14261433

1434+
ast::item_enum(ref edef, _) => {
1435+
self.check_attrs(cx, it.attrs, it.span,
1436+
"missing documentation for an enum");
1437+
for variant in edef.variants.iter() {
1438+
if variant.node.vis == ast::private {
1439+
continue;
1440+
}
1441+
1442+
self.check_attrs(cx, variant.node.attrs, variant.span,
1443+
"missing documentation for a variant");
1444+
match variant.node.kind {
1445+
ast::struct_variant_kind(sdef) => {
1446+
self.check_struct(cx, sdef);
1447+
}
1448+
_ => ()
1449+
}
1450+
}
1451+
}
1452+
14271453
_ => {}
14281454
}
14291455
}

0 commit comments

Comments
 (0)