Skip to content

Commit ec67fea

Browse files
committed
---
yaml --- r: 162734 b: refs/heads/try c: 232ffa0 h: refs/heads/master v: v3
1 parent d5d2ab0 commit ec67fea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1060
-1656
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 9146a919b616e39e528e4d7100d16eef52f1f852
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cafe2966770ff377aad6dd9fd808e68055587c58
5-
refs/heads/try: de95ad4c46788518822326941bdc5084b1023abf
5+
refs/heads/try: 232ffa039ddb349c9e9c08d0872aaf95970a1369
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/mk/target.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
7979
$$(dir $$@)$$(call CFG_LIB_GLOB_$(2),$(4)))
8080
$$(call REMOVE_ALL_OLD_GLOB_MATCHES, \
8181
$$(dir $$@)$$(call CFG_RLIB_GLOB,$(4)))
82-
$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(3)) \
82+
$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(2)) \
8383
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) \
8484
$$(RUST_LIB_FLAGS_ST$(1)) \
8585
-L "$$(RT_OUTPUT_DIR_$(2))" \

branches/try/mk/tests.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
412412
$$(CRATEFILE_$(4)) \
413413
$$(TESTDEP_$(1)_$(2)_$(3)_$(4))
414414
@$$(call E, rustc: $$@)
415-
$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(3)) \
415+
$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(2)) \
416416
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \
417417
-L "$$(RT_OUTPUT_DIR_$(2))" \
418418
-L "$$(LLVM_LIBDIR_$(2))" \
@@ -598,7 +598,7 @@ CTEST_DISABLE_debuginfo-lldb = "lldb tests are only run on darwin"
598598
endif
599599

600600
ifeq ($(CFG_OSTYPE),apple-darwin)
601-
CTEST_DISABLE_debuginfo-gdb = "gdb on darwin needs root"
601+
CTEST_DISABLE_debuginfo-gdb = "gdb on darwing needs root"
602602
endif
603603

604604
# CTEST_DISABLE_NONSELFHOST_$(TEST_GROUP), if set, will cause that
@@ -891,7 +891,7 @@ endif
891891
ifeq ($(2),$$(CFG_BUILD))
892892
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)): $$(CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4))
893893
@$$(call E, run doc-crate-$(4) [$(2)])
894-
$$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(3)) \
894+
$$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(2)) \
895895
$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test --cfg dox \
896896
$$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && touch $$@
897897
else

branches/try/src/libcollections/str.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -656,13 +656,6 @@ Section: CowString
656656
/// A clone-on-write string
657657
pub type CowString<'a> = Cow<'a, String, str>;
658658

659-
impl<'a> Str for CowString<'a> {
660-
#[inline]
661-
fn as_slice<'b>(&'b self) -> &'b str {
662-
(**self).as_slice()
663-
}
664-
}
665-
666659
/*
667660
Section: Trait implementations
668661
*/

branches/try/src/libgetopts/lib.rs

Lines changed: 70 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@
9292

9393
#[cfg(test)] #[phase(plugin, link)] extern crate log;
9494

95-
use self::Name::*;
96-
use self::HasArg::*;
97-
use self::Occur::*;
98-
use self::Fail::*;
95+
pub use self::Name::*;
96+
pub use self::HasArg::*;
97+
pub use self::Occur::*;
98+
pub use self::Fail_::*;
99+
pub use self::FailType::*;
99100
use self::Optval::*;
100101

101102
use std::fmt;
@@ -190,7 +191,7 @@ pub struct Matches {
190191
/// expected format. Use the `Show` implementation to output detailed
191192
/// information.
192193
#[deriving(Clone, PartialEq, Eq)]
193-
pub enum Fail {
194+
pub enum Fail_ {
194195
/// The option requires an argument but none was passed.
195196
ArgumentMissing(String),
196197
/// The passed option is not declared among the possible options.
@@ -203,8 +204,19 @@ pub enum Fail {
203204
UnexpectedArgument(String),
204205
}
205206

207+
/// The type of failure that occurred.
208+
#[deriving(PartialEq, Eq)]
209+
#[allow(missing_docs)]
210+
pub enum FailType {
211+
ArgumentMissing_,
212+
UnrecognizedOption_,
213+
OptionMissing_,
214+
OptionDuplicated_,
215+
UnexpectedArgument_,
216+
}
217+
206218
/// The result of parsing a command line with a set of options.
207-
pub type Result = result::Result<Matches, Fail>;
219+
pub type Result = result::Result<Matches, Fail_>;
208220

209221
impl Name {
210222
fn from_str(nm: &str) -> Name {
@@ -252,7 +264,7 @@ impl OptGroup {
252264
(1,_) => Opt {
253265
name: Long((long_name)),
254266
hasarg: hasarg,
255-
occur: occur,
267+
occur: occur,
256268
aliases: vec!(
257269
Opt {
258270
name: Short(short_name.as_slice().char_at(0)),
@@ -354,12 +366,11 @@ impl Matches {
354366
pub fn opt_default(&self, nm: &str, def: &str) -> Option<String> {
355367
let vals = self.opt_vals(nm);
356368
if vals.is_empty() {
357-
None
358-
} else {
359-
match vals[0] {
360-
Val(ref s) => Some((*s).clone()),
361-
_ => Some(def.to_string())
362-
}
369+
return None;
370+
}
371+
match vals[0] {
372+
Val(ref s) => Some((*s).clone()),
373+
_ => Some(def.to_string())
363374
}
364375
}
365376

@@ -523,15 +534,15 @@ pub fn opt(short_name: &str,
523534
}
524535
}
525536

526-
impl Fail {
527-
/// Convert a `Fail` enum into an error string.
537+
impl Fail_ {
538+
/// Convert a `Fail_` enum into an error string.
528539
#[deprecated="use `Show` (`{}` format specifier)"]
529540
pub fn to_err_msg(self) -> String {
530541
self.to_string()
531542
}
532543
}
533544

534-
impl fmt::Show for Fail {
545+
impl fmt::Show for Fail_ {
535546
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
536547
match *self {
537548
ArgumentMissing(ref nm) => {
@@ -559,7 +570,7 @@ impl fmt::Show for Fail {
559570
/// `opt_str`, etc. to interrogate results.
560571
/// # Panics
561572
///
562-
/// Returns `Err(Fail)` on failure: use the `Show` implementation of `Fail` to display
573+
/// Returns `Err(Fail_)` on failure: use the `Show` implementation of `Fail_` to display
563574
/// information about it.
564575
pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
565576
let opts: Vec<Opt> = optgrps.iter().map(|x| x.long_to_short()).collect();
@@ -670,15 +681,21 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
670681
}
671682
i += 1;
672683
}
673-
for i in range(0u, n_opts) {
684+
i = 0u;
685+
while i < n_opts {
674686
let n = vals[i].len();
675687
let occ = opts[i].occur;
676-
if occ == Req && n == 0 {
677-
return Err(OptionMissing(opts[i].name.to_string()));
688+
if occ == Req {
689+
if n == 0 {
690+
return Err(OptionMissing(opts[i].name.to_string()));
691+
}
678692
}
679-
if occ != Multi && n > 1 {
680-
return Err(OptionDuplicated(opts[i].name.to_string()));
693+
if occ != Multi {
694+
if n > 1 {
695+
return Err(OptionDuplicated(opts[i].name.to_string()));
696+
}
681697
}
698+
i += 1;
682699
}
683700
Ok(Matches {
684701
opts: opts,
@@ -949,11 +966,20 @@ fn test_split_within() {
949966
#[cfg(test)]
950967
mod tests {
951968
use super::*;
952-
use super::Fail::*;
953969

954970
use std::result::{Err, Ok};
955971
use std::result;
956972

973+
fn check_fail_type(f: Fail_, ft: FailType) {
974+
match f {
975+
ArgumentMissing(_) => assert!(ft == ArgumentMissing_),
976+
UnrecognizedOption(_) => assert!(ft == UnrecognizedOption_),
977+
OptionMissing(_) => assert!(ft == OptionMissing_),
978+
OptionDuplicated(_) => assert!(ft == OptionDuplicated_),
979+
UnexpectedArgument(_) => assert!(ft == UnexpectedArgument_)
980+
}
981+
}
982+
957983
// Tests for reqopt
958984
#[test]
959985
fn test_reqopt() {
@@ -987,7 +1013,7 @@ mod tests {
9871013
let opts = vec!(reqopt("t", "test", "testing", "TEST"));
9881014
let rs = getopts(args.as_slice(), opts.as_slice());
9891015
match rs {
990-
Err(OptionMissing(_)) => {},
1016+
Err(f) => check_fail_type(f, OptionMissing_),
9911017
_ => panic!()
9921018
}
9931019
}
@@ -998,12 +1024,12 @@ mod tests {
9981024
let opts = vec!(reqopt("t", "test", "testing", "TEST"));
9991025
let rs = getopts(long_args.as_slice(), opts.as_slice());
10001026
match rs {
1001-
Err(ArgumentMissing(_)) => {},
1027+
Err(f) => check_fail_type(f, ArgumentMissing_),
10021028
_ => panic!()
10031029
}
10041030
let short_args = vec!("-t".to_string());
10051031
match getopts(short_args.as_slice(), opts.as_slice()) {
1006-
Err(ArgumentMissing(_)) => {},
1032+
Err(f) => check_fail_type(f, ArgumentMissing_),
10071033
_ => panic!()
10081034
}
10091035
}
@@ -1014,7 +1040,7 @@ mod tests {
10141040
let opts = vec!(reqopt("t", "test", "testing", "TEST"));
10151041
let rs = getopts(args.as_slice(), opts.as_slice());
10161042
match rs {
1017-
Err(OptionDuplicated(_)) => {},
1043+
Err(f) => check_fail_type(f, OptionDuplicated_),
10181044
_ => panic!()
10191045
}
10201046
}
@@ -1066,12 +1092,12 @@ mod tests {
10661092
let opts = vec!(optopt("t", "test", "testing", "TEST"));
10671093
let rs = getopts(long_args.as_slice(), opts.as_slice());
10681094
match rs {
1069-
Err(ArgumentMissing(_)) => {},
1095+
Err(f) => check_fail_type(f, ArgumentMissing_),
10701096
_ => panic!()
10711097
}
10721098
let short_args = vec!("-t".to_string());
10731099
match getopts(short_args.as_slice(), opts.as_slice()) {
1074-
Err(ArgumentMissing(_)) => {},
1100+
Err(f) => check_fail_type(f, ArgumentMissing_),
10751101
_ => panic!()
10761102
}
10771103
}
@@ -1082,7 +1108,7 @@ mod tests {
10821108
let opts = vec!(optopt("t", "test", "testing", "TEST"));
10831109
let rs = getopts(args.as_slice(), opts.as_slice());
10841110
match rs {
1085-
Err(OptionDuplicated(_)) => {},
1111+
Err(f) => check_fail_type(f, OptionDuplicated_),
10861112
_ => panic!()
10871113
}
10881114
}
@@ -1130,7 +1156,9 @@ mod tests {
11301156
let opts = vec!(optflag("t", "test", "testing"));
11311157
let rs = getopts(args.as_slice(), opts.as_slice());
11321158
match rs {
1133-
Err(UnexpectedArgument(_)) => {},
1159+
Err(f) => {
1160+
check_fail_type(f, UnexpectedArgument_);
1161+
}
11341162
_ => panic!()
11351163
}
11361164
}
@@ -1141,7 +1169,7 @@ mod tests {
11411169
let opts = vec!(optflag("t", "test", "testing"));
11421170
let rs = getopts(args.as_slice(), opts.as_slice());
11431171
match rs {
1144-
Err(OptionDuplicated(_)) => {},
1172+
Err(f) => check_fail_type(f, OptionDuplicated_),
11451173
_ => panic!()
11461174
}
11471175
}
@@ -1289,12 +1317,12 @@ mod tests {
12891317
let opts = vec!(optmulti("t", "test", "testing", "TEST"));
12901318
let rs = getopts(long_args.as_slice(), opts.as_slice());
12911319
match rs {
1292-
Err(ArgumentMissing(_)) => {},
1320+
Err(f) => check_fail_type(f, ArgumentMissing_),
12931321
_ => panic!()
12941322
}
12951323
let short_args = vec!("-t".to_string());
12961324
match getopts(short_args.as_slice(), opts.as_slice()) {
1297-
Err(ArgumentMissing(_)) => {},
1325+
Err(f) => check_fail_type(f, ArgumentMissing_),
12981326
_ => panic!()
12991327
}
13001328
}
@@ -1324,12 +1352,12 @@ mod tests {
13241352
let opts = vec!(optmulti("t", "test", "testing", "TEST"));
13251353
let rs = getopts(long_args.as_slice(), opts.as_slice());
13261354
match rs {
1327-
Err(UnrecognizedOption(_)) => {},
1355+
Err(f) => check_fail_type(f, UnrecognizedOption_),
13281356
_ => panic!()
13291357
}
13301358
let short_args = vec!("-u".to_string());
13311359
match getopts(short_args.as_slice(), opts.as_slice()) {
1332-
Err(UnrecognizedOption(_)) => {},
1360+
Err(f) => check_fail_type(f, UnrecognizedOption_),
13331361
_ => panic!()
13341362
}
13351363
}
@@ -1465,14 +1493,14 @@ mod tests {
14651493
#[test]
14661494
fn test_long_to_short() {
14671495
let mut short = Opt {
1468-
name: Name::Long("banana".to_string()),
1469-
hasarg: HasArg::Yes,
1470-
occur: Occur::Req,
1496+
name: Long("banana".to_string()),
1497+
hasarg: Yes,
1498+
occur: Req,
14711499
aliases: Vec::new(),
14721500
};
1473-
short.aliases = vec!(Opt { name: Name::Short('b'),
1474-
hasarg: HasArg::Yes,
1475-
occur: Occur::Req,
1501+
short.aliases = vec!(Opt { name: Short('b'),
1502+
hasarg: Yes,
1503+
occur: Req,
14761504
aliases: Vec::new() });
14771505
let verbose = reqopt("b", "banana", "some bananas", "VAL");
14781506

0 commit comments

Comments
 (0)