Skip to content

Commit b15ed69

Browse files
committed
---
yaml --- r: 57338 b: refs/heads/incoming c: e06b982 h: refs/heads/master v: v3
1 parent aa0d923 commit b15ed69

File tree

27 files changed

+584
-475
lines changed

27 files changed

+584
-475
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: bf67eb2362b7d0f37012f2d6dac604c3bbacd2c6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 255193cc1af5e07753906ad18bae077b45b5c3f0
9+
refs/heads/incoming: e06b9827efa0a7d8334d0b71577c6efef44a35f0
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,7 @@ impl Shape for CircleStruct {
23202320
Notice that methods of `Circle` can call methods on `Shape`, as our
23212321
`radius` implementation calls the `area` method.
23222322
This is a silly way to compute the radius of a circle
2323-
(since we could just return the `circle` field), but you get the idea.
2323+
(since we could just return the `radius` field), but you get the idea.
23242324

23252325
In type-parameterized functions,
23262326
methods of the supertrait may be called on values of subtrait-bound type parameters.

branches/incoming/src/etc/vim/syntax/rust.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9
110110
syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
111111
syn match rustCharacter "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'"
112112

113-
syn region rustComment start="/\*" end="\*/" contains=rustComment,rustTodo
114-
syn region rustComment start="//" skip="\\$" end="$" contains=rustTodo keepend
113+
syn region rustCommentDoc start="/\*\*" end="\*/"
114+
syn region rustCommentDoc start="///" skip="\\$" end="$" keepend
115+
syn match rustComment "/\*\*/"
116+
syn region rustComment start="/\*\([^\*]\|$\)" end="\*/" contains=rustTodo
117+
syn region rustComment start="//\([^/]\|$\)" skip="\\$" end="$" contains=rustTodo keepend
115118

116119
syn keyword rustTodo contained TODO FIXME XXX NB
117120

@@ -134,6 +137,7 @@ hi def link rustConditional Conditional
134137
hi def link rustIdentifier Identifier
135138
hi def link rustModPath Include
136139
hi def link rustFuncName Function
140+
hi def link rustCommentDoc SpecialComment
137141
hi def link rustComment Comment
138142
hi def link rustMacro Macro
139143
hi def link rustType Type

branches/incoming/src/libcore/char.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,12 @@ pub fn escape_unicode(c: char) -> ~str {
202202
else { ('U', 8u) });
203203
assert!(str::len(s) <= pad);
204204
let mut out = ~"\\";
205-
str::push_str(&mut out, str::from_char(c));
206-
for uint::range(str::len(s), pad) |_i|
207-
{ str::push_str(&mut out, ~"0"); }
208-
str::push_str(&mut out, s);
205+
unsafe {
206+
str::push_str(&mut out, str::from_char(c));
207+
for uint::range(str::len(s), pad) |_i|
208+
{ str::push_str(&mut out, ~"0"); }
209+
str::push_str(&mut out, s);
210+
}
209211
out
210212
}
211213

branches/incoming/src/libcore/hash.rs

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,43 +76,51 @@ pub trait Streaming {
7676
impl<A:IterBytes> Hash for A {
7777
#[inline(always)]
7878
fn hash_keyed(&self, k0: u64, k1: u64) -> u64 {
79-
let s = &State(k0, k1);
80-
for self.iter_bytes(true) |bytes| {
81-
s.input(bytes);
79+
unsafe {
80+
let s = &State(k0, k1);
81+
for self.iter_bytes(true) |bytes| {
82+
s.input(bytes);
83+
}
84+
s.result_u64()
8285
}
83-
s.result_u64()
8486
}
8587
}
8688

8789
fn hash_keyed_2<A: IterBytes,
8890
B: IterBytes>(a: &A, b: &B, k0: u64, k1: u64) -> u64 {
89-
let s = &State(k0, k1);
90-
for a.iter_bytes(true) |bytes| { s.input(bytes); }
91-
for b.iter_bytes(true) |bytes| { s.input(bytes); }
92-
s.result_u64()
91+
unsafe {
92+
let s = &State(k0, k1);
93+
for a.iter_bytes(true) |bytes| { s.input(bytes); }
94+
for b.iter_bytes(true) |bytes| { s.input(bytes); }
95+
s.result_u64()
96+
}
9397
}
9498

9599
fn hash_keyed_3<A: IterBytes,
96100
B: IterBytes,
97101
C: IterBytes>(a: &A, b: &B, c: &C, k0: u64, k1: u64) -> u64 {
98-
let s = &State(k0, k1);
99-
for a.iter_bytes(true) |bytes| { s.input(bytes); }
100-
for b.iter_bytes(true) |bytes| { s.input(bytes); }
101-
for c.iter_bytes(true) |bytes| { s.input(bytes); }
102-
s.result_u64()
102+
unsafe {
103+
let s = &State(k0, k1);
104+
for a.iter_bytes(true) |bytes| { s.input(bytes); }
105+
for b.iter_bytes(true) |bytes| { s.input(bytes); }
106+
for c.iter_bytes(true) |bytes| { s.input(bytes); }
107+
s.result_u64()
108+
}
103109
}
104110

105111
fn hash_keyed_4<A: IterBytes,
106112
B: IterBytes,
107113
C: IterBytes,
108114
D: IterBytes>(a: &A, b: &B, c: &C, d: &D, k0: u64, k1: u64)
109115
-> u64 {
110-
let s = &State(k0, k1);
111-
for a.iter_bytes(true) |bytes| { s.input(bytes); }
112-
for b.iter_bytes(true) |bytes| { s.input(bytes); }
113-
for c.iter_bytes(true) |bytes| { s.input(bytes); }
114-
for d.iter_bytes(true) |bytes| { s.input(bytes); }
115-
s.result_u64()
116+
unsafe {
117+
let s = &State(k0, k1);
118+
for a.iter_bytes(true) |bytes| { s.input(bytes); }
119+
for b.iter_bytes(true) |bytes| { s.input(bytes); }
120+
for c.iter_bytes(true) |bytes| { s.input(bytes); }
121+
for d.iter_bytes(true) |bytes| { s.input(bytes); }
122+
s.result_u64()
123+
}
116124
}
117125

118126
fn hash_keyed_5<A: IterBytes,
@@ -121,13 +129,15 @@ fn hash_keyed_5<A: IterBytes,
121129
D: IterBytes,
122130
E: IterBytes>(a: &A, b: &B, c: &C, d: &D, e: &E,
123131
k0: u64, k1: u64) -> u64 {
124-
let s = &State(k0, k1);
125-
for a.iter_bytes(true) |bytes| { s.input(bytes); }
126-
for b.iter_bytes(true) |bytes| { s.input(bytes); }
127-
for c.iter_bytes(true) |bytes| { s.input(bytes); }
128-
for d.iter_bytes(true) |bytes| { s.input(bytes); }
129-
for e.iter_bytes(true) |bytes| { s.input(bytes); }
130-
s.result_u64()
132+
unsafe {
133+
let s = &State(k0, k1);
134+
for a.iter_bytes(true) |bytes| { s.input(bytes); }
135+
for b.iter_bytes(true) |bytes| { s.input(bytes); }
136+
for c.iter_bytes(true) |bytes| { s.input(bytes); }
137+
for d.iter_bytes(true) |bytes| { s.input(bytes); }
138+
for e.iter_bytes(true) |bytes| { s.input(bytes); }
139+
s.result_u64()
140+
}
131141
}
132142

133143
// Implement State as SipState

branches/incoming/src/libcore/num/strconv.rs

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
228228
deccum /= radix_gen;
229229
deccum = deccum.round_to_zero();
230230

231-
buf.push(char::from_digit(current_digit.to_int() as uint, radix)
232-
.unwrap() as u8);
231+
unsafe { // FIXME: Pureness workaround (#4568)
232+
buf.push(char::from_digit(current_digit.to_int() as uint, radix)
233+
.unwrap() as u8);
234+
}
233235

234236
// No more digits to calculate for the non-fractional part -> break
235237
if deccum == _0 { break; }
@@ -245,15 +247,21 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
245247
// Decide what sign to put in front
246248
match sign {
247249
SignNeg | SignAll if neg => {
248-
buf.push('-' as u8);
250+
unsafe { // FIXME: Pureness workaround (#4568)
251+
buf.push('-' as u8);
252+
}
249253
}
250254
SignAll => {
251-
buf.push('+' as u8);
255+
unsafe { // FIXME: Pureness workaround (#4568)
256+
buf.push('+' as u8);
257+
}
252258
}
253259
_ => ()
254260
}
255261

256-
vec::reverse(buf);
262+
unsafe { // FIXME: Pureness workaround (#4568)
263+
vec::reverse(buf);
264+
}
257265

258266
// Remember start of the fractional digits.
259267
// Points one beyond end of buf if none get generated,
@@ -263,7 +271,9 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
263271
// Now emit the fractional part, if any
264272
deccum = num.fractional_part();
265273
if deccum != _0 || (limit_digits && exact && digit_count > 0) {
266-
buf.push('.' as u8);
274+
unsafe { // FIXME: Pureness workaround (#4568)
275+
buf.push('.' as u8);
276+
}
267277
let mut dig = 0u;
268278

269279
// calculate new digits while
@@ -289,8 +299,10 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
289299
current_digit_signed
290300
};
291301

292-
buf.push(char::from_digit(
293-
current_digit.to_int() as uint, radix).unwrap() as u8);
302+
unsafe { // FIXME: Pureness workaround (#4568)
303+
buf.push(char::from_digit(
304+
current_digit.to_int() as uint, radix).unwrap() as u8);
305+
}
294306

295307
// Decrease the deccumulator one fractional digit at a time
296308
deccum = deccum.fractional_part();
@@ -308,31 +320,33 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
308320
char::from_digit(val, radix).unwrap() as u8
309321
};
310322

311-
let extra_digit = ascii2value(buf.pop());
312-
if extra_digit >= radix / 2 { // -> need to round
313-
let mut i: int = buf.len() as int - 1;
314-
loop {
315-
// If reached left end of number, have to
316-
// insert additional digit:
317-
if i < 0
318-
|| buf[i] == '-' as u8
319-
|| buf[i] == '+' as u8 {
320-
buf.insert((i + 1) as uint, value2ascii(1));
321-
break;
322-
}
323-
324-
// Skip the '.'
325-
if buf[i] == '.' as u8 { i -= 1; loop; }
326-
327-
// Either increment the digit,
328-
// or set to 0 if max and carry the 1.
329-
let current_digit = ascii2value(buf[i]);
330-
if current_digit < (radix - 1) {
331-
buf[i] = value2ascii(current_digit+1);
332-
break;
333-
} else {
334-
buf[i] = value2ascii(0);
335-
i -= 1;
323+
unsafe { // FIXME: Pureness workaround (#4568)
324+
let extra_digit = ascii2value(buf.pop());
325+
if extra_digit >= radix / 2 { // -> need to round
326+
let mut i: int = buf.len() as int - 1;
327+
loop {
328+
// If reached left end of number, have to
329+
// insert additional digit:
330+
if i < 0
331+
|| buf[i] == '-' as u8
332+
|| buf[i] == '+' as u8 {
333+
buf.insert((i + 1) as uint, value2ascii(1));
334+
break;
335+
}
336+
337+
// Skip the '.'
338+
if buf[i] == '.' as u8 { i -= 1; loop; }
339+
340+
// Either increment the digit,
341+
// or set to 0 if max and carry the 1.
342+
let current_digit = ascii2value(buf[i]);
343+
if current_digit < (radix - 1) {
344+
buf[i] = value2ascii(current_digit+1);
345+
break;
346+
} else {
347+
buf[i] = value2ascii(0);
348+
i -= 1;
349+
}
336350
}
337351
}
338352
}

branches/incoming/src/libcore/result.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ pub enum Result<T, U> {
3939
pub fn get<T:Copy,U>(res: &Result<T, U>) -> T {
4040
match *res {
4141
Ok(copy t) => t,
42-
Err(ref the_err) =>
42+
Err(ref the_err) => unsafe {
4343
fail!(fmt!("get called on error result: %?", *the_err))
44+
}
4445
}
4546
}
4647

@@ -55,8 +56,9 @@ pub fn get<T:Copy,U>(res: &Result<T, U>) -> T {
5556
pub fn get_ref<'a, T, U>(res: &'a Result<T, U>) -> &'a T {
5657
match *res {
5758
Ok(ref t) => t,
58-
Err(ref the_err) =>
59+
Err(ref the_err) => unsafe {
5960
fail!(fmt!("get_ref called on error result: %?", *the_err))
61+
}
6062
}
6163
}
6264

branches/incoming/src/libcore/str.rs

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,9 +1020,11 @@ pub fn any(ss: &str, pred: &fn(char) -> bool) -> bool {
10201020
/// Apply a function to each character
10211021
pub fn map(ss: &str, ff: &fn(char) -> char) -> ~str {
10221022
let mut result = ~"";
1023-
reserve(&mut result, len(ss));
1024-
for ss.each_char |cc| {
1025-
str::push_char(&mut result, ff(cc));
1023+
unsafe {
1024+
reserve(&mut result, len(ss));
1025+
for ss.each_char |cc| {
1026+
str::push_char(&mut result, ff(cc));
1027+
}
10261028
}
10271029
result
10281030
}
@@ -1658,18 +1660,20 @@ pub fn to_utf16(s: &str) -> ~[u16] {
16581660
// Arithmetic with u32 literals is easier on the eyes than chars.
16591661
let mut ch = ch as u32;
16601662

1661-
if (ch & 0xFFFF_u32) == ch {
1662-
// The BMP falls through (assuming non-surrogate, as it
1663-
// should)
1664-
assert!(ch <= 0xD7FF_u32 || ch >= 0xE000_u32);
1665-
u.push(ch as u16)
1666-
} else {
1667-
// Supplementary planes break into surrogates.
1668-
assert!(ch >= 0x1_0000_u32 && ch <= 0x10_FFFF_u32);
1669-
ch -= 0x1_0000_u32;
1670-
let w1 = 0xD800_u16 | ((ch >> 10) as u16);
1671-
let w2 = 0xDC00_u16 | ((ch as u16) & 0x3FF_u16);
1672-
u.push_all(~[w1, w2])
1663+
unsafe {
1664+
if (ch & 0xFFFF_u32) == ch {
1665+
// The BMP falls through (assuming non-surrogate, as it
1666+
// should)
1667+
assert!(ch <= 0xD7FF_u32 || ch >= 0xE000_u32);
1668+
u.push(ch as u16)
1669+
} else {
1670+
// Supplementary planes break into surrogates.
1671+
assert!(ch >= 0x1_0000_u32 && ch <= 0x10_FFFF_u32);
1672+
ch -= 0x1_0000_u32;
1673+
let w1 = 0xD800_u16 | ((ch >> 10) as u16);
1674+
let w2 = 0xDC00_u16 | ((ch as u16) & 0x3FF_u16);
1675+
u.push_all(~[w1, w2])
1676+
}
16731677
}
16741678
}
16751679
u
@@ -1701,14 +1705,16 @@ pub fn utf16_chars(v: &[u16], f: &fn(char)) {
17011705

17021706
pub fn from_utf16(v: &[u16]) -> ~str {
17031707
let mut buf = ~"";
1704-
reserve(&mut buf, vec::len(v));
1705-
utf16_chars(v, |ch| push_char(&mut buf, ch));
1708+
unsafe {
1709+
reserve(&mut buf, vec::len(v));
1710+
utf16_chars(v, |ch| push_char(&mut buf, ch));
1711+
}
17061712
buf
17071713
}
17081714

17091715
pub fn with_capacity(capacity: uint) -> ~str {
17101716
let mut buf = ~"";
1711-
reserve(&mut buf, capacity);
1717+
unsafe { reserve(&mut buf, capacity); }
17121718
buf
17131719
}
17141720

@@ -2099,19 +2105,23 @@ pub fn capacity(s: &const ~str) -> uint {
20992105
/// Escape each char in `s` with char::escape_default.
21002106
pub fn escape_default(s: &str) -> ~str {
21012107
let mut out: ~str = ~"";
2102-
reserve_at_least(&mut out, str::len(s));
2103-
for s.each_char |c| {
2104-
push_str(&mut out, char::escape_default(c));
2108+
unsafe {
2109+
reserve_at_least(&mut out, str::len(s));
2110+
for s.each_char |c| {
2111+
push_str(&mut out, char::escape_default(c));
2112+
}
21052113
}
21062114
out
21072115
}
21082116

21092117
/// Escape each char in `s` with char::escape_unicode.
21102118
pub fn escape_unicode(s: &str) -> ~str {
21112119
let mut out: ~str = ~"";
2112-
reserve_at_least(&mut out, str::len(s));
2113-
for s.each_char |c| {
2114-
push_str(&mut out, char::escape_unicode(c));
2120+
unsafe {
2121+
reserve_at_least(&mut out, str::len(s));
2122+
for s.each_char |c| {
2123+
push_str(&mut out, char::escape_unicode(c));
2124+
}
21152125
}
21162126
out
21172127
}

0 commit comments

Comments
 (0)