Skip to content

Commit 8c3da5f

Browse files
committed
---
yaml --- r: 22150 b: refs/heads/snap-stage3 c: 2f4ee89 h: refs/heads/master v: v3
1 parent 6f163fb commit 8c3da5f

File tree

11 files changed

+118
-106
lines changed

11 files changed

+118
-106
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 21519bc7e0a32e388e8b12be5d36d4440129f417
4+
refs/heads/snap-stage3: 2f4ee891199d3dffd8382742f576c3e78081634e
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/cast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
2121
* reinterpret_cast on managed pointer types.
2222
*/
2323
#[inline(always)]
24-
pub unsafe fn forget<T>(-thing: T) { rusti::forget(move thing); }
24+
pub unsafe fn forget<T>(+thing: T) { rusti::forget(move thing); }
2525

2626
/**
2727
* Force-increment the reference count on a shared box. If used
@@ -40,7 +40,7 @@ pub unsafe fn bump_box_refcount<T>(+t: @T) { forget(move t); }
4040
* assert transmute("L") == ~[76u8, 0u8];
4141
*/
4242
#[inline(always)]
43-
pub unsafe fn transmute<L, G>(-thing: L) -> G {
43+
pub unsafe fn transmute<L, G>(+thing: L) -> G {
4444
let newthing: G = reinterpret_cast(&thing);
4545
forget(move thing);
4646
move newthing

branches/snap-stage3/src/libcore/extfmt.rs

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ mod ct {
8181

8282
// A fragment of the output sequence
8383
enum Piece { PieceString(~str), PieceConv(Conv), }
84-
type ErrorFn = fn@(~str) -> ! ;
84+
type ErrorFn = fn@(&str) -> ! ;
8585

86-
fn parse_fmt_string(s: ~str, error: ErrorFn) -> ~[Piece] {
86+
fn parse_fmt_string(s: &str, error: ErrorFn) -> ~[Piece] {
8787
let mut pieces: ~[Piece] = ~[];
8888
let lim = str::len(s);
8989
let mut buf = ~"";
90-
fn flush_buf(+buf: ~str, &pieces: ~[Piece]) -> ~str {
91-
if str::len(buf) > 0 {
90+
fn flush_buf(+buf: ~str, pieces: &mut ~[Piece]) -> ~str {
91+
if buf.len() > 0 {
9292
let piece = PieceString(move buf);
9393
pieces.push(move piece);
9494
}
@@ -108,17 +108,17 @@ mod ct {
108108
buf += curr2;
109109
i += 1;
110110
} else {
111-
buf = flush_buf(move buf, pieces);
111+
buf = flush_buf(move buf, &mut pieces);
112112
let rs = parse_conversion(s, i, lim, error);
113113
pieces.push(copy rs.piece);
114114
i = rs.next;
115115
}
116116
} else { buf += curr; i += size; }
117117
}
118-
flush_buf(move buf, pieces);
118+
flush_buf(move buf, &mut pieces);
119119
move pieces
120120
}
121-
fn peek_num(s: ~str, i: uint, lim: uint) ->
121+
fn peek_num(s: &str, i: uint, lim: uint) ->
122122
Option<{num: uint, next: uint}> {
123123
let mut j = i;
124124
let mut accum = 0u;
@@ -140,7 +140,7 @@ mod ct {
140140
None
141141
}
142142
}
143-
fn parse_conversion(s: ~str, i: uint, lim: uint, error: ErrorFn) ->
143+
fn parse_conversion(s: &str, i: uint, lim: uint, error: ErrorFn) ->
144144
{piece: Piece, next: uint} {
145145
let parm = parse_parameter(s, i, lim);
146146
let flags = parse_flags(s, parm.next, lim);
@@ -155,7 +155,7 @@ mod ct {
155155
ty: ty.ty}),
156156
next: ty.next};
157157
}
158-
fn parse_parameter(s: ~str, i: uint, lim: uint) ->
158+
fn parse_parameter(s: &str, i: uint, lim: uint) ->
159159
{param: Option<int>, next: uint} {
160160
if i >= lim { return {param: None, next: i}; }
161161
let num = peek_num(s, i, lim);
@@ -170,34 +170,35 @@ mod ct {
170170
}
171171
};
172172
}
173-
fn parse_flags(s: ~str, i: uint, lim: uint) ->
173+
fn parse_flags(s: &str, i: uint, lim: uint) ->
174174
{flags: ~[Flag], next: uint} {
175175
let noflags: ~[Flag] = ~[];
176176
if i >= lim { return {flags: move noflags, next: i}; }
177177
178-
fn more_(f: Flag, s: ~str, i: uint, lim: uint) ->
178+
fn more(f: Flag, s: &str, i: uint, lim: uint) ->
179179
{flags: ~[Flag], next: uint} {
180180
let next = parse_flags(s, i + 1u, lim);
181181
let rest = copy next.flags;
182182
let j = next.next;
183183
let curr: ~[Flag] = ~[f];
184184
return {flags: vec::append(move curr, rest), next: j};
185185
}
186-
let more = |x, copy s| more_(x, copy s, i, lim);
186+
// Unfortunate, but because s is borrowed, can't use a closure
187+
// fn more(f: Flag, s: &str) { more_(f, s, i, lim); }
187188
let f = s[i];
188189
return if f == '-' as u8 {
189-
more(FlagLeftJustify)
190+
more(FlagLeftJustify, s, i, lim)
190191
} else if f == '0' as u8 {
191-
more(FlagLeftZeroPad)
192+
more(FlagLeftZeroPad, s, i, lim)
192193
} else if f == ' ' as u8 {
193-
more(FlagSpaceForSign)
194+
more(FlagSpaceForSign, s, i, lim)
194195
} else if f == '+' as u8 {
195-
more(FlagSignAlways)
196+
more(FlagSignAlways, s, i, lim)
196197
} else if f == '#' as u8 {
197-
more(FlagAlternate)
198+
more(FlagAlternate, s, i, lim)
198199
} else { {flags: move noflags, next: i} };
199200
}
200-
fn parse_count(s: ~str, i: uint, lim: uint)
201+
fn parse_count(s: &str, i: uint, lim: uint)
201202
-> {count: Count, next: uint} {
202203
return if i >= lim {
203204
{count: CountImplied, next: i}
@@ -219,7 +220,7 @@ mod ct {
219220
}
220221
};
221222
}
222-
fn parse_precision(s: ~str, i: uint, lim: uint) ->
223+
fn parse_precision(s: &str, i: uint, lim: uint) ->
223224
{count: Count, next: uint} {
224225
return if i >= lim {
225226
{count: CountImplied, next: i}
@@ -235,7 +236,7 @@ mod ct {
235236
}
236237
} else { {count: CountImplied, next: i} };
237238
}
238-
fn parse_type(s: ~str, i: uint, lim: uint, error: ErrorFn) ->
239+
fn parse_type(s: &str, i: uint, lim: uint, error: ErrorFn) ->
239240
{ty: Ty, next: uint} {
240241
if i >= lim { error(~"missing type in conversion"); }
241242
let tstr = str::slice(s, i, i+1u);
@@ -269,10 +270,7 @@ mod ct {
269270
}
270271
}
271272
272-
// Functions used by the fmt extension at runtime. For now there are a lot of
273-
// decisions made a runtime. If it proves worthwhile then some of these
274-
// conditions can be evaluated at compile-time. For now though it's cleaner to
275-
// implement it 0this way, I think.
273+
// OLD CODE -- eventually remove
276274
mod rt {
277275
#[legacy_exports];
278276
const flag_none : u32 = 0u32;
@@ -328,7 +326,7 @@ mod rt {
328326
let mut unpadded = match cv.precision {
329327
CountImplied => s.to_unique(),
330328
CountIs(max) => if max as uint < str::char_len(s) {
331-
str::substr(s, 0u, max as uint)
329+
str::substr(s, 0, max as uint)
332330
} else {
333331
s.to_unique()
334332
}
@@ -338,7 +336,7 @@ mod rt {
338336
pure fn conv_float(cv: Conv, f: float) -> ~str {
339337
let (to_str, digits) = match cv.precision {
340338
CountIs(c) => (float::to_str_exact, c as uint),
341-
CountImplied => (float::to_str, 6u)
339+
CountImplied => (float::to_str, 6)
342340
};
343341
let mut s = unsafe { to_str(f, digits) };
344342
if 0.0 <= f {
@@ -404,16 +402,17 @@ mod rt {
404402
pure fn ne(other: &PadMode) -> bool { !self.eq(other) }
405403
}
406404

407-
fn pad(cv: Conv, &s: ~str, mode: PadMode) -> ~str {
405+
fn pad(cv: Conv, +s: ~str, mode: PadMode) -> ~str {
406+
let mut s = move s; // sadtimes
408407
let uwidth : uint = match cv.width {
409-
CountImplied => return copy s,
408+
CountImplied => return s,
410409
CountIs(width) => {
411410
// FIXME: width should probably be uint (see Issue #1996)
412411
width as uint
413412
}
414413
};
415414
let strlen = str::char_len(s);
416-
if uwidth <= strlen { return copy s; }
415+
if uwidth <= strlen { return s; }
417416
let mut padchar = ' ';
418417
let diff = uwidth - strlen;
419418
if have_flag(cv.flags, flag_left_justify) {
@@ -444,7 +443,7 @@ mod rt {
444443
// zeros. It may make sense to convert zero padding to a precision
445444
// instead.
446445

447-
if signed && zero_padding && str::len(s) > 0u {
446+
if signed && zero_padding && s.len() > 0 {
448447
let head = str::shift_char(&mut s);
449448
if head == '+' || head == '-' || head == ' ' {
450449
let headstr = str::from_chars(vec::from_elem(1u, head));
@@ -461,7 +460,12 @@ mod rt {
461460
}
462461
}
463462

464-
// XXX remove after snapshots
463+
// NEW CODE
464+
465+
// Functions used by the fmt extension at runtime. For now there are a lot of
466+
// decisions made a runtime. If it proves worthwhile then some of these
467+
// conditions can be evaluated at compile-time. For now though it's cleaner to
468+
// implement it 0this way, I think.
465469
mod rt2 {
466470
#[legacy_exports];
467471
const flag_none : u32 = 0u32;
@@ -477,7 +481,7 @@ mod rt2 {
477481
type Conv = {flags: u32, width: Count, precision: Count, ty: Ty};
478482

479483
pure fn conv_int(cv: Conv, i: int) -> ~str {
480-
let radix = 10u;
484+
let radix = 10;
481485
let prec = get_int_precision(cv);
482486
let mut s : ~str = int_to_str_prec(i, radix, prec);
483487
if 0 <= i {
@@ -511,7 +515,7 @@ mod rt2 {
511515
let mut s = str::from_char(c);
512516
return unsafe { pad(cv, s, PadNozero) };
513517
}
514-
pure fn conv_str(cv: Conv, s: &str) -> ~str {
518+
pure fn conv_str(cv: Conv, +s: &str) -> ~str {
515519
// For strings, precision is the maximum characters
516520
// displayed
517521
let mut unpadded = match cv.precision {
@@ -539,8 +543,8 @@ mod rt2 {
539543
}
540544
return unsafe { pad(cv, s, PadFloat) };
541545
}
542-
pure fn conv_poly<T>(cv: Conv, v: T) -> ~str {
543-
let s = sys::log_str(&v);
546+
pure fn conv_poly<T>(cv: Conv, v: &T) -> ~str {
547+
let s = sys::log_str(v);
544548
return conv_str(cv, s);
545549
}
546550
@@ -593,16 +597,17 @@ mod rt2 {
593597
pure fn ne(other: &PadMode) -> bool { !self.eq(other) }
594598
}
595599

596-
fn pad(cv: Conv, &s: ~str, mode: PadMode) -> ~str {
600+
fn pad(cv: Conv, +s: ~str, mode: PadMode) -> ~str {
601+
let mut s = move s; // sadtimes
597602
let uwidth : uint = match cv.width {
598-
CountImplied => return copy s,
603+
CountImplied => return s,
599604
CountIs(width) => {
600605
// FIXME: width should probably be uint (see Issue #1996)
601606
width as uint
602607
}
603608
};
604609
let strlen = str::char_len(s);
605-
if uwidth <= strlen { return copy s; }
610+
if uwidth <= strlen { return s; }
606611
let mut padchar = ' ';
607612
let diff = uwidth - strlen;
608613
if have_flag(cv.flags, flag_left_justify) {
@@ -633,7 +638,7 @@ mod rt2 {
633638
// zeros. It may make sense to convert zero padding to a precision
634639
// instead.
635640

636-
if signed && zero_padding && str::len(s) > 0u {
641+
if signed && zero_padding && s.len() > 0 {
637642
let head = str::shift_char(&mut s);
638643
if head == '+' || head == '-' || head == ' ' {
639644
let headstr = str::from_chars(vec::from_elem(1u, head));

branches/snap-stage3/src/libcore/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ pub fn program_output(prog: &str, args: &[~str]) ->
328328
return {status: status, out: move outs, err: move errs};
329329
}
330330

331-
fn writeclose(fd: c_int, s: &str) {
331+
fn writeclose(fd: c_int, +s: ~str) {
332332
use io::WriterUtil;
333333

334334
error!("writeclose %d, %s", fd as int, s);

branches/snap-stage3/src/libstd/net_ip.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ mod v4 {
156156
fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
157157
let parts = vec::map(str::split_char(ip, '.'), |s| {
158158
match uint::from_str(*s) {
159-
Some(n) if n <= 255u => n,
160-
_ => 256u
159+
Some(n) if n <= 255 => n,
160+
_ => 256
161161
}
162162
});
163-
if vec::len(parts) != 4u {
163+
if parts.len() != 4 {
164164
result::Err(fmt!("'%s' doesn't have 4 parts", ip))
165165
}
166-
else if vec::contains(parts, &256u) {
166+
else if parts.contains(&256) {
167167
result::Err(fmt!("invalid octal in addr '%s'", ip))
168168
}
169169
else {

0 commit comments

Comments
 (0)