Skip to content

Commit afef421

Browse files
committed
---
yaml --- r: 162725 b: refs/heads/try c: acad03a h: refs/heads/master i: 162723: 013f1f9 v: v3
1 parent 1f5a1fa commit afef421

File tree

21 files changed

+254
-118
lines changed

21 files changed

+254
-118
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: 432adc675e2955cbc639cbecf318dc23e053e7e2
5+
refs/heads/try: acad03a420186ee8f0c28626e59eee55664dd0b4
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, 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.
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.
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 also a few things you can do with a tuple as a whole, without
925+
There are 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: 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_trans/driver/driver.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ pub fn compile_input(sess: Session,
5151
outdir: &Option<Path>,
5252
output: &Option<Path>,
5353
addl_plugins: Option<Plugins>) {
54+
// These may be left in an incoherent state after a previous compile.
55+
// `clear_tables` and `get_ident_interner().clear()` can be used to free
56+
// memory, but they do not restore the initial state.
57+
syntax::ext::mtwt::reset_tables();
58+
token::reset_ident_interner();
59+
5460
// We need nested scopes here, because the intermediate results can keep
5561
// large chunks of memory alive and we want to free them as soon as
5662
// possible to keep the peak memory usage low

branches/try/src/librustc_trans/trans/asm.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,22 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
7777
// no failure occurred preparing operands, no need to cleanup
7878
fcx.pop_custom_cleanup_scope(temp_scope);
7979

80-
let mut constraints =
81-
String::from_str(constraints.iter()
82-
.map(|s| s.get().to_string())
83-
.chain(ext_constraints.into_iter())
84-
.collect::<Vec<String>>()
85-
.connect(",")
86-
.as_slice());
87-
88-
let mut clobbers = get_clobbers();
89-
if !ia.clobbers.get().is_empty() && !clobbers.is_empty() {
90-
clobbers = format!("{},{}", ia.clobbers.get(), clobbers);
91-
} else {
92-
clobbers.push_str(ia.clobbers.get());
80+
let mut constraints = constraints.iter()
81+
.map(|s| s.get().to_string())
82+
.chain(ext_constraints.into_iter())
83+
.collect::<Vec<String>>()
84+
.connect(",");
85+
86+
let mut clobbers = ia.clobbers.iter()
87+
.map(|s| format!("~{{{}}}", s.get()))
88+
.collect::<Vec<String>>()
89+
.connect(",");
90+
let more_clobbers = get_clobbers();
91+
if !more_clobbers.is_empty() {
92+
if !clobbers.is_empty() {
93+
clobbers.push(',');
94+
}
95+
clobbers.push_str(more_clobbers.as_slice());
9396
}
9497

9598
// Add the clobbers to our constraints list

0 commit comments

Comments
 (0)