Skip to content

Commit 1f5a1fa

Browse files
committed
---
yaml --- r: 162724 b: refs/heads/try c: 432adc6 h: refs/heads/master v: v3
1 parent 013f1f9 commit 1f5a1fa

Some content is hidden

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

43 files changed

+186
-322
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: 3ee471cab5ed17b14484c636c02d95fa1699e76f
5+
refs/heads/try: 432adc675e2955cbc639cbecf318dc23e053e7e2
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/doc/complement-lang-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ The `str` type is UTF-8 because we observe more text in the wild in this encodin
108108

109109
This does mean that indexed access to a Unicode codepoint inside a `str` value is an O(n) operation. On the one hand, this is clearly undesirable; on the other hand, this problem is full of trade-offs and we'd like to point a few important qualifications:
110110

111-
* Scanning a `str` for ASCII-range codepoints can still be done safely octet-at-a-time. If you use `.as_bytes()`, pulling out a `u8` costs only O(1) and produces a value that can be cast and compared to an ASCII-range `char`. So if you're (say) line-breaking on `'\n'`, octet-based treatment still works. UTF8 was well-designed this way.
111+
* Scanning a `str` for ASCII-range codepoints can still be done safely octet-at-a-time, with each indexing operation pulling out a `u8` costing only O(1) and producing a value that can be cast and compared to an ASCII-range `char`. So if you're (say) line-breaking on `'\n'`, octet-based treatment still works. UTF8 was well-designed this way.
112112
* Most "character oriented" operations on text only work under very restricted language assumptions sets such as "ASCII-range codepoints only". Outside ASCII-range, you tend to have to use a complex (non-constant-time) algorithm for determining linguistic-unit (glyph, word, paragraph) boundaries anyways. We recommend using an "honest" linguistically-aware, Unicode-approved algorithm.
113113
* The `char` type is UCS4. If you honestly need to do a codepoint-at-a-time algorithm, it's trivial to write a `type wstr = [char]`, and unpack a `str` into it in a single pass, then work with the `wstr`. In other words: the fact that the language is not "decoding to UCS4 by default" shouldn't stop you from decoding (or re-encoding any other way) if you need to work with that encoding.
114114

branches/try/src/doc/guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ or 'breaks up,' the tuple, and assigns the bits to three bindings.
922922

923923
This pattern is very powerful, and we'll see it repeated more later.
924924

925-
There are also a few things you can do with a tuple as a whole, without
925+
There also a few things you can do with a tuple as a whole, without
926926
destructuring. You can assign one tuple into another, if they have the same
927927
arity and contained types.
928928

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

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)