Skip to content

Commit c55e423

Browse files
committed
---
yaml --- r: 162731 b: refs/heads/try c: 09f04bf h: refs/heads/master i: 162729: f628129 162727: 1892f1f v: v3
1 parent 6f0a800 commit c55e423

35 files changed

+201
-170
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: 1d4ce379465927778e57a1782de809f8502635f9
5+
refs/heads/try: 09f04bf2c919725d5ee69b8cbb34cdcbb3433e25
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 darwing needs root"
601+
CTEST_DISABLE_debuginfo-gdb = "gdb on darwin needs root"
602602
endif
603603

604604
# CTEST_DISABLE_NONSELFHOST_$(TEST_GROUP), if set, will cause that

branches/try/src/libcollections/str.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,13 @@ 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+
659666
/*
660667
Section: Trait implementations
661668
*/

branches/try/src/libgetopts/lib.rs

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

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

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::*;
95+
use self::Name::*;
96+
use self::HasArg::*;
97+
use self::Occur::*;
98+
use self::Fail::*;
10099
use self::Optval::*;
101100

102101
use std::fmt;
@@ -191,7 +190,7 @@ pub struct Matches {
191190
/// expected format. Use the `Show` implementation to output detailed
192191
/// information.
193192
#[deriving(Clone, PartialEq, Eq)]
194-
pub enum Fail_ {
193+
pub enum Fail {
195194
/// The option requires an argument but none was passed.
196195
ArgumentMissing(String),
197196
/// The passed option is not declared among the possible options.
@@ -204,19 +203,8 @@ pub enum Fail_ {
204203
UnexpectedArgument(String),
205204
}
206205

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-
218206
/// The result of parsing a command line with a set of options.
219-
pub type Result = result::Result<Matches, Fail_>;
207+
pub type Result = result::Result<Matches, Fail>;
220208

221209
impl Name {
222210
fn from_str(nm: &str) -> Name {
@@ -264,7 +252,7 @@ impl OptGroup {
264252
(1,_) => Opt {
265253
name: Long((long_name)),
266254
hasarg: hasarg,
267-
occur: occur,
255+
occur: occur,
268256
aliases: vec!(
269257
Opt {
270258
name: Short(short_name.as_slice().char_at(0)),
@@ -366,11 +354,12 @@ impl Matches {
366354
pub fn opt_default(&self, nm: &str, def: &str) -> Option<String> {
367355
let vals = self.opt_vals(nm);
368356
if vals.is_empty() {
369-
return None;
370-
}
371-
match vals[0] {
372-
Val(ref s) => Some((*s).clone()),
373-
_ => Some(def.to_string())
357+
None
358+
} else {
359+
match vals[0] {
360+
Val(ref s) => Some((*s).clone()),
361+
_ => Some(def.to_string())
362+
}
374363
}
375364
}
376365

@@ -534,15 +523,15 @@ pub fn opt(short_name: &str,
534523
}
535524
}
536525

537-
impl Fail_ {
538-
/// Convert a `Fail_` enum into an error string.
526+
impl Fail {
527+
/// Convert a `Fail` enum into an error string.
539528
#[deprecated="use `Show` (`{}` format specifier)"]
540529
pub fn to_err_msg(self) -> String {
541530
self.to_string()
542531
}
543532
}
544533

545-
impl fmt::Show for Fail_ {
534+
impl fmt::Show for Fail {
546535
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
547536
match *self {
548537
ArgumentMissing(ref nm) => {
@@ -570,7 +559,7 @@ impl fmt::Show for Fail_ {
570559
/// `opt_str`, etc. to interrogate results.
571560
/// # Panics
572561
///
573-
/// Returns `Err(Fail_)` on failure: use the `Show` implementation of `Fail_` to display
562+
/// Returns `Err(Fail)` on failure: use the `Show` implementation of `Fail` to display
574563
/// information about it.
575564
pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
576565
let opts: Vec<Opt> = optgrps.iter().map(|x| x.long_to_short()).collect();
@@ -681,21 +670,15 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
681670
}
682671
i += 1;
683672
}
684-
i = 0u;
685-
while i < n_opts {
673+
for i in range(0u, n_opts) {
686674
let n = vals[i].len();
687675
let occ = opts[i].occur;
688-
if occ == Req {
689-
if n == 0 {
690-
return Err(OptionMissing(opts[i].name.to_string()));
691-
}
676+
if occ == Req && n == 0 {
677+
return Err(OptionMissing(opts[i].name.to_string()));
692678
}
693-
if occ != Multi {
694-
if n > 1 {
695-
return Err(OptionDuplicated(opts[i].name.to_string()));
696-
}
679+
if occ != Multi && n > 1 {
680+
return Err(OptionDuplicated(opts[i].name.to_string()));
697681
}
698-
i += 1;
699682
}
700683
Ok(Matches {
701684
opts: opts,
@@ -966,20 +949,11 @@ fn test_split_within() {
966949
#[cfg(test)]
967950
mod tests {
968951
use super::*;
952+
use super::Fail::*;
969953

970954
use std::result::{Err, Ok};
971955
use std::result;
972956

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-
983957
// Tests for reqopt
984958
#[test]
985959
fn test_reqopt() {
@@ -1013,7 +987,7 @@ mod tests {
1013987
let opts = vec!(reqopt("t", "test", "testing", "TEST"));
1014988
let rs = getopts(args.as_slice(), opts.as_slice());
1015989
match rs {
1016-
Err(f) => check_fail_type(f, OptionMissing_),
990+
Err(OptionMissing(_)) => {},
1017991
_ => panic!()
1018992
}
1019993
}
@@ -1024,12 +998,12 @@ mod tests {
1024998
let opts = vec!(reqopt("t", "test", "testing", "TEST"));
1025999
let rs = getopts(long_args.as_slice(), opts.as_slice());
10261000
match rs {
1027-
Err(f) => check_fail_type(f, ArgumentMissing_),
1001+
Err(ArgumentMissing(_)) => {},
10281002
_ => panic!()
10291003
}
10301004
let short_args = vec!("-t".to_string());
10311005
match getopts(short_args.as_slice(), opts.as_slice()) {
1032-
Err(f) => check_fail_type(f, ArgumentMissing_),
1006+
Err(ArgumentMissing(_)) => {},
10331007
_ => panic!()
10341008
}
10351009
}
@@ -1040,7 +1014,7 @@ mod tests {
10401014
let opts = vec!(reqopt("t", "test", "testing", "TEST"));
10411015
let rs = getopts(args.as_slice(), opts.as_slice());
10421016
match rs {
1043-
Err(f) => check_fail_type(f, OptionDuplicated_),
1017+
Err(OptionDuplicated(_)) => {},
10441018
_ => panic!()
10451019
}
10461020
}
@@ -1092,12 +1066,12 @@ mod tests {
10921066
let opts = vec!(optopt("t", "test", "testing", "TEST"));
10931067
let rs = getopts(long_args.as_slice(), opts.as_slice());
10941068
match rs {
1095-
Err(f) => check_fail_type(f, ArgumentMissing_),
1069+
Err(ArgumentMissing(_)) => {},
10961070
_ => panic!()
10971071
}
10981072
let short_args = vec!("-t".to_string());
10991073
match getopts(short_args.as_slice(), opts.as_slice()) {
1100-
Err(f) => check_fail_type(f, ArgumentMissing_),
1074+
Err(ArgumentMissing(_)) => {},
11011075
_ => panic!()
11021076
}
11031077
}
@@ -1108,7 +1082,7 @@ mod tests {
11081082
let opts = vec!(optopt("t", "test", "testing", "TEST"));
11091083
let rs = getopts(args.as_slice(), opts.as_slice());
11101084
match rs {
1111-
Err(f) => check_fail_type(f, OptionDuplicated_),
1085+
Err(OptionDuplicated(_)) => {},
11121086
_ => panic!()
11131087
}
11141088
}
@@ -1156,9 +1130,7 @@ mod tests {
11561130
let opts = vec!(optflag("t", "test", "testing"));
11571131
let rs = getopts(args.as_slice(), opts.as_slice());
11581132
match rs {
1159-
Err(f) => {
1160-
check_fail_type(f, UnexpectedArgument_);
1161-
}
1133+
Err(UnexpectedArgument(_)) => {},
11621134
_ => panic!()
11631135
}
11641136
}
@@ -1169,7 +1141,7 @@ mod tests {
11691141
let opts = vec!(optflag("t", "test", "testing"));
11701142
let rs = getopts(args.as_slice(), opts.as_slice());
11711143
match rs {
1172-
Err(f) => check_fail_type(f, OptionDuplicated_),
1144+
Err(OptionDuplicated(_)) => {},
11731145
_ => panic!()
11741146
}
11751147
}
@@ -1317,12 +1289,12 @@ mod tests {
13171289
let opts = vec!(optmulti("t", "test", "testing", "TEST"));
13181290
let rs = getopts(long_args.as_slice(), opts.as_slice());
13191291
match rs {
1320-
Err(f) => check_fail_type(f, ArgumentMissing_),
1292+
Err(ArgumentMissing(_)) => {},
13211293
_ => panic!()
13221294
}
13231295
let short_args = vec!("-t".to_string());
13241296
match getopts(short_args.as_slice(), opts.as_slice()) {
1325-
Err(f) => check_fail_type(f, ArgumentMissing_),
1297+
Err(ArgumentMissing(_)) => {},
13261298
_ => panic!()
13271299
}
13281300
}
@@ -1352,12 +1324,12 @@ mod tests {
13521324
let opts = vec!(optmulti("t", "test", "testing", "TEST"));
13531325
let rs = getopts(long_args.as_slice(), opts.as_slice());
13541326
match rs {
1355-
Err(f) => check_fail_type(f, UnrecognizedOption_),
1327+
Err(UnrecognizedOption(_)) => {},
13561328
_ => panic!()
13571329
}
13581330
let short_args = vec!("-u".to_string());
13591331
match getopts(short_args.as_slice(), opts.as_slice()) {
1360-
Err(f) => check_fail_type(f, UnrecognizedOption_),
1332+
Err(UnrecognizedOption(_)) => {},
13611333
_ => panic!()
13621334
}
13631335
}
@@ -1493,14 +1465,14 @@ mod tests {
14931465
#[test]
14941466
fn test_long_to_short() {
14951467
let mut short = Opt {
1496-
name: Long("banana".to_string()),
1497-
hasarg: Yes,
1498-
occur: Req,
1468+
name: Name::Long("banana".to_string()),
1469+
hasarg: HasArg::Yes,
1470+
occur: Occur::Req,
14991471
aliases: Vec::new(),
15001472
};
1501-
short.aliases = vec!(Opt { name: Short('b'),
1502-
hasarg: Yes,
1503-
occur: Req,
1473+
short.aliases = vec!(Opt { name: Name::Short('b'),
1474+
hasarg: HasArg::Yes,
1475+
occur: Occur::Req,
15041476
aliases: Vec::new() });
15051477
let verbose = reqopt("b", "banana", "some bananas", "VAL");
15061478

branches/try/src/librustc/middle/resolve.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3239,7 +3239,7 @@ impl<'a> Resolver<'a> {
32393239
segment_name),
32403240
}
32413241
} else {
3242-
format!("Could not find `{}` in `{}`.",
3242+
format!("Could not find `{}` in `{}`",
32433243
segment_name,
32443244
module_name)
32453245
};
@@ -4744,7 +4744,7 @@ impl<'a> Resolver<'a> {
47444744
Some(&DefMod(_)) => {
47454745
self.resolve_error(path.span, "inherent implementations are not \
47464746
allowed for types not defined in \
4747-
the current module.");
4747+
the current module");
47484748
}
47494749
_ => {}
47504750
}
@@ -5843,12 +5843,12 @@ impl<'a> Resolver<'a> {
58435843
};
58445844

58455845
if msg.len() > 0 {
5846-
msg = format!(" Did you mean {}?", msg)
5846+
msg = format!(". Did you mean {}?", msg)
58475847
}
58485848

58495849
self.resolve_error(
58505850
expr.span,
5851-
format!("unresolved name `{}`.{}",
5851+
format!("unresolved name `{}`{}",
58525852
wrong_name,
58535853
msg).as_slice());
58545854
}

branches/try/src/librustc/middle/typeck/collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl<'a, 'tcx> AstConv<'tcx> for CrateCtxt<'a, 'tcx> {
184184

185185
fn ty_infer(&self, span: Span) -> Ty<'tcx> {
186186
span_err!(self.tcx.sess, span, E0121,
187-
"the type placeholder `_` is not allowed within types on item signatures.");
187+
"the type placeholder `_` is not allowed within types on item signatures");
188188
ty::mk_err()
189189
}
190190

@@ -1715,7 +1715,7 @@ fn add_unsized_bound<'tcx,AC>(this: &AC,
17151715
the given bound is not \
17161716
a default. \
17171717
Only `Sized?` is \
1718-
supported.",
1718+
supported",
17191719
desc).as_slice());
17201720
ty::try_add_builtin_trait(this.tcx(),
17211721
kind_id,

branches/try/src/librustc/middle/typeck/infer/error_reporting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,15 +1648,15 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
16481648
self.tcx.sess.span_note(
16491649
span,
16501650
format!("...so that the type `{}` \
1651-
will meet the declared lifetime bounds.",
1651+
will meet the declared lifetime bounds",
16521652
self.ty_to_string(t)).as_slice());
16531653
}
16541654
infer::RelateDefaultParamBound(span, t) => {
16551655
self.tcx.sess.span_note(
16561656
span,
16571657
format!("...so that type parameter \
16581658
instantiated with `{}`, \
1659-
will meet its declared lifetime bounds.",
1659+
will meet its declared lifetime bounds",
16601660
self.ty_to_string(t)).as_slice());
16611661
}
16621662
infer::RelateRegionParamBound(span) => {

0 commit comments

Comments
 (0)