1
Fork 0

Eliminate usages of old sugared call syntax

This commit is contained in:
Brian Anderson 2012-06-26 13:55:56 -07:00
parent 8b2491160d
commit a3382b6f26
280 changed files with 1561 additions and 1572 deletions

View file

@ -1638,7 +1638,7 @@ task in a _failing state_.
~~~~ ~~~~
# let buildr = task::builder(); # let buildr = task::builder();
# task::unsupervise(buildr); # task::unsupervise(buildr);
# task::run(buildr) {|| # do task::run(buildr) {||
(~[1, 2, 3, 4])[0]; (~[1, 2, 3, 4])[0];
(~[mut 'x', 'y'])[1] = 'z'; (~[mut 'x', 'y'])[1] = 'z';
@ -3365,7 +3365,7 @@ An example of a `spawn` call:
let po = comm::port(); let po = comm::port();
let ch = comm::chan(po); let ch = comm::chan(po);
task::spawn {|| do task::spawn {||
// let task run, do other things // let task run, do other things
// ... // ...
comm::send(ch, true); comm::send(ch, true);

View file

@ -924,7 +924,7 @@ processes. They copy the values they close over, much like boxed
closures, but they also 'own' them—meaning no other code can access closures, but they also 'own' them—meaning no other code can access
them. Unique closures mostly exist for spawning new [tasks](#tasks). them. Unique closures mostly exist for spawning new [tasks](#tasks).
### Shorthand syntax ### Do syntax
The compact syntax used for stack closures (`{|arg1, arg2| body}`) can The compact syntax used for stack closures (`{|arg1, arg2| body}`) can
also be used to express boxed and unique closures in situations where also be used to express boxed and unique closures in situations where
@ -934,25 +934,10 @@ the long-hand syntax for the function you're passing, since the
compiler can look at the argument type to find out what the parameter compiler can look at the argument type to find out what the parameter
types are. types are.
As a further simplification, if the final parameter to a function is a Because closures in Rust are so versatile, they are used often, and in
closure, the closure need not be placed within parentheses. You could, particular, functions taking closures are used as control structures
for example, write... in much the same way as `if` or `loop`. For example, this one iterates
over a vector of integers backwards:
~~~~
let doubled = vec::map(~[1, 2, 3]) {|x| x*2};
~~~~
`vec::map` is a function in the core library that applies its last
argument to every element of a vector, producing a new vector.
Even when a closure takes no parameters, you must still write the bars
for the parameter list, as in `{|| ...}`.
## Iteration
Functions taking closures provide a good way to define non-trivial
iteration constructs. For example, this one iterates over a vector
of integers backwards:
~~~~ ~~~~
fn for_rev(v: ~[int], act: fn(int)) { fn for_rev(v: ~[int], act: fn(int)) {
@ -971,19 +956,22 @@ To run such an iteration, you could do this:
for_rev(~[1, 2, 3], {|n| log(error, n); }); for_rev(~[1, 2, 3], {|n| log(error, n); });
~~~~ ~~~~
Making use of the shorthand where a final closure argument can be Because this is such a common pattern Rust has a special form
moved outside of the parentheses permits the following, which of function call that can be written more like a built-in control
looks quite like a normal loop: structure:
~~~~ ~~~~
# fn for_rev(v: ~[int], act: fn(int)) {} # fn for_rev(v: [int], act: fn(int)) {}
for_rev(~[1, 2, 3]) {|n| do for_rev(~[1, 2, 3]) {|n|
log(error, n); log(error, n);
} }
~~~~ ~~~~
Note that, because `for_rev()` returns unit type, no semicolon is Notice that the call is prefixed with the keyword `do` and, instead of
needed when the final closure is pulled outside of the parentheses. writing the final closure inside the argument list it is moved outside
of the parenthesis where it looks visually more like a typical block
of code. The `do` expression is purely syntactic sugar for a call
that takes a final closure argument.
# For loops # For loops
@ -992,12 +980,12 @@ To allow breaking out of loops, many iteration functions, such as
`false` to break off iteration. `false` to break off iteration.
~~~~ ~~~~
vec::each(~[2, 4, 8, 5, 16]) {|n| vec::each(~[2, 4, 8, 5, 16], {|n|
if n % 2 != 0 { if n % 2 != 0 {
io::println("found odd number!"); io::println("found odd number!");
false false
} else { true } } else { true }
} });
~~~~ ~~~~
You can see how that gets noisy. As a syntactic convenience, if the You can see how that gets noisy. As a syntactic convenience, if the
@ -2350,7 +2338,7 @@ module `task`. Let's begin with the simplest one, `task::spawn()`:
~~~~ ~~~~
let some_value = 22; let some_value = 22;
task::spawn {|| do task::spawn {||
io::println("This executes in the child task."); io::println("This executes in the child task.");
io::println(#fmt("%d", some_value)); io::println(#fmt("%d", some_value));
} }
@ -2376,7 +2364,7 @@ in parallel. We might write something like:
# fn some_other_expensive_computation() {} # fn some_other_expensive_computation() {}
let port = comm::port::<int>(); let port = comm::port::<int>();
let chan = comm::chan::<int>(port); let chan = comm::chan::<int>(port);
task::spawn {|| do task::spawn {||
let result = some_expensive_computation(); let result = some_expensive_computation();
comm::send(chan, result); comm::send(chan, result);
} }
@ -2407,7 +2395,7 @@ The next statement actually spawns the child:
# fn some_expensive_computation() -> int { 42 } # fn some_expensive_computation() -> int { 42 }
# let port = comm::port::<int>(); # let port = comm::port::<int>();
# let chan = comm::chan::<int>(port); # let chan = comm::chan::<int>(port);
task::spawn {|| do task::spawn {||
let result = some_expensive_computation(); let result = some_expensive_computation();
comm::send(chan, result); comm::send(chan, result);
} }
@ -2470,7 +2458,7 @@ Here is the code for the parent task:
fn main() { fn main() {
let from_child = comm::port(); let from_child = comm::port();
let to_parent = comm::chan(from_child); let to_parent = comm::chan(from_child);
let to_child = task::spawn_listener {|from_parent| let to_child = do task::spawn_listener {|from_parent|
stringifier(from_parent, to_parent); stringifier(from_parent, to_parent);
}; };
comm::send(to_child, 22u); comm::send(to_child, 22u);

View file

@ -1469,10 +1469,10 @@ fn print_source(s: source) {
}, copy s.packages); }, copy s.packages);
let l = vec::len(pks); let l = vec::len(pks);
print(io::with_str_writer() { |writer| print(io::with_str_writer({ |writer|
let mut list = " >> "; let mut list = " >> ";
vec::iteri(pks) { |i, pk| do vec::iteri(pks) { |i, pk|
if str::len(list) > 78u { if str::len(list) > 78u {
writer.write_line(list); writer.write_line(list);
list = " >> "; list = " >> ";
@ -1481,14 +1481,14 @@ fn print_source(s: source) {
} }
writer.write_line(list); writer.write_line(list);
}); }));
} }
fn cmd_list(c: cargo) { fn cmd_list(c: cargo) {
sync(c); sync(c);
if vec::len(c.opts.free) >= 3u { if vec::len(c.opts.free) >= 3u {
vec::iter_between(c.opts.free, 2u, vec::len(c.opts.free)) { |name| do vec::iter_between(c.opts.free, 2u, vec::len(c.opts.free)) { |name|
if !valid_pkg_name(name) { if !valid_pkg_name(name) {
error(#fmt("'%s' is an invalid source name", name)); error(#fmt("'%s' is an invalid source name", name));
} else { } else {

View file

@ -43,11 +43,11 @@ fn load_props(testfile: str) -> test_props {
pp_exact = parse_pp_exact(ln, testfile); pp_exact = parse_pp_exact(ln, testfile);
} }
option::iter(parse_aux_build(ln)) {|ab| do option::iter(parse_aux_build(ln)) {|ab|
vec::push(aux_builds, ab); vec::push(aux_builds, ab);
} }
option::iter(parse_exec_env(ln)) {|ee| do option::iter(parse_exec_env(ln)) {|ee|
vec::push(exec_env, ee); vec::push(exec_env, ee);
} }
}; };
@ -104,7 +104,7 @@ fn parse_compile_flags(line: str) -> option<str> {
} }
fn parse_exec_env(line: str) -> option<(str, str)> { fn parse_exec_env(line: str) -> option<(str, str)> {
parse_name_value_directive(line, "exec-env").map {|nv| do parse_name_value_directive(line, "exec-env").map {|nv|
// nv is either FOO or FOO=BAR // nv is either FOO or FOO=BAR
let strs = str::splitn_char(nv, '=', 1u); let strs = str::splitn_char(nv, '=', 1u);
alt strs.len() { alt strs.len() {

View file

@ -13,7 +13,7 @@ fn target_env(lib_path: str, prog: str) -> ~[(str,str)] {
assert prog.ends_with(".exe"); assert prog.ends_with(".exe");
let aux_path = prog.slice(0u, prog.len() - 4u) + ".libaux"; let aux_path = prog.slice(0u, prog.len() - 4u) + ".libaux";
env = vec::map(env) {|pair| env = do vec::map(env) {|pair|
let (k,v) = pair; let (k,v) = pair;
if k == "PATH" { ("PATH", v + ";" + lib_path + ";" + aux_path) } if k == "PATH" { ("PATH", v + ";" + lib_path + ";" + aux_path) }
else { (k,v) } else { (k,v) }
@ -60,14 +60,14 @@ fn run(lib_path: str,
writeclose(pipe_in.out, input); writeclose(pipe_in.out, input);
let p = comm::port(); let p = comm::port();
let ch = comm::chan(p); let ch = comm::chan(p);
task::spawn_sched(task::single_threaded) {|| do task::spawn_sched(task::single_threaded) {||
let errput = readclose(pipe_err.in); let errput = readclose(pipe_err.in);
comm::send(ch, (2, errput)); comm::send(ch, (2, errput));
}; }
task::spawn_sched(task::single_threaded) {|| do task::spawn_sched(task::single_threaded) {||
let output = readclose(pipe_out.in); let output = readclose(pipe_out.in);
comm::send(ch, (1, output)); comm::send(ch, (1, output));
}; }
let status = run::waitpid(pid); let status = run::waitpid(pid);
let mut errs = ""; let mut errs = "";
let mut outs = ""; let mut outs = "";

View file

@ -321,7 +321,7 @@ fn compose_and_run_compiler(
let extra_link_args = ~["-L", aux_output_dir_name(config, testfile)]; let extra_link_args = ~["-L", aux_output_dir_name(config, testfile)];
vec::iter(props.aux_builds) {|rel_ab| do vec::iter(props.aux_builds) {|rel_ab|
let abs_ab = path::connect(config.aux_base, rel_ab); let abs_ab = path::connect(config.aux_base, rel_ab);
let aux_args = let aux_args =
make_compile_args(config, props, ~["--lib"] + extra_link_args, make_compile_args(config, props, ~["--lib"] + extra_link_args,

View file

@ -259,9 +259,9 @@ fn check_variants_T<T: copy>(
let L = vec::len(things); let L = vec::len(things);
if L < 100u { if L < 100u {
under(uint::min(L, 20u)) {|i| do under(uint::min(L, 20u)) {|i|
log(error, "Replacing... #" + uint::str(i)); log(error, "Replacing... #" + uint::str(i));
under(uint::min(L, 30u)) {|j| do under(uint::min(L, 30u)) {|j|
log(error, "With... " + stringifier(@things[j])); log(error, "With... " + stringifier(@things[j]));
let crate2 = @replacer(crate, i, things[j], cx.mode); let crate2 = @replacer(crate, i, things[j], cx.mode);
// It would be best to test the *crate* for stability, but // It would be best to test the *crate* for stability, but
@ -421,7 +421,7 @@ fn parse_and_print(code: @str) -> str {
write_file(filename, *code); write_file(filename, *code);
let crate = parse::parse_crate_from_source_str( let crate = parse::parse_crate_from_source_str(
filename, code, ~[], sess); filename, code, ~[], sess);
io::with_str_reader(*code) { |rdr| io::with_str_reader(*code, { |rdr|
as_str({|a|pprust::print_crate(sess.cm, as_str({|a|pprust::print_crate(sess.cm,
sess.span_diagnostic, sess.span_diagnostic,
crate, crate,
@ -429,7 +429,7 @@ fn parse_and_print(code: @str) -> str {
rdr, a, rdr, a,
pprust::no_ann(), pprust::no_ann(),
false)}) false)})
} })
} }
fn has_raw_pointers(c: ast::crate) -> bool { fn has_raw_pointers(c: ast::crate) -> bool {
@ -565,7 +565,7 @@ fn check_variants(files: ~[str], cx: context) {
parse::parse_crate_from_source_str( parse::parse_crate_from_source_str(
file, file,
s, ~[], sess); s, ~[], sess);
io::with_str_reader(*s) { |rdr| io::with_str_reader(*s, { |rdr|
#error("%s", #error("%s",
as_str({|a|pprust::print_crate(sess.cm, as_str({|a|pprust::print_crate(sess.cm,
sess.span_diagnostic, sess.span_diagnostic,
@ -573,8 +573,8 @@ fn check_variants(files: ~[str], cx: context) {
file, file,
rdr, a, rdr, a,
pprust::no_ann(), pprust::no_ann(),
false)})); false)}))
} });
check_variants_of_ast(*crate, sess.cm, file, cx); check_variants_of_ast(*crate, sess.cm, file, cx);
} }
} }

View file

@ -109,9 +109,9 @@ impl methods<T: send> for exclusive<T> {
unsafe::reinterpret_cast(self.data); unsafe::reinterpret_cast(self.data);
let r = { let r = {
let rec: &ex_data<T> = &(*ptr).data; let rec: &ex_data<T> = &(*ptr).data;
rec.lock.lock_cond() {|c| rec.lock.lock_cond({|c|
f(c, &rec.data) f(c, &rec.data)
} })
}; };
unsafe::forget(ptr); unsafe::forget(ptr);
r r
@ -135,7 +135,7 @@ fn shared_arc<T: send const>(-data: T) -> shared_arc<T> {
let a = arc::arc(data); let a = arc::arc(data);
let p = port(); let p = port();
let c = chan(p); let c = chan(p);
task::spawn() {|move a| do task::spawn() {|move a|
let mut live = true; let mut live = true;
let terminate = port(); let terminate = port();
let get = port(); let get = port();
@ -174,7 +174,7 @@ mod tests {
let p = port(); let p = port();
let c = chan(p); let c = chan(p);
task::spawn() {|| do task::spawn() {||
let p = port(); let p = port();
c.send(chan(p)); c.send(chan(p));
@ -200,7 +200,7 @@ mod tests {
let p = port(); let p = port();
let c = chan(p); let c = chan(p);
task::spawn() {|| do task::spawn() {||
let arc_v = get_arc(arc_c); let arc_v = get_arc(arc_c);
let v = *get(&arc_v); let v = *get(&arc_v);
assert v[2] == 3; assert v[2] == 3;
@ -225,7 +225,7 @@ mod tests {
let total = total.clone(); let total = total.clone();
futures += ~[future::spawn({|| futures += ~[future::spawn({||
for uint::range(0u, count) {|_i| for uint::range(0u, count) {|_i|
total.with {|_cond, count| do total.with {|_cond, count|
**count += 1u; **count += 1u;
} }
} }
@ -234,7 +234,7 @@ mod tests {
for futures.each {|f| f.get() }; for futures.each {|f| f.get() };
total.with {|_cond, total| do total.with {|_cond, total|
assert **total == num_tasks * count assert **total == num_tasks * count
}; };
} }

View file

@ -65,7 +65,7 @@ pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
#[test] #[test]
fn test_bool_from_str() { fn test_bool_from_str() {
all_values { |v| do all_values { |v|
assert some(v) == from_str(bool::to_str(v)) assert some(v) == from_str(bool::to_str(v))
} }
} }
@ -78,7 +78,7 @@ fn test_bool_to_str() {
#[test] #[test]
fn test_bool_to_bit() { fn test_bool_to_bit() {
all_values { |v| do all_values { |v|
assert to_bit(v) == if is_true(v) { 1u8 } else { 0u8 }; assert to_bit(v) == if is_true(v) { 1u8 } else { 0u8 };
} }
} }

View file

@ -98,7 +98,7 @@ class port_ptr<T:send> {
let po: *rust_port; let po: *rust_port;
new(po: *rust_port) { self.po = po; } new(po: *rust_port) { self.po = po; }
drop unsafe { drop unsafe {
task::unkillable {|| do task::unkillable {||
// Once the port is detached it's guaranteed not to receive further // Once the port is detached it's guaranteed not to receive further
// messages // messages
let yield = 0u; let yield = 0u;
@ -223,7 +223,7 @@ fn select2<A: send, B: send>(p_a: port<A>, p_b: port<B>)
let mut resport: *rust_port; let mut resport: *rust_port;
resport = rusti::init::<*rust_port>(); resport = rusti::init::<*rust_port>();
vec::as_buf(ports) {|ports| do vec::as_buf(ports) {|ports|
rustrt::rust_port_select(ptr::addr_of(resport), ports, n_ports, rustrt::rust_port_select(ptr::addr_of(resport), ports, n_ports,
yieldp); yieldp);
} }
@ -364,16 +364,16 @@ fn test_select2_rendezvous() {
let ch_a = chan(po_a); let ch_a = chan(po_a);
let ch_b = chan(po_b); let ch_b = chan(po_b);
iter::repeat(10u) {|| do iter::repeat(10u) {||
task::spawn {|| do task::spawn {||
iter::repeat(10u) {|| task::yield() } iter::repeat(10u, {|| task::yield() });
send(ch_a, "a"); send(ch_a, "a");
}; };
assert select2(po_a, po_b) == either::left("a"); assert select2(po_a, po_b) == either::left("a");
task::spawn {|| do task::spawn {||
iter::repeat(10u) {|| task::yield() } iter::repeat(10u, {|| task::yield() });
send(ch_b, "b"); send(ch_b, "b");
}; };
@ -391,14 +391,14 @@ fn test_select2_stress() {
let msgs = 100u; let msgs = 100u;
let times = 4u; let times = 4u;
iter::repeat(times) {|| do iter::repeat(times) {||
task::spawn {|| do task::spawn {||
iter::repeat(msgs) {|| do iter::repeat(msgs) {||
send(ch_a, "a") send(ch_a, "a")
} }
}; };
task::spawn {|| do task::spawn {||
iter::repeat(msgs) {|| do iter::repeat(msgs) {||
send(ch_b, "b") send(ch_b, "b")
} }
}; };
@ -406,7 +406,7 @@ fn test_select2_stress() {
let mut as = 0; let mut as = 0;
let mut bs = 0; let mut bs = 0;
iter::repeat(msgs * times * 2u) {|| do iter::repeat(msgs * times * 2u) {||
alt check select2(po_a, po_b) { alt check select2(po_a, po_b) {
either::left("a") { as += 1 } either::left("a") { as += 1 }
either::right("b") { bs += 1 } either::right("b") { bs += 1 }
@ -440,9 +440,9 @@ fn test_recv_chan_wrong_task() {
let po = port(); let po = port();
let ch = chan(po); let ch = chan(po);
send(ch, "flower"); send(ch, "flower");
assert result::is_err(task::try {|| assert result::is_err(task::try({||
recv_chan(ch) recv_chan(ch)
}) }))
} }
#[test] #[test]
@ -462,8 +462,8 @@ fn test_chan_peek() {
#[test] #[test]
fn test_listen() { fn test_listen() {
listen {|parent| do listen {|parent|
task::spawn {|| do task::spawn {||
parent.send("oatmeal-salad"); parent.send("oatmeal-salad");
} }
assert parent.recv() == "oatmeal-salad"; assert parent.recv() == "oatmeal-salad";
@ -473,18 +473,18 @@ fn test_listen() {
#[test] #[test]
#[ignore(cfg(windows))] #[ignore(cfg(windows))]
fn test_port_detach_fail() { fn test_port_detach_fail() {
iter::repeat(100u) {|| do iter::repeat(100u) {||
let builder = task::builder(); let builder = task::builder();
task::unsupervise(builder); task::unsupervise(builder);
task::run(builder) {|| do task::run(builder) {||
let po = port(); let po = port();
let ch = po.chan(); let ch = po.chan();
task::spawn {|| do task::spawn {||
fail; fail;
} }
task::spawn {|| do task::spawn {||
ch.send(()); ch.send(());
} }
} }

View file

@ -114,12 +114,12 @@ impl extensions<A> for dvec<A> {
"] "]
#[inline(always)] #[inline(always)]
fn swap(f: fn(-~[mut A]) -> ~[mut A]) { fn swap(f: fn(-~[mut A]) -> ~[mut A]) {
self.borrow { |v| self.return(f(v)) } self.borrow({ |v| self.return(f(v)) })
} }
#[doc = "Returns the number of elements currently in the dvec"] #[doc = "Returns the number of elements currently in the dvec"]
fn len() -> uint { fn len() -> uint {
self.borrow { |v| do self.borrow { |v|
let l = v.len(); let l = v.len();
self.return(v); self.return(v);
l l
@ -134,7 +134,7 @@ impl extensions<A> for dvec<A> {
#[doc = "Remove and return the last element"] #[doc = "Remove and return the last element"]
fn pop() -> A { fn pop() -> A {
self.borrow { |v| do self.borrow { |v|
let mut v <- v; let mut v <- v;
let result = vec::pop(v); let result = vec::pop(v);
self.return(v); self.return(v);
@ -164,7 +164,7 @@ impl extensions<A> for dvec<A> {
#[doc = "Remove and return the first element"] #[doc = "Remove and return the first element"]
fn shift() -> A { fn shift() -> A {
self.borrow { |v| do self.borrow { |v|
let mut v = vec::from_mut(v); let mut v = vec::from_mut(v);
let result = vec::shift(v); let result = vec::shift(v);
self.return(vec::to_mut(v)); self.return(vec::to_mut(v));
@ -187,7 +187,7 @@ impl extensions<A:copy> for dvec<A> {
Appends elements from `from_idx` to `to_idx` (exclusive) Appends elements from `from_idx` to `to_idx` (exclusive)
"] "]
fn push_slice(ts: &[const A], from_idx: uint, to_idx: uint) { fn push_slice(ts: &[const A], from_idx: uint, to_idx: uint) {
self.swap { |v| do self.swap { |v|
let mut v <- v; let mut v <- v;
let new_len = vec::len(v) + to_idx - from_idx; let new_len = vec::len(v) + to_idx - from_idx;
vec::reserve(v, new_len); vec::reserve(v, new_len);
@ -207,7 +207,7 @@ impl extensions<A:copy> for dvec<A> {
attempts to access this vector. attempts to access this vector.
"] "]
fn append_iter<A, I:iter::base_iter<A>>(ts: I) { fn append_iter<A, I:iter::base_iter<A>>(ts: I) {
self.swap { |v| do self.swap { |v|
let mut v = alt ts.size_hint() { let mut v = alt ts.size_hint() {
none { v } none { v }
some(h) { some(h) {
@ -229,7 +229,7 @@ impl extensions<A:copy> for dvec<A> {
See `unwrap()` if you do not wish to copy the contents. See `unwrap()` if you do not wish to copy the contents.
"] "]
fn get() -> ~[A] { fn get() -> ~[A] {
self.borrow { |v| do self.borrow { |v|
let w = vec::from_mut(copy v); let w = vec::from_mut(copy v);
self.return(v); self.return(v);
w w
@ -259,7 +259,7 @@ impl extensions<A:copy> for dvec<A> {
growing the vector if necessary. New elements will be initialized growing the vector if necessary. New elements will be initialized
with `initval`"] with `initval`"]
fn grow_set_elt(idx: uint, initval: A, val: A) { fn grow_set_elt(idx: uint, initval: A, val: A) {
self.swap { |v| do self.swap { |v|
let mut v <- v; let mut v <- v;
vec::grow_set(v, idx, initval, val); vec::grow_set(v, idx, initval, val);
v v

View file

@ -64,7 +64,7 @@ fn from_port<A:send>(-port: comm::port<A>) -> future<A> {
waiting for the result to be received on the port. waiting for the result to be received on the port.
"]; "];
from_fn {|| do from_fn {||
comm::recv(port) comm::recv(port)
} }
} }
@ -93,7 +93,7 @@ fn spawn<A:send>(+blk: fn~() -> A) -> future<A> {
let mut po = comm::port(); let mut po = comm::port();
let ch = comm::chan(po); let ch = comm::chan(po);
task::spawn {|| do task::spawn {||
comm::send(ch, blk()) comm::send(ch, blk())
}; };
from_port(po) from_port(po)
@ -102,7 +102,7 @@ fn spawn<A:send>(+blk: fn~() -> A) -> future<A> {
fn get<A:copy>(future: future<A>) -> A { fn get<A:copy>(future: future<A>) -> A {
#[doc = "Get the value of the future"]; #[doc = "Get the value of the future"];
with(future) {|v| v } do with(future) {|v| v }
} }
fn with<A,B>(future: future<A>, blk: fn(A) -> B) -> B { fn with<A,B>(future: future<A>, blk: fn(A) -> B) -> B {
@ -150,18 +150,18 @@ fn test_iface_get() {
#[test] #[test]
fn test_with() { fn test_with() {
let f = from_value("nail"); let f = from_value("nail");
assert with(f) {|v| v} == "nail"; assert with(f, {|v| v}) == "nail";
} }
#[test] #[test]
fn test_iface_with() { fn test_iface_with() {
let f = from_value("kale"); let f = from_value("kale");
assert f.with {|v| v} == "kale"; assert f.with({|v| v}) == "kale";
} }
#[test] #[test]
fn test_spawn() { fn test_spawn() {
let f = spawn {|| "bale" }; let f = spawn({|| "bale" });
assert get(f) == "bale"; assert get(f) == "bale";
} }
@ -169,6 +169,6 @@ fn test_spawn() {
#[should_fail] #[should_fail]
#[ignore(cfg(target_os = "win32"))] #[ignore(cfg(target_os = "win32"))]
fn test_futurefail() { fn test_futurefail() {
let f = spawn {|| fail }; let f = spawn({|| fail });
let _x: str = get(f); let _x: str = get(f);
} }

View file

@ -93,8 +93,8 @@ fn from_str(s: str) -> option<T> { parse_buf(str::bytes(s), 10u) }
#[doc = "Convert to a string in a given base"] #[doc = "Convert to a string in a given base"]
fn to_str(n: T, radix: uint) -> str { fn to_str(n: T, radix: uint) -> str {
to_str_bytes(n, radix) {|slice| do to_str_bytes(n, radix) {|slice|
vec::unpack_slice(slice) {|p, len| do vec::unpack_slice(slice) {|p, len|
unsafe { str::unsafe::from_buf_len(p, len) } unsafe { str::unsafe::from_buf_len(p, len) }
} }
} }

View file

@ -195,7 +195,7 @@ impl of reader for *libc::FILE {
fn read_bytes(len: uint) -> ~[u8] { fn read_bytes(len: uint) -> ~[u8] {
let mut buf : ~[mut u8] = ~[mut]; let mut buf : ~[mut u8] = ~[mut];
vec::reserve(buf, len); vec::reserve(buf, len);
vec::as_mut_buf(buf) {|b| do vec::as_mut_buf(buf) {|b|
let read = libc::fread(b as *mut c_void, 1u as size_t, let read = libc::fread(b as *mut c_void, 1u as size_t,
len as size_t, self); len as size_t, self);
unsafe { vec::unsafe::set_len(buf, read as uint) }; unsafe { vec::unsafe::set_len(buf, read as uint) };
@ -308,7 +308,7 @@ fn str_reader(s: str) -> reader {
} }
fn with_str_reader<T>(s: str, f: fn(reader) -> T) -> T { fn with_str_reader<T>(s: str, f: fn(reader) -> T) -> T {
str::as_bytes(s) { |bytes| do str::as_bytes(s) { |bytes|
with_bytes_reader_between(bytes, 0u, str::len(s), f) with_bytes_reader_between(bytes, 0u, str::len(s), f)
} }
} }
@ -334,7 +334,7 @@ impl <T: writer, C> of writer for {base: T, cleanup: C} {
impl of writer for *libc::FILE { impl of writer for *libc::FILE {
fn write(v: &[const u8]) { fn write(v: &[const u8]) {
vec::unpack_const_slice(v) {|vbuf, len| do vec::unpack_const_slice(v) {|vbuf, len|
let nout = libc::fwrite(vbuf as *c_void, len as size_t, let nout = libc::fwrite(vbuf as *c_void, len as size_t,
1u as size_t, self); 1u as size_t, self);
if nout < 1 as size_t { if nout < 1 as size_t {
@ -363,7 +363,7 @@ fn FILE_writer(f: *libc::FILE, cleanup: bool) -> writer {
impl of writer for fd_t { impl of writer for fd_t {
fn write(v: &[const u8]) { fn write(v: &[const u8]) {
let mut count = 0u; let mut count = 0u;
vec::unpack_const_slice(v) {|vbuf, len| do vec::unpack_const_slice(v) {|vbuf, len|
while count < len { while count < len {
let vb = ptr::const_offset(vbuf, count) as *c_void; let vb = ptr::const_offset(vbuf, count) as *c_void;
let nout = libc::write(self, vb, len as size_t); let nout = libc::write(self, vb, len as size_t);
@ -420,7 +420,7 @@ fn mk_file_writer(path: str, flags: ~[fileflag])
no_flag { } no_flag { }
} }
} }
let fd = os::as_c_charp(path) {|pathbuf| let fd = do os::as_c_charp(path) {|pathbuf|
libc::open(pathbuf, fflags, libc::open(pathbuf, fflags,
(S_IRUSR | S_IWUSR) as c_int) (S_IRUSR | S_IWUSR) as c_int)
}; };
@ -514,64 +514,64 @@ impl writer_util for writer {
self.write_str(str::from_char(ch)); self.write_str(str::from_char(ch));
} }
} }
fn write_str(s: str/&) { str::byte_slice(s) {|v| self.write(v); } } fn write_str(s: str/&) { str::byte_slice(s, {|v| self.write(v); }) }
fn write_line(s: str/&) { fn write_line(s: str/&) {
self.write_str(s); self.write_str(s);
self.write_str("\n"/&); self.write_str("\n"/&);
} }
fn write_int(n: int) { fn write_int(n: int) {
int::to_str_bytes(n, 10u) {|buf| self.write(buf) } int::to_str_bytes(n, 10u, {|buf| self.write(buf) })
} }
fn write_uint(n: uint) { fn write_uint(n: uint) {
uint::to_str_bytes(false, n, 10u) {|buf| self.write(buf) } uint::to_str_bytes(false, n, 10u, {|buf| self.write(buf) })
} }
fn write_le_uint(n: uint, size: uint) { fn write_le_uint(n: uint, size: uint) {
u64_to_le_bytes(n as u64, size) {|v| self.write(v); } u64_to_le_bytes(n as u64, size, {|v| self.write(v) })
} }
fn write_le_int(n: int, size: uint) { fn write_le_int(n: int, size: uint) {
u64_to_le_bytes(n as u64, size) {|v| self.write(v); } u64_to_le_bytes(n as u64, size, {|v| self.write(v) })
} }
fn write_be_uint(n: uint, size: uint) { fn write_be_uint(n: uint, size: uint) {
u64_to_be_bytes(n as u64, size) {|v| self.write(v); } u64_to_be_bytes(n as u64, size, {|v| self.write(v) })
} }
fn write_be_int(n: int, size: uint) { fn write_be_int(n: int, size: uint) {
u64_to_be_bytes(n as u64, size) {|v| self.write(v); } u64_to_be_bytes(n as u64, size, {|v| self.write(v) })
} }
fn write_be_u64(n: u64) { fn write_be_u64(n: u64) {
u64_to_be_bytes(n, 8u) {|v| self.write(v); } u64_to_be_bytes(n, 8u, {|v| self.write(v) })
} }
fn write_be_u32(n: u32) { fn write_be_u32(n: u32) {
u64_to_be_bytes(n as u64, 4u) {|v| self.write(v); } u64_to_be_bytes(n as u64, 4u, {|v| self.write(v) })
} }
fn write_be_u16(n: u16) { fn write_be_u16(n: u16) {
u64_to_be_bytes(n as u64, 2u) {|v| self.write(v); } u64_to_be_bytes(n as u64, 2u, {|v| self.write(v) })
} }
fn write_be_i64(n: i64) { fn write_be_i64(n: i64) {
u64_to_be_bytes(n as u64, 8u) {|v| self.write(v); } u64_to_be_bytes(n as u64, 8u, {|v| self.write(v) })
} }
fn write_be_i32(n: i32) { fn write_be_i32(n: i32) {
u64_to_be_bytes(n as u64, 4u) {|v| self.write(v); } u64_to_be_bytes(n as u64, 4u, {|v| self.write(v) })
} }
fn write_be_i16(n: i16) { fn write_be_i16(n: i16) {
u64_to_be_bytes(n as u64, 2u) {|v| self.write(v); } u64_to_be_bytes(n as u64, 2u, {|v| self.write(v) })
} }
fn write_le_u64(n: u64) { fn write_le_u64(n: u64) {
u64_to_le_bytes(n, 8u) {|v| self.write(v); } u64_to_le_bytes(n, 8u, {|v| self.write(v) })
} }
fn write_le_u32(n: u32) { fn write_le_u32(n: u32) {
u64_to_le_bytes(n as u64, 4u) {|v| self.write(v); } u64_to_le_bytes(n as u64, 4u, {|v| self.write(v) })
} }
fn write_le_u16(n: u16) { fn write_le_u16(n: u16) {
u64_to_le_bytes(n as u64, 2u) {|v| self.write(v); } u64_to_le_bytes(n as u64, 2u, {|v| self.write(v) })
} }
fn write_le_i64(n: i64) { fn write_le_i64(n: i64) {
u64_to_le_bytes(n as u64, 8u) {|v| self.write(v); } u64_to_le_bytes(n as u64, 8u, {|v| self.write(v) })
} }
fn write_le_i32(n: i32) { fn write_le_i32(n: i32) {
u64_to_le_bytes(n as u64, 4u) {|v| self.write(v); } u64_to_le_bytes(n as u64, 4u, {|v| self.write(v) })
} }
fn write_le_i16(n: i16) { fn write_le_i16(n: i16) {
u64_to_le_bytes(n as u64, 2u) {|v| self.write(v); } u64_to_le_bytes(n as u64, 2u, {|v| self.write(v) })
} }
fn write_u8(n: u8) { self.write(&[n]) } fn write_u8(n: u8) { self.write(&[n]) }
@ -584,8 +584,8 @@ fn file_writer(path: str, flags: ~[fileflag]) -> result<writer, str> {
// FIXME: fileflags // #2004 // FIXME: fileflags // #2004
fn buffered_file_writer(path: str) -> result<writer, str> { fn buffered_file_writer(path: str) -> result<writer, str> {
let f = os::as_c_charp(path) {|pathbuf| let f = do os::as_c_charp(path) {|pathbuf|
os::as_c_charp("w") {|modebuf| do os::as_c_charp("w") {|modebuf|
libc::fopen(pathbuf, modebuf) libc::fopen(pathbuf, modebuf)
} }
}; };

View file

@ -7,7 +7,7 @@ Attempts to access this dvec during iteration will fail.
"] "]
fn EACH<A>(self: IMPL_T<A>, f: fn(A) -> bool) { fn EACH<A>(self: IMPL_T<A>, f: fn(A) -> bool) {
import dvec::extensions; import dvec::extensions;
self.swap { |v| vec::each(v, f); v } self.swap({ |v| vec::each(v, f); v })
} }
fn SIZE_HINT<A>(self: IMPL_T<A>) -> option<uint> { fn SIZE_HINT<A>(self: IMPL_T<A>) -> option<uint> {

View file

@ -28,7 +28,7 @@ fn any<A,IA:base_iter<A>>(self: IA, blk: fn(A) -> bool) -> bool {
fn filter_to_vec<A:copy,IA:base_iter<A>>(self: IA, fn filter_to_vec<A:copy,IA:base_iter<A>>(self: IA,
prd: fn(A) -> bool) -> ~[A] { prd: fn(A) -> bool) -> ~[A] {
let mut result = ~[]; let mut result = ~[];
self.size_hint().iter {|hint| vec::reserve(result, hint); } self.size_hint().iter({|hint| vec::reserve(result, hint); });
for self.each {|a| for self.each {|a|
if prd(a) { vec::push(result, a); } if prd(a) { vec::push(result, a); }
} }
@ -37,7 +37,7 @@ fn filter_to_vec<A:copy,IA:base_iter<A>>(self: IA,
fn map_to_vec<A:copy,B,IA:base_iter<A>>(self: IA, op: fn(A) -> B) -> ~[B] { fn map_to_vec<A:copy,B,IA:base_iter<A>>(self: IA, op: fn(A) -> B) -> ~[B] {
let mut result = ~[]; let mut result = ~[];
self.size_hint().iter {|hint| vec::reserve(result, hint); } self.size_hint().iter({|hint| vec::reserve(result, hint); });
for self.each {|a| for self.each {|a|
vec::push(result, op(a)); vec::push(result, op(a));
} }
@ -76,7 +76,7 @@ fn contains<A,IA:base_iter<A>>(self: IA, x: A) -> bool {
} }
fn count<A,IA:base_iter<A>>(self: IA, x: A) -> uint { fn count<A,IA:base_iter<A>>(self: IA, x: A) -> uint {
foldl(self, 0u) {|count, value| do foldl(self, 0u) {|count, value|
if value == x { if value == x {
count + 1u count + 1u
} else { } else {
@ -108,7 +108,7 @@ fn repeat(times: uint, blk: fn()) {
} }
fn min<A:copy,IA:base_iter<A>>(self: IA) -> A { fn min<A:copy,IA:base_iter<A>>(self: IA) -> A {
alt foldl::<A,option<A>,IA>(self, none) {|a, b| alt do foldl::<A,option<A>,IA>(self, none) {|a, b|
alt a { alt a {
some(a_) if a_ < b { some(a_) if a_ < b {
// FIXME (#2005): Not sure if this is successfully optimized to // FIXME (#2005): Not sure if this is successfully optimized to
@ -124,7 +124,7 @@ fn min<A:copy,IA:base_iter<A>>(self: IA) -> A {
} }
fn max<A:copy,IA:base_iter<A>>(self: IA) -> A { fn max<A:copy,IA:base_iter<A>>(self: IA) -> A {
alt foldl::<A,option<A>,IA>(self, none) {|a, b| alt do foldl::<A,option<A>,IA>(self, none) {|a, b|
alt a { alt a {
some(a_) if a_ > b { some(a_) if a_ > b {
// FIXME (#2005): Not sure if this is successfully optimized to // FIXME (#2005): Not sure if this is successfully optimized to

View file

@ -31,7 +31,7 @@ fn chan<T: send>(p: port<T>) -> chan<T> {
fn send<T: send>(c: chan<T>, -x: T) { fn send<T: send>(c: chan<T>, -x: T) {
let mut x <- some(x); let mut x <- some(x);
(*c).with {|cond, data| do (*c).with {|cond, data|
let mut xx = none; let mut xx = none;
xx <-> x; xx <-> x;
(*data).push(option::unwrap(xx)); (*data).push(option::unwrap(xx));
@ -40,7 +40,7 @@ fn send<T: send>(c: chan<T>, -x: T) {
} }
fn recv<T: send>(p: port<T>) -> T { fn recv<T: send>(p: port<T>) -> T {
(*p).with {|cond, data| do (*p).with {|cond, data|
if (*data).len() == 0u { if (*data).len() == 0u {
cond.wait(); cond.wait();
} }

View file

@ -133,10 +133,10 @@ fn test_unwrap_ptr() {
#[test] #[test]
fn test_unwrap_str() { fn test_unwrap_str() {
let x = "test"; let x = "test";
let addr_x = str::as_buf(x) {|buf| ptr::addr_of(buf) }; let addr_x = str::as_buf(x, {|buf| ptr::addr_of(buf) });
let opt = some(x); let opt = some(x);
let y = unwrap(opt); let y = unwrap(opt);
let addr_y = str::as_buf(y) {|buf| ptr::addr_of(buf) }; let addr_y = str::as_buf(y, {|buf| ptr::addr_of(buf) });
assert addr_x == addr_y; assert addr_x == addr_y;
} }

View file

@ -64,13 +64,13 @@ fn env() -> ~[(str,str)] {
const tmpbuf_sz : uint = 1000u; const tmpbuf_sz : uint = 1000u;
fn as_c_charp<T>(s: str, f: fn(*c_char) -> T) -> T { fn as_c_charp<T>(s: str, f: fn(*c_char) -> T) -> T {
str::as_c_str(s) {|b| f(b as *c_char) } str::as_c_str(s, {|b| f(b as *c_char) })
} }
fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool) fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool)
-> option<str> { -> option<str> {
let buf = vec::to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char)); let buf = vec::to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char));
vec::as_mut_buf(buf) { |b| do vec::as_mut_buf(buf) { |b|
if f(b, tmpbuf_sz as size_t) unsafe { if f(b, tmpbuf_sz as size_t) unsafe {
some(str::unsafe::from_buf(b as *u8)) some(str::unsafe::from_buf(b as *u8))
} else { } else {
@ -95,7 +95,7 @@ mod win32 {
let mut done = false; let mut done = false;
while !done { while !done {
let buf = vec::to_mut(vec::from_elem(n as uint, 0u16)); let buf = vec::to_mut(vec::from_elem(n as uint, 0u16));
vec::as_mut_buf(buf) {|b| do vec::as_mut_buf(buf) {|b|
let k : dword = f(b, tmpbuf_sz as dword); let k : dword = f(b, tmpbuf_sz as dword);
if k == (0 as dword) { if k == (0 as dword) {
done = true; done = true;
@ -182,7 +182,7 @@ mod global_env {
fn global_env_task(msg_po: comm::port<msg>) { fn global_env_task(msg_po: comm::port<msg>) {
unsafe { unsafe {
priv::weaken_task {|weak_po| do priv::weaken_task {|weak_po|
loop { loop {
alt comm::select2(msg_po, weak_po) { alt comm::select2(msg_po, weak_po) {
either::left(msg_getenv(n, resp_ch)) { either::left(msg_getenv(n, resp_ch)) {
@ -220,8 +220,8 @@ mod global_env {
import libc::types::os::arch::extra::*; import libc::types::os::arch::extra::*;
import libc::funcs::extra::kernel32::*; import libc::funcs::extra::kernel32::*;
import win32::*; import win32::*;
as_utf16_p(n) {|u| do as_utf16_p(n) {|u|
fill_utf16_buf_and_decode() {|buf, sz| do fill_utf16_buf_and_decode() {|buf, sz|
GetEnvironmentVariableW(u, buf, sz) GetEnvironmentVariableW(u, buf, sz)
} }
} }
@ -233,8 +233,8 @@ mod global_env {
// FIXME: remove this when export globs work properly. #1238 // FIXME: remove this when export globs work properly. #1238
import libc::funcs::posix01::unistd::setenv; import libc::funcs::posix01::unistd::setenv;
str::as_c_str(n) {|nbuf| do str::as_c_str(n) {|nbuf|
str::as_c_str(v) {|vbuf| do str::as_c_str(v) {|vbuf|
setenv(nbuf, vbuf, 1i32); setenv(nbuf, vbuf, 1i32);
} }
} }
@ -246,8 +246,8 @@ mod global_env {
// FIXME: remove imports when export globs work properly. #1238 // FIXME: remove imports when export globs work properly. #1238
import libc::funcs::extra::kernel32::*; import libc::funcs::extra::kernel32::*;
import win32::*; import win32::*;
as_utf16_p(n) {|nbuf| do as_utf16_p(n) {|nbuf|
as_utf16_p(v) {|vbuf| do as_utf16_p(v) {|vbuf|
SetEnvironmentVariableW(nbuf, vbuf); SetEnvironmentVariableW(nbuf, vbuf);
} }
} }
@ -257,7 +257,7 @@ mod global_env {
} }
fn fdopen(fd: c_int) -> *FILE { fn fdopen(fd: c_int) -> *FILE {
ret as_c_charp("r") {|modebuf| ret do as_c_charp("r") {|modebuf|
libc::fdopen(fd, modebuf) libc::fdopen(fd, modebuf)
}; };
} }
@ -370,7 +370,7 @@ fn self_exe_path() -> option<path> {
unsafe { unsafe {
import libc::funcs::bsd44::*; import libc::funcs::bsd44::*;
import libc::consts::os::extra::*; import libc::consts::os::extra::*;
fill_charp_buf() {|buf, sz| do fill_charp_buf() {|buf, sz|
let mib = ~[CTL_KERN as c_int, let mib = ~[CTL_KERN as c_int,
KERN_PROC as c_int, KERN_PROC as c_int,
KERN_PROC_PATHNAME as c_int, -1 as c_int]; KERN_PROC_PATHNAME as c_int, -1 as c_int];
@ -384,8 +384,8 @@ fn self_exe_path() -> option<path> {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
fn load_self() -> option<path> { fn load_self() -> option<path> {
import libc::funcs::posix01::unistd::readlink; import libc::funcs::posix01::unistd::readlink;
fill_charp_buf() {|buf, sz| do fill_charp_buf() {|buf, sz|
as_c_charp("/proc/self/exe") { |proc_self_buf| do as_c_charp("/proc/self/exe") { |proc_self_buf|
readlink(proc_self_buf, buf, sz) != (-1 as ssize_t) readlink(proc_self_buf, buf, sz) != (-1 as ssize_t)
} }
} }
@ -395,8 +395,7 @@ fn self_exe_path() -> option<path> {
fn load_self() -> option<path> { fn load_self() -> option<path> {
// FIXME: remove imports when export globs work properly. #1238 // FIXME: remove imports when export globs work properly. #1238
import libc::funcs::extra::*; import libc::funcs::extra::*;
do fill_charp_buf() {|buf, sz|
fill_charp_buf() {|buf, sz|
_NSGetExecutablePath(buf, ptr::mut_addr_of(sz as u32)) _NSGetExecutablePath(buf, ptr::mut_addr_of(sz as u32))
== (0 as c_int) == (0 as c_int)
} }
@ -408,12 +407,12 @@ fn self_exe_path() -> option<path> {
import libc::types::os::arch::extra::*; import libc::types::os::arch::extra::*;
import libc::funcs::extra::kernel32::*; import libc::funcs::extra::kernel32::*;
import win32::*; import win32::*;
fill_utf16_buf_and_decode() {|buf, sz| do fill_utf16_buf_and_decode() {|buf, sz|
GetModuleFileNameW(0u as dword, buf, sz) GetModuleFileNameW(0u as dword, buf, sz)
} }
} }
option::map(load_self()) {|pth| do option::map(load_self()) {|pth|
path::dirname(pth) + path::path_sep() path::dirname(pth) + path::path_sep()
} }
} }
@ -453,7 +452,7 @@ fn homedir() -> option<path> {
#[cfg(windows)] #[cfg(windows)]
fn secondary() -> option<path> { fn secondary() -> option<path> {
option::chain(getenv("USERPROFILE")) {|p| do option::chain(getenv("USERPROFILE")) {|p|
if !str::is_empty(p) { if !str::is_empty(p) {
some(p) some(p)
} else { } else {
@ -470,7 +469,7 @@ fn walk_dir(p: path, f: fn(path) -> bool) {
fn walk_dir_(p: path, f: fn(path) -> bool) -> bool { fn walk_dir_(p: path, f: fn(path) -> bool) -> bool {
let mut keepgoing = true; let mut keepgoing = true;
list_dir(p).each {|q| do list_dir(p).each {|q|
let path = path::connect(p, q); let path = path::connect(p, q);
if !f(path) { if !f(path) {
keepgoing = false; keepgoing = false;
@ -494,14 +493,14 @@ fn walk_dir(p: path, f: fn(path) -> bool) {
#[doc = "Indicates whether a path represents a directory"] #[doc = "Indicates whether a path represents a directory"]
fn path_is_dir(p: path) -> bool { fn path_is_dir(p: path) -> bool {
str::as_c_str(p) {|buf| do str::as_c_str(p) {|buf|
rustrt::rust_path_is_dir(buf) != 0 as c_int rustrt::rust_path_is_dir(buf) != 0 as c_int
} }
} }
#[doc = "Indicates whether a path exists"] #[doc = "Indicates whether a path exists"]
fn path_exists(p: path) -> bool { fn path_exists(p: path) -> bool {
str::as_c_str(p) {|buf| do str::as_c_str(p) {|buf|
rustrt::rust_path_exists(buf) != 0 as c_int rustrt::rust_path_exists(buf) != 0 as c_int
} }
} }
@ -538,7 +537,7 @@ fn make_dir(p: path, mode: c_int) -> bool {
import libc::funcs::extra::kernel32::*; import libc::funcs::extra::kernel32::*;
import win32::*; import win32::*;
// FIXME: turn mode into something useful? #2623 // FIXME: turn mode into something useful? #2623
as_utf16_p(p) {|buf| do as_utf16_p(p) {|buf|
CreateDirectoryW(buf, unsafe { unsafe::reinterpret_cast(0) }) CreateDirectoryW(buf, unsafe { unsafe::reinterpret_cast(0) })
!= (0 as BOOL) != (0 as BOOL)
} }
@ -546,7 +545,7 @@ fn make_dir(p: path, mode: c_int) -> bool {
#[cfg(unix)] #[cfg(unix)]
fn mkdir(p: path, mode: c_int) -> bool { fn mkdir(p: path, mode: c_int) -> bool {
as_c_charp(p) {|c| do as_c_charp(p) {|c|
libc::mkdir(c, mode as mode_t) == (0 as c_int) libc::mkdir(c, mode as mode_t) == (0 as c_int)
} }
} }
@ -569,7 +568,7 @@ fn list_dir(p: path) -> ~[str] {
} }
} }
rustrt::rust_list_files(star(p)).filter {|filename| do rustrt::rust_list_files(star(p)).filter {|filename|
!str::eq(filename, ".") && !str::eq(filename, "..") !str::eq(filename, ".") && !str::eq(filename, "..")
} }
} }
@ -586,7 +585,7 @@ fn list_dir_path(p: path) -> ~[str] {
&& p[pl - 1u] as char != path::consts::alt_path_sep) { && p[pl - 1u] as char != path::consts::alt_path_sep) {
p += path::path_sep(); p += path::path_sep();
} }
os::list_dir(p).map {|f| p + f} os::list_dir(p).map({|f| p + f})
} }
#[doc = "Removes a directory at the specified path"] #[doc = "Removes a directory at the specified path"]
@ -599,14 +598,14 @@ fn remove_dir(p: path) -> bool {
import libc::funcs::extra::kernel32::*; import libc::funcs::extra::kernel32::*;
import libc::types::os::arch::extra::*; import libc::types::os::arch::extra::*;
import win32::*; import win32::*;
ret as_utf16_p(p) {|buf| ret do as_utf16_p(p) {|buf|
RemoveDirectoryW(buf) != (0 as BOOL) RemoveDirectoryW(buf) != (0 as BOOL)
}; };
} }
#[cfg(unix)] #[cfg(unix)]
fn rmdir(p: path) -> bool { fn rmdir(p: path) -> bool {
ret as_c_charp(p) {|buf| ret do as_c_charp(p) {|buf|
libc::rmdir(buf) == (0 as c_int) libc::rmdir(buf) == (0 as c_int)
}; };
} }
@ -621,14 +620,14 @@ fn change_dir(p: path) -> bool {
import libc::funcs::extra::kernel32::*; import libc::funcs::extra::kernel32::*;
import libc::types::os::arch::extra::*; import libc::types::os::arch::extra::*;
import win32::*; import win32::*;
ret as_utf16_p(p) {|buf| ret do as_utf16_p(p) {|buf|
SetCurrentDirectoryW(buf) != (0 as BOOL) SetCurrentDirectoryW(buf) != (0 as BOOL)
}; };
} }
#[cfg(unix)] #[cfg(unix)]
fn chdir(p: path) -> bool { fn chdir(p: path) -> bool {
ret as_c_charp(p) {|buf| ret do as_c_charp(p) {|buf|
libc::chdir(buf) == (0 as c_int) libc::chdir(buf) == (0 as c_int)
}; };
} }
@ -644,8 +643,8 @@ fn copy_file(from: path, to: path) -> bool {
import libc::funcs::extra::kernel32::*; import libc::funcs::extra::kernel32::*;
import libc::types::os::arch::extra::*; import libc::types::os::arch::extra::*;
import win32::*; import win32::*;
ret as_utf16_p(from) {|fromp| ret do as_utf16_p(from) {|fromp|
as_utf16_p(to) {|top| do as_utf16_p(to) {|top|
CopyFileW(fromp, top, (0 as BOOL)) != (0 as BOOL) CopyFileW(fromp, top, (0 as BOOL)) != (0 as BOOL)
} }
} }
@ -653,16 +652,16 @@ fn copy_file(from: path, to: path) -> bool {
#[cfg(unix)] #[cfg(unix)]
fn do_copy_file(from: path, to: path) -> bool { fn do_copy_file(from: path, to: path) -> bool {
let istream = as_c_charp(from) {|fromp| let istream = do as_c_charp(from) {|fromp|
as_c_charp("rb") {|modebuf| do as_c_charp("rb") {|modebuf|
libc::fopen(fromp, modebuf) libc::fopen(fromp, modebuf)
} }
}; };
if istream as uint == 0u { if istream as uint == 0u {
ret false; ret false;
} }
let ostream = as_c_charp(to) {|top| let ostream = do as_c_charp(to) {|top|
as_c_charp("w+b") {|modebuf| do as_c_charp("w+b") {|modebuf|
libc::fopen(top, modebuf) libc::fopen(top, modebuf)
} }
}; };
@ -676,7 +675,7 @@ fn copy_file(from: path, to: path) -> bool {
let mut done = false; let mut done = false;
let mut ok = true; let mut ok = true;
while !done { while !done {
vec::as_mut_buf(buf) {|b| do vec::as_mut_buf(buf) {|b|
let nread = libc::fread(b as *mut c_void, 1u as size_t, let nread = libc::fread(b as *mut c_void, 1u as size_t,
bufsize as size_t, bufsize as size_t,
istream); istream);
@ -708,14 +707,14 @@ fn remove_file(p: path) -> bool {
import libc::funcs::extra::kernel32::*; import libc::funcs::extra::kernel32::*;
import libc::types::os::arch::extra::*; import libc::types::os::arch::extra::*;
import win32::*; import win32::*;
ret as_utf16_p(p) {|buf| ret do as_utf16_p(p) {|buf|
DeleteFileW(buf) != (0 as BOOL) DeleteFileW(buf) != (0 as BOOL)
}; };
} }
#[cfg(unix)] #[cfg(unix)]
fn unlink(p: path) -> bool { fn unlink(p: path) -> bool {
ret as_c_charp(p) {|buf| ret do as_c_charp(p) {|buf|
libc::unlink(buf) == (0 as c_int) libc::unlink(buf) == (0 as c_int)
}; };
} }
@ -971,15 +970,15 @@ mod tests {
let out = tempdir + path::path_sep() + "out.txt"; let out = tempdir + path::path_sep() + "out.txt";
/* Write the temp input file */ /* Write the temp input file */
let ostream = as_c_charp(in) {|fromp| let ostream = do as_c_charp(in) {|fromp|
as_c_charp("w+b") {|modebuf| do as_c_charp("w+b") {|modebuf|
libc::fopen(fromp, modebuf) libc::fopen(fromp, modebuf)
} }
}; };
assert (ostream as uint != 0u); assert (ostream as uint != 0u);
let s = "hello"; let s = "hello";
let mut buf = vec::to_mut(str::bytes(s) + ~[0 as u8]); let mut buf = vec::to_mut(str::bytes(s) + ~[0 as u8]);
vec::as_mut_buf(buf) {|b| do vec::as_mut_buf(buf) {|b|
assert (libc::fwrite(b as *c_void, 1u as size_t, assert (libc::fwrite(b as *c_void, 1u as size_t,
(str::len(s) + 1u) as size_t, ostream) (str::len(s) + 1u) as size_t, ostream)
== buf.len() as size_t)}; == buf.len() as size_t)};

View file

@ -41,7 +41,7 @@ unsafe fn chan_from_global_ptr<T: send>(
let setup_po = comm::port(); let setup_po = comm::port();
let setup_ch = comm::chan(setup_po); let setup_ch = comm::chan(setup_po);
let setup_ch = task::run_listener(builder()) {|setup_po| let setup_ch = do task::run_listener(builder()) {|setup_po|
let po = comm::port::<T>(); let po = comm::port::<T>();
let ch = comm::chan(po); let ch = comm::chan(po);
comm::send(setup_ch, ch); comm::send(setup_ch, ch);
@ -92,7 +92,7 @@ fn test_from_global_chan1() {
// Create the global channel, attached to a new task // Create the global channel, attached to a new task
let ch = unsafe { let ch = unsafe {
chan_from_global_ptr(globchanp, task::builder) {|po| do chan_from_global_ptr(globchanp, task::builder) {|po|
let ch = comm::recv(po); let ch = comm::recv(po);
comm::send(ch, true); comm::send(ch, true);
let ch = comm::recv(po); let ch = comm::recv(po);
@ -106,7 +106,7 @@ fn test_from_global_chan1() {
// This one just reuses the previous channel // This one just reuses the previous channel
let ch = unsafe { let ch = unsafe {
chan_from_global_ptr(globchanp, task::builder) {|po| do chan_from_global_ptr(globchanp, task::builder) {|po|
let ch = comm::recv(po); let ch = comm::recv(po);
comm::send(ch, false); comm::send(ch, false);
} }
@ -121,7 +121,7 @@ fn test_from_global_chan1() {
#[test] #[test]
fn test_from_global_chan2() { fn test_from_global_chan2() {
iter::repeat(100u) {|| do iter::repeat(100u) {||
// The global channel // The global channel
let globchan = 0u; let globchan = 0u;
let globchanp = ptr::addr_of(globchan); let globchanp = ptr::addr_of(globchan);
@ -132,9 +132,9 @@ fn test_from_global_chan2() {
// Spawn a bunch of tasks that all want to compete to // Spawn a bunch of tasks that all want to compete to
// create the global channel // create the global channel
for uint::range(0u, 10u) {|i| for uint::range(0u, 10u) {|i|
task::spawn() {|| do task::spawn {||
let ch = unsafe { let ch = unsafe {
chan_from_global_ptr( do chan_from_global_ptr(
globchanp, task::builder) {|po| globchanp, task::builder) {|po|
for uint::range(0u, 10u) {|_j| for uint::range(0u, 10u) {|_j|
@ -200,9 +200,9 @@ unsafe fn weaken_task(f: fn(comm::port<()>)) {
#[test] #[test]
fn test_weaken_task_then_unweaken() { fn test_weaken_task_then_unweaken() {
task::try {|| do task::try {||
unsafe { unsafe {
weaken_task {|_po| do weaken_task {|_po|
} }
} }
}; };
@ -212,9 +212,9 @@ fn test_weaken_task_then_unweaken() {
fn test_weaken_task_wait() { fn test_weaken_task_wait() {
let builder = task::builder(); let builder = task::builder();
task::unsupervise(builder); task::unsupervise(builder);
task::run(builder) {|| do task::run(builder) {||
unsafe { unsafe {
weaken_task {|po| do weaken_task {|po|
comm::recv(po); comm::recv(po);
} }
} }
@ -224,18 +224,18 @@ fn test_weaken_task_wait() {
#[test] #[test]
fn test_weaken_task_stress() { fn test_weaken_task_stress() {
// Create a bunch of weak tasks // Create a bunch of weak tasks
iter::repeat(100u) {|| do iter::repeat(100u) {||
task::spawn {|| do task::spawn {||
unsafe { unsafe {
weaken_task {|_po| do weaken_task {|_po|
} }
} }
} }
let builder = task::builder(); let builder = task::builder();
task::unsupervise(builder); task::unsupervise(builder);
task::run(builder) {|| do task::run(builder) {||
unsafe { unsafe {
weaken_task {|po| do weaken_task {|po|
// Wait for it to tell us to die // Wait for it to tell us to die
comm::recv(po); comm::recv(po);
} }
@ -247,9 +247,9 @@ fn test_weaken_task_stress() {
#[test] #[test]
#[ignore(cfg(windows))] #[ignore(cfg(windows))]
fn test_weaken_task_fail() { fn test_weaken_task_fail() {
let res = task::try {|| let res = do task::try {||
unsafe { unsafe {
weaken_task {|_po| do weaken_task {|_po|
fail; fail;
} }
} }

View file

@ -70,7 +70,7 @@ fn mut_offset<T>(ptr: *mut T, count: uint) -> *mut T {
#[doc = "Return the offset of the first null pointer in `buf`."] #[doc = "Return the offset of the first null pointer in `buf`."]
#[inline(always)] #[inline(always)]
unsafe fn buf_len<T>(buf: **T) -> uint { unsafe fn buf_len<T>(buf: **T) -> uint {
position(buf) {|i| i == null() } do position(buf) {|i| i == null() }
} }
#[doc = "Return the first offset `i` such that `f(buf[i]) == true`."] #[doc = "Return the first offset `i` such that `f(buf[i]) == true`."]
@ -171,9 +171,9 @@ fn test_position() {
let s = "hello"; let s = "hello";
unsafe { unsafe {
assert 2u == as_c_str(s) {|p| position(p) {|c| c == 'l' as c_char} }; assert 2u == as_c_str(s, {|p| position(p, {|c| c == 'l' as c_char})});
assert 4u == as_c_str(s) {|p| position(p) {|c| c == 'o' as c_char} }; assert 4u == as_c_str(s, {|p| position(p, {|c| c == 'o' as c_char})});
assert 5u == as_c_str(s) {|p| position(p) {|c| c == 0 as c_char } }; assert 5u == as_c_str(s, {|p| position(p, {|c| c == 0 as c_char })});
} }
} }
@ -182,11 +182,11 @@ fn test_buf_len() {
let s0 = "hello"; let s0 = "hello";
let s1 = "there"; let s1 = "there";
let s2 = "thing"; let s2 = "thing";
str::as_c_str(s0) {|p0| do str::as_c_str(s0) {|p0|
str::as_c_str(s1) {|p1| do str::as_c_str(s1) {|p1|
str::as_c_str(s2) {|p2| do str::as_c_str(s2) {|p2|
let v = ~[p0, p1, p2, null()]; let v = ~[p0, p1, p2, null()];
vec::as_buf(v) {|vp| do vec::as_buf(v) {|vp|
assert unsafe { buf_len(vp) } == 3u; assert unsafe { buf_len(vp) } == 3u;
} }
} }

View file

@ -152,7 +152,7 @@ impl extensions for rng {
#[doc = "Return a random byte string of the specified length"] #[doc = "Return a random byte string of the specified length"]
fn gen_bytes(len: uint) -> ~[u8] { fn gen_bytes(len: uint) -> ~[u8] {
vec::from_fn(len) {|_i| do vec::from_fn(len) {|_i|
self.gen_u8() self.gen_u8()
} }
} }

View file

@ -362,33 +362,33 @@ mod tests {
#[test] #[test]
fn test_impl_iter() { fn test_impl_iter() {
let mut valid = false; let mut valid = false;
ok::<str, str>("a").iter { |_x| valid = true; }; ok::<str, str>("a").iter({ |_x| valid = true; });
assert valid; assert valid;
err::<str, str>("b").iter { |_x| valid = false; }; err::<str, str>("b").iter({ |_x| valid = false; });
assert valid; assert valid;
} }
#[test] #[test]
fn test_impl_iter_err() { fn test_impl_iter_err() {
let mut valid = true; let mut valid = true;
ok::<str, str>("a").iter_err { |_x| valid = false; }; ok::<str, str>("a").iter_err({ |_x| valid = false; });
assert valid; assert valid;
valid = false; valid = false;
err::<str, str>("b").iter_err { |_x| valid = true; }; err::<str, str>("b").iter_err({ |_x| valid = true; });
assert valid; assert valid;
} }
#[test] #[test]
fn test_impl_map() { fn test_impl_map() {
assert ok::<str, str>("a").map { |_x| "b" } == ok("b"); assert ok::<str, str>("a").map({ |_x| "b" }) == ok("b");
assert err::<str, str>("a").map { |_x| "b" } == err("a"); assert err::<str, str>("a").map({ |_x| "b" }) == err("a");
} }
#[test] #[test]
fn test_impl_map_err() { fn test_impl_map_err() {
assert ok::<str, str>("a").map_err { |_x| "b" } == ok("a"); assert ok::<str, str>("a").map_err({ |_x| "b" }) == ok("a");
assert err::<str, str>("a").map_err { |_x| "b" } == err("b"); assert err::<str, str>("a").map_err({ |_x| "b" }) == err("b");
} }
} }

View file

@ -67,9 +67,9 @@ fn spawn_process(prog: str, args: ~[str],
dir: option<str>, dir: option<str>,
in_fd: c_int, out_fd: c_int, err_fd: c_int) in_fd: c_int, out_fd: c_int, err_fd: c_int)
-> pid_t { -> pid_t {
with_argv(prog, args) {|argv| do with_argv(prog, args) {|argv|
with_envp(env) { |envp| do with_envp(env) { |envp|
with_dirp(dir) { |dirp| do with_dirp(dir) { |dirp|
rustrt::rust_run_program(argv, envp, dirp, rustrt::rust_run_program(argv, envp, dirp,
in_fd, out_fd, err_fd) in_fd, out_fd, err_fd)
} }
@ -79,12 +79,12 @@ fn spawn_process(prog: str, args: ~[str],
fn with_argv<T>(prog: str, args: ~[str], fn with_argv<T>(prog: str, args: ~[str],
cb: fn(**libc::c_char) -> T) -> T { cb: fn(**libc::c_char) -> T) -> T {
let mut argptrs = str::as_c_str(prog) {|b| ~[b] }; let mut argptrs = str::as_c_str(prog, {|b| ~[b] });
let mut tmps = ~[]; let mut tmps = ~[];
for vec::each(args) {|arg| for vec::each(args) {|arg|
let t = @arg; let t = @arg;
vec::push(tmps, t); vec::push(tmps, t);
vec::push_all(argptrs, str::as_c_str(*t) {|b| ~[b] }); vec::push_all(argptrs, str::as_c_str(*t, {|b| ~[b] }));
} }
vec::push(argptrs, ptr::null()); vec::push(argptrs, ptr::null());
vec::as_buf(argptrs, cb) vec::as_buf(argptrs, cb)
@ -104,12 +104,12 @@ fn with_envp<T>(env: option<~[(str,str)]>,
let (k,v) = e; let (k,v) = e;
let t = @(#fmt("%s=%s", k, v)); let t = @(#fmt("%s=%s", k, v));
vec::push(tmps, t); vec::push(tmps, t);
vec::push_all(ptrs, str::as_c_str(*t) {|b| ~[b]}); vec::push_all(ptrs, str::as_c_str(*t, {|b| ~[b]}));
} }
vec::push(ptrs, ptr::null()); vec::push(ptrs, ptr::null());
vec::as_buf(ptrs) { |p| vec::as_buf(ptrs, { |p|
unsafe { cb(::unsafe::reinterpret_cast(p)) } unsafe { cb(::unsafe::reinterpret_cast(p)) }
} })
} }
_ { _ {
cb(ptr::null()) cb(ptr::null())
@ -135,7 +135,7 @@ fn with_envp<T>(env: option<~[(str,str)]>,
::unsafe::forget(v); ::unsafe::forget(v);
} }
blk += ~[0_u8]; blk += ~[0_u8];
vec::as_buf(blk) {|p| cb(::unsafe::reinterpret_cast(p)) } vec::as_buf(blk, {|p| cb(::unsafe::reinterpret_cast(p)) })
} }
_ { _ {
cb(ptr::null()) cb(ptr::null())
@ -298,11 +298,11 @@ fn program_output(prog: str, args: ~[str]) ->
// clever way to do this. // clever way to do this.
let p = comm::port(); let p = comm::port();
let ch = comm::chan(p); let ch = comm::chan(p);
task::spawn_sched(task::single_threaded) {|| do task::spawn_sched(task::single_threaded) {||
let errput = readclose(pipe_err.in); let errput = readclose(pipe_err.in);
comm::send(ch, (2, errput)); comm::send(ch, (2, errput));
}; };
task::spawn_sched(task::single_threaded) {|| do task::spawn_sched(task::single_threaded) {||
let output = readclose(pipe_out.in); let output = readclose(pipe_out.in);
comm::send(ch, (1, output)); comm::send(ch, (1, output));
}; };

View file

@ -18,7 +18,7 @@ fn walk_stack(visit: fn(frame) -> bool) {
#debug("beginning stack walk"); #debug("beginning stack walk");
frame_address { |frame_pointer| do frame_address { |frame_pointer|
let mut frame_address: *word = unsafe { let mut frame_address: *word = unsafe {
reinterpret_cast(frame_pointer) reinterpret_cast(frame_pointer)
}; };

View file

@ -154,7 +154,7 @@ fn push_char(&s: str, ch: char) {
let new_len = len + nb; let new_len = len + nb;
reserve_at_least(s, new_len); reserve_at_least(s, new_len);
let off = len; let off = len;
as_buf(s) {|buf| do as_buf(s) {|buf|
let buf: *mut u8 = ::unsafe::reinterpret_cast(buf); let buf: *mut u8 = ::unsafe::reinterpret_cast(buf);
if nb == 1u { if nb == 1u {
*ptr::mut_offset(buf, off) = *ptr::mut_offset(buf, off) =
@ -208,7 +208,7 @@ fn push_char(&s: str, ch: char) {
*ptr::mut_offset(buf, off + nb) = 0u8; *ptr::mut_offset(buf, off + nb) = 0u8;
} }
as_bytes(s) {|bytes| do as_bytes(s) {|bytes|
let mut mut_bytes: ~[u8] = ::unsafe::reinterpret_cast(bytes); let mut mut_bytes: ~[u8] = ::unsafe::reinterpret_cast(bytes);
vec::unsafe::set_len(mut_bytes, new_len + 1u); vec::unsafe::set_len(mut_bytes, new_len + 1u);
::unsafe::forget(mut_bytes); ::unsafe::forget(mut_bytes);
@ -336,7 +336,7 @@ Work with the string as a byte slice, not including trailing null.
"] "]
#[inline(always)] #[inline(always)]
pure fn byte_slice<T>(s: str/&, f: fn(v: &[u8]) -> T) -> T { pure fn byte_slice<T>(s: str/&, f: fn(v: &[u8]) -> T) -> T {
unpack_slice(s) {|p,n| do unpack_slice(s) {|p,n|
unsafe { vec::unsafe::form_slice(p, n-1u, f) } unsafe { vec::unsafe::form_slice(p, n-1u, f) }
} }
} }
@ -495,7 +495,7 @@ pure fn iter_matches(s: str/&a, sep: str/&b, f: fn(uint, uint)) {
pure fn iter_between_matches(s: str/&a, sep: str/&b, f: fn(uint, uint)) { pure fn iter_between_matches(s: str/&a, sep: str/&b, f: fn(uint, uint)) {
let mut last_end = 0u; let mut last_end = 0u;
iter_matches(s, sep) {|from, to| do iter_matches(s, sep) {|from, to|
f(last_end, from); f(last_end, from);
last_end = to; last_end = to;
} }
@ -513,7 +513,7 @@ assert [\"\", \"XXX\", \"YYY\", \"\"] == split_str(\".XXX.YYY.\", \".\")
"] "]
pure fn split_str(s: str/&a, sep: str/&b) -> ~[str] { pure fn split_str(s: str/&a, sep: str/&b) -> ~[str] {
let mut result = ~[]; let mut result = ~[];
iter_between_matches(s, sep) {|from, to| do iter_between_matches(s, sep) {|from, to|
unsafe { vec::push(result, unsafe::slice_bytes(s, from, to)); } unsafe { vec::push(result, unsafe::slice_bytes(s, from, to)); }
} }
result result
@ -521,7 +521,7 @@ pure fn split_str(s: str/&a, sep: str/&b) -> ~[str] {
pure fn split_str_nonempty(s: str/&a, sep: str/&b) -> ~[str] { pure fn split_str_nonempty(s: str/&a, sep: str/&b) -> ~[str] {
let mut result = ~[]; let mut result = ~[];
iter_between_matches(s, sep) {|from, to| do iter_between_matches(s, sep) {|from, to|
if to > from { if to > from {
unsafe { vec::push(result, unsafe::slice_bytes(s, from, to)); } unsafe { vec::push(result, unsafe::slice_bytes(s, from, to)); }
} }
@ -585,7 +585,7 @@ The original string with all occurances of `from` replaced with `to`
"] "]
pure fn replace(s: str, from: str, to: str) -> str { pure fn replace(s: str, from: str, to: str) -> str {
let mut result = "", first = true; let mut result = "", first = true;
iter_between_matches(s, from) {|start, end| do iter_between_matches(s, from) {|start, end|
if first { first = false; } else { result += to; } if first { first = false; } else { result += to; }
unsafe { result += unsafe::slice_bytes(s, start, end); } unsafe { result += unsafe::slice_bytes(s, start, end); }
} }
@ -651,7 +651,7 @@ pure fn map(ss: str/&, ff: fn(char) -> char) -> str {
let mut result = ""; let mut result = "";
unchecked { unchecked {
reserve(result, len(ss)); reserve(result, len(ss));
chars_iter(ss) {|cc| do chars_iter(ss) {|cc|
str::push_char(result, ff(cc)); str::push_char(result, ff(cc));
} }
} }
@ -1215,7 +1215,7 @@ fn is_alphanumeric(s: str/&) -> bool {
Returns the string length/size in bytes not counting the null terminator Returns the string length/size in bytes not counting the null terminator
"] "]
pure fn len(s: str/&) -> uint { pure fn len(s: str/&) -> uint {
unpack_slice(s) { |_p, n| n - 1u } do unpack_slice(s) { |_p, n| n - 1u }
} }
#[doc = "Returns the number of characters that a string holds"] #[doc = "Returns the number of characters that a string holds"]
@ -1267,7 +1267,7 @@ pure fn is_utf16(v: &[const u16]) -> bool {
#[doc = "Converts to a vector of `u16` encoded as UTF-16"] #[doc = "Converts to a vector of `u16` encoded as UTF-16"]
pure fn to_utf16(s: str/&) -> ~[u16] { pure fn to_utf16(s: str/&) -> ~[u16] {
let mut u = ~[]; let mut u = ~[];
chars_iter(s) {|cch| do chars_iter(s) {|cch|
// Arithmetic with u32 literals is easier on the eyes than chars. // Arithmetic with u32 literals is easier on the eyes than chars.
let mut ch = cch as u32; let mut ch = cch as u32;
@ -1316,7 +1316,7 @@ pure fn from_utf16(v: &[const u16]) -> str {
let mut buf = ""; let mut buf = "";
unchecked { unchecked {
reserve(buf, vec::len(v)); reserve(buf, vec::len(v));
utf16_chars(v) {|ch| push_char(buf, ch); } do utf16_chars(v) {|ch| push_char(buf, ch); }
} }
ret buf; ret buf;
} }
@ -1583,7 +1583,7 @@ Allows for unsafe manipulation of strings, which is useful for native
interop. interop.
"] "]
pure fn as_buf<T>(s: str, f: fn(*u8) -> T) -> T { pure fn as_buf<T>(s: str, f: fn(*u8) -> T) -> T {
as_bytes(s) { |v| unsafe { vec::as_buf(v, f) } } as_bytes(s, { |v| unsafe { vec::as_buf(v, f) } })
} }
#[doc = " #[doc = "
@ -1599,7 +1599,7 @@ let s = str::as_buf(\"PATH\", { |path_buf| libc::getenv(path_buf) });
~~~ ~~~
"] "]
pure fn as_c_str<T>(s: str, f: fn(*libc::c_char) -> T) -> T { pure fn as_c_str<T>(s: str, f: fn(*libc::c_char) -> T) -> T {
as_buf(s) {|buf| f(buf as *libc::c_char) } as_buf(s, {|buf| f(buf as *libc::c_char) })
} }
@ -1671,7 +1671,7 @@ Returns the number of single-byte characters the string can hold without
reallocating reallocating
"] "]
pure fn capacity(&&s: str) -> uint { pure fn capacity(&&s: str) -> uint {
as_bytes(s) {|buf| do as_bytes(s) {|buf|
let vcap = vec::capacity(buf); let vcap = vec::capacity(buf);
assert vcap > 0u; assert vcap > 0u;
vcap - 1u vcap - 1u
@ -1683,7 +1683,7 @@ pure fn escape_default(s: str/&) -> str {
let mut out: str = ""; let mut out: str = "";
unchecked { unchecked {
reserve_at_least(out, str::len(s)); reserve_at_least(out, str::len(s));
chars_iter(s) {|c| out += char::escape_default(c); } do chars_iter(s) {|c| out += char::escape_default(c); }
} }
ret out; ret out;
} }
@ -1693,7 +1693,7 @@ pure fn escape_unicode(s: str/&) -> str {
let mut out: str = ""; let mut out: str = "";
unchecked { unchecked {
reserve_at_least(out, str::len(s)); reserve_at_least(out, str::len(s));
chars_iter(s) {|c| out += char::escape_unicode(c); } do chars_iter(s) {|c| out += char::escape_unicode(c); }
} }
ret out; ret out;
} }
@ -1726,7 +1726,7 @@ mod unsafe {
unsafe fn from_buf_len(buf: *u8, len: uint) -> str { unsafe fn from_buf_len(buf: *u8, len: uint) -> str {
let mut v: ~[u8] = ~[]; let mut v: ~[u8] = ~[];
vec::reserve(v, len + 1u); vec::reserve(v, len + 1u);
vec::as_buf(v) {|b| ptr::memcpy(b, buf, len); } do vec::as_buf(v) {|b| ptr::memcpy(b, buf, len); }
vec::unsafe::set_len(v, len); vec::unsafe::set_len(v, len);
vec::push(v, 0u8); vec::push(v, 0u8);
@ -1777,14 +1777,14 @@ mod unsafe {
If end is greater than the length of the string. If end is greater than the length of the string.
"] "]
unsafe fn slice_bytes(s: str/&, begin: uint, end: uint) -> str { unsafe fn slice_bytes(s: str/&, begin: uint, end: uint) -> str {
unpack_slice(s) { |sbuf, n| do unpack_slice(s) { |sbuf, n|
assert (begin <= end); assert (begin <= end);
assert (end <= n); assert (end <= n);
let mut v = ~[]; let mut v = ~[];
vec::reserve(v, end - begin + 1u); vec::reserve(v, end - begin + 1u);
unsafe { unsafe {
vec::as_buf(v) { |vbuf| do vec::as_buf(v) { |vbuf|
let src = ptr::offset(sbuf, begin); let src = ptr::offset(sbuf, begin);
ptr::memcpy(vbuf, src, end - begin); ptr::memcpy(vbuf, src, end - begin);
} }
@ -2574,7 +2574,7 @@ mod tests {
#[should_fail] #[should_fail]
fn test_as_bytes_fail() { fn test_as_bytes_fail() {
// Don't double free // Don't double free
as_bytes("") {|_bytes| fail } do as_bytes("") {|_bytes| fail }
} }
#[test] #[test]
@ -2647,7 +2647,7 @@ mod tests {
#[test] #[test]
fn test_chars_iter() { fn test_chars_iter() {
let mut i = 0; let mut i = 0;
chars_iter("x\u03c0y") {|ch| do chars_iter("x\u03c0y") {|ch|
alt check i { alt check i {
0 { assert ch == 'x'; } 0 { assert ch == 'x'; }
1 { assert ch == '\u03c0'; } 1 { assert ch == '\u03c0'; }
@ -2656,14 +2656,14 @@ mod tests {
i += 1; i += 1;
} }
chars_iter("") {|_ch| fail; } // should not fail do chars_iter("") {|_ch| fail; } // should not fail
} }
#[test] #[test]
fn test_bytes_iter() { fn test_bytes_iter() {
let mut i = 0; let mut i = 0;
bytes_iter("xyz") {|bb| do bytes_iter("xyz") {|bb|
alt check i { alt check i {
0 { assert bb == 'x' as u8; } 0 { assert bb == 'x' as u8; }
1 { assert bb == 'y' as u8; } 1 { assert bb == 'y' as u8; }
@ -2672,7 +2672,7 @@ mod tests {
i += 1; i += 1;
} }
bytes_iter("") {|bb| assert bb == 0u8; } do bytes_iter("") {|bb| assert bb == 0u8; }
} }
#[test] #[test]
@ -2681,7 +2681,7 @@ mod tests {
let mut ii = 0; let mut ii = 0;
split_char_iter(data, ' ') {|xx| do split_char_iter(data, ' ') {|xx|
alt ii { alt ii {
0 { assert "\nMary" == xx; } 0 { assert "\nMary" == xx; }
1 { assert "had" == xx; } 1 { assert "had" == xx; }
@ -2699,7 +2699,7 @@ mod tests {
let mut ii = 0; let mut ii = 0;
splitn_char_iter(data, ' ', 2u) {|xx| do splitn_char_iter(data, ' ', 2u) {|xx|
alt ii { alt ii {
0 { assert "\nMary" == xx; } 0 { assert "\nMary" == xx; }
1 { assert "had" == xx; } 1 { assert "had" == xx; }
@ -2716,7 +2716,7 @@ mod tests {
let mut ii = 0; let mut ii = 0;
words_iter(data) {|ww| do words_iter(data) {|ww|
alt ii { alt ii {
0 { assert "Mary" == ww; } 0 { assert "Mary" == ww; }
1 { assert "had" == ww; } 1 { assert "had" == ww; }
@ -2727,7 +2727,7 @@ mod tests {
ii += 1; ii += 1;
} }
words_iter("") {|_x| fail; } // should not fail do words_iter("") {|_x| fail; } // should not fail
} }
#[test] #[test]
@ -2736,7 +2736,7 @@ mod tests {
let mut ii = 0; let mut ii = 0;
lines_iter(lf) {|x| do lines_iter(lf) {|x|
alt ii { alt ii {
0 { assert "" == x; } 0 { assert "" == x; }
1 { assert "Mary had a little lamb" == x; } 1 { assert "Mary had a little lamb" == x; }
@ -2844,7 +2844,7 @@ mod tests {
#[test] #[test]
fn test_unpack_slice() { fn test_unpack_slice() {
let a = "hello"; let a = "hello";
unpack_slice(a) {|buf, len| do unpack_slice(a) {|buf, len|
unsafe { unsafe {
assert a[0] == 'h' as u8; assert a[0] == 'h' as u8;
assert *buf == 'h' as u8; assert *buf == 'h' as u8;

View file

@ -183,16 +183,16 @@ mod tests {
let lock = arc::arc(create_lock()); let lock = arc::arc(create_lock());
let lock2 = arc::clone(&lock); let lock2 = arc::clone(&lock);
task::spawn {|move lock2| do task::spawn {|move lock2|
let lock = arc::get(&lock2); let lock = arc::get(&lock2);
(*lock).lock_cond {|c| do (*lock).lock_cond {|c|
c.wait(); c.wait();
} }
} }
let mut signaled = false; let mut signaled = false;
while !signaled { while !signaled {
(*arc::get(&lock)).lock_cond {|c| do (*arc::get(&lock)).lock_cond {|c|
signaled = c.signal() signaled = c.signal()
} }
} }

View file

@ -295,7 +295,7 @@ fn future_result(builder: builder) -> future::future<task_result> {
with get_opts(builder) with get_opts(builder)
}); });
future::from_fn {|| do future::from_fn {||
alt comm::recv(po) { alt comm::recv(po) {
exit(_, result) { result } exit(_, result) { result }
} }
@ -307,7 +307,7 @@ fn future_task(builder: builder) -> future::future<task> {
let mut po = comm::port(); let mut po = comm::port();
let ch = comm::chan(po); let ch = comm::chan(po);
add_wrapper(builder) {|body| do add_wrapper(builder) {|body|
fn~() { fn~() {
comm::send(ch, get_task()); comm::send(ch, get_task());
body(); body();
@ -342,7 +342,7 @@ fn run_listener<A:send>(-builder: builder,
let setup_po = comm::port(); let setup_po = comm::port();
let setup_ch = comm::chan(setup_po); let setup_ch = comm::chan(setup_po);
run(builder) {|| do run(builder) {||
let po = comm::port(); let po = comm::port();
let mut ch = comm::chan(po); let mut ch = comm::chan(po);
comm::send(setup_ch, ch); comm::send(setup_ch, ch);
@ -439,7 +439,7 @@ fn try<T:send>(+f: fn~() -> T) -> result<T,()> {
let mut builder = builder(); let mut builder = builder();
unsupervise(builder); unsupervise(builder);
let result = future_result(builder); let result = future_result(builder);
run(builder) {|| do run(builder) {||
comm::send(ch, f()); comm::send(ch, f());
} }
alt future::get(result) { alt future::get(result) {
@ -540,7 +540,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) {
}; };
assert !new_task.is_null(); assert !new_task.is_null();
option::iter(opts.notify_chan) {|c| do option::iter(opts.notify_chan) {|c|
// FIXME (#1087): Would like to do notification in Rust // FIXME (#1087): Would like to do notification in Rust
rustrt::rust_task_config_notify(new_task, c); rustrt::rust_task_config_notify(new_task, c);
} }
@ -657,10 +657,10 @@ unsafe fn key_to_key_value<T>(key: local_data_key<T>) -> *libc::c_void {
unsafe fn local_data_lookup<T>(map: task_local_map, key: local_data_key<T>) unsafe fn local_data_lookup<T>(map: task_local_map, key: local_data_key<T>)
-> option<(uint, *libc::c_void, fn@(+*libc::c_void))> { -> option<(uint, *libc::c_void, fn@(+*libc::c_void))> {
let key_value = key_to_key_value(key); let key_value = key_to_key_value(key);
let map_pos = (*map).position {|entry| let map_pos = (*map).position({|entry|
alt entry { some((k,_,_)) { k == key_value } none { false } } alt entry { some((k,_,_)) { k == key_value } none { false } }
}; });
map_pos.map {|index| do map_pos.map {|index|
// .get() is guaranteed because of "none { false }" above. // .get() is guaranteed because of "none { false }" above.
let (_, data_ptr, finaliser) = (*map)[index].get(); let (_, data_ptr, finaliser) = (*map)[index].get();
(index, data_ptr, finaliser) (index, data_ptr, finaliser)
@ -671,7 +671,7 @@ unsafe fn local_get_helper<T>(task: *rust_task, key: local_data_key<T>,
do_pop: bool) -> option<@T> { do_pop: bool) -> option<@T> {
let map = get_task_local_map(task); let map = get_task_local_map(task);
// Interpret our findings from the map // Interpret our findings from the map
local_data_lookup(map, key).map {|result| do local_data_lookup(map, key).map {|result|
// A reference count magically appears on 'data' out of thin air. // A reference count magically appears on 'data' out of thin air.
// 'data' has the reference we originally stored it with. We either // 'data' has the reference we originally stored it with. We either
// need to erase it from the map or artificially bump the count. // need to erase it from the map or artificially bump the count.
@ -799,7 +799,7 @@ native mod rustrt {
fn test_spawn_raw_simple() { fn test_spawn_raw_simple() {
let po = comm::port(); let po = comm::port();
let ch = comm::chan(po); let ch = comm::chan(po);
spawn_raw(default_task_opts()) {|| do spawn_raw(default_task_opts()) {||
comm::send(ch, ()); comm::send(ch, ());
} }
comm::recv(po); comm::recv(po);
@ -812,7 +812,7 @@ fn test_spawn_raw_unsupervise() {
supervise: false supervise: false
with default_task_opts() with default_task_opts()
}; };
spawn_raw(opts) {|| do spawn_raw(opts) {||
fail; fail;
} }
} }
@ -829,7 +829,7 @@ fn test_spawn_raw_notify() {
notify_chan: some(notify_ch) notify_chan: some(notify_ch)
with default_task_opts() with default_task_opts()
}; };
spawn_raw(opts) {|| do spawn_raw(opts) {||
comm::send(task_ch, get_task()); comm::send(task_ch, get_task());
} }
let task_ = comm::recv(task_po); let task_ = comm::recv(task_po);
@ -840,7 +840,7 @@ fn test_spawn_raw_notify() {
notify_chan: some(notify_ch) notify_chan: some(notify_ch)
with default_task_opts() with default_task_opts()
}; };
spawn_raw(opts) {|| do spawn_raw(opts) {||
comm::send(task_ch, get_task()); comm::send(task_ch, get_task());
fail; fail;
} }
@ -853,7 +853,7 @@ fn test_run_basic() {
let po = comm::port(); let po = comm::port();
let ch = comm::chan(po); let ch = comm::chan(po);
let buildr = builder(); let buildr = builder();
run(buildr) {|| do run(buildr) {||
comm::send(ch, ()); comm::send(ch, ());
} }
comm::recv(po); comm::recv(po);
@ -864,13 +864,13 @@ fn test_add_wrapper() {
let po = comm::port(); let po = comm::port();
let ch = comm::chan(po); let ch = comm::chan(po);
let buildr = builder(); let buildr = builder();
add_wrapper(buildr) {|body| do add_wrapper(buildr) {|body|
fn~() { fn~() {
body(); body();
comm::send(ch, ()); comm::send(ch, ());
} }
} }
run(buildr) {||} do run(buildr) {||}
comm::recv(po); comm::recv(po);
} }
@ -879,13 +879,13 @@ fn test_add_wrapper() {
fn test_future_result() { fn test_future_result() {
let buildr = builder(); let buildr = builder();
let result = future_result(buildr); let result = future_result(buildr);
run(buildr) {||} do run(buildr) {||}
assert future::get(result) == success; assert future::get(result) == success;
let buildr = builder(); let buildr = builder();
let result = future_result(buildr); let result = future_result(buildr);
unsupervise(buildr); unsupervise(buildr);
run(buildr) {|| fail } do run(buildr) {|| fail }
assert future::get(result) == failure; assert future::get(result) == failure;
} }
@ -895,7 +895,7 @@ fn test_future_task() {
let ch = comm::chan(po); let ch = comm::chan(po);
let buildr = builder(); let buildr = builder();
let task1 = future_task(buildr); let task1 = future_task(buildr);
run(buildr) {|| comm::send(ch, get_task()) } do run(buildr) {|| comm::send(ch, get_task()) }
assert future::get(task1) == comm::recv(po); assert future::get(task1) == comm::recv(po);
} }
@ -903,7 +903,7 @@ fn test_future_task() {
fn test_spawn_listiner_bidi() { fn test_spawn_listiner_bidi() {
let po = comm::port(); let po = comm::port();
let ch = comm::chan(po); let ch = comm::chan(po);
let ch = spawn_listener {|po| let ch = do spawn_listener {|po|
// Now the child has a port called 'po' to read from and // Now the child has a port called 'po' to read from and
// an environment-captured channel called 'ch'. // an environment-captured channel called 'ch'.
let res = comm::recv(po); let res = comm::recv(po);
@ -918,7 +918,7 @@ fn test_spawn_listiner_bidi() {
#[test] #[test]
fn test_try_success() { fn test_try_success() {
alt try {|| alt do try {||
"Success!" "Success!"
} { } {
result::ok("Success!") { } result::ok("Success!") { }
@ -929,7 +929,7 @@ fn test_try_success() {
#[test] #[test]
#[ignore(cfg(windows))] #[ignore(cfg(windows))]
fn test_try_fail() { fn test_try_fail() {
alt try {|| alt do try {||
fail fail
} { } {
result::err(()) { } result::err(()) { }
@ -941,7 +941,7 @@ fn test_try_fail() {
#[should_fail] #[should_fail]
#[ignore(cfg(windows))] #[ignore(cfg(windows))]
fn test_spawn_sched_no_threads() { fn test_spawn_sched_no_threads() {
spawn_sched(manual_threads(0u)) {|| }; do spawn_sched(manual_threads(0u)) {|| };
} }
#[test] #[test]
@ -952,7 +952,7 @@ fn test_spawn_sched() {
fn f(i: int, ch: comm::chan<()>) { fn f(i: int, ch: comm::chan<()>) {
let parent_sched_id = rustrt::rust_get_sched_id(); let parent_sched_id = rustrt::rust_get_sched_id();
spawn_sched(single_threaded) {|| do spawn_sched(single_threaded) {||
let child_sched_id = rustrt::rust_get_sched_id(); let child_sched_id = rustrt::rust_get_sched_id();
assert parent_sched_id != child_sched_id; assert parent_sched_id != child_sched_id;
@ -973,9 +973,9 @@ fn test_spawn_sched_childs_on_same_sched() {
let po = comm::port(); let po = comm::port();
let ch = comm::chan(po); let ch = comm::chan(po);
spawn_sched(single_threaded) {|| do spawn_sched(single_threaded) {||
let parent_sched_id = rustrt::rust_get_sched_id(); let parent_sched_id = rustrt::rust_get_sched_id();
spawn {|| do spawn {||
let child_sched_id = rustrt::rust_get_sched_id(); let child_sched_id = rustrt::rust_get_sched_id();
// This should be on the same scheduler // This should be on the same scheduler
assert parent_sched_id == child_sched_id; assert parent_sched_id == child_sched_id;
@ -1002,7 +1002,7 @@ fn test_spawn_sched_blocking() {
// Testing that a task in one scheduler can block in foreign code // Testing that a task in one scheduler can block in foreign code
// without affecting other schedulers // without affecting other schedulers
iter::repeat(20u) {|| do iter::repeat(20u) {||
let start_po = comm::port(); let start_po = comm::port();
let start_ch = comm::chan(start_po); let start_ch = comm::chan(start_po);
@ -1011,7 +1011,7 @@ fn test_spawn_sched_blocking() {
let lock = testrt::rust_dbg_lock_create(); let lock = testrt::rust_dbg_lock_create();
spawn_sched(single_threaded) {|| do spawn_sched(single_threaded) {||
testrt::rust_dbg_lock_lock(lock); testrt::rust_dbg_lock_lock(lock);
comm::send(start_ch, ()); comm::send(start_ch, ());
@ -1038,7 +1038,7 @@ fn test_spawn_sched_blocking() {
let setup_ch = comm::chan(setup_po); let setup_ch = comm::chan(setup_po);
let parent_po = comm::port(); let parent_po = comm::port();
let parent_ch = comm::chan(parent_po); let parent_ch = comm::chan(parent_po);
spawn {|| do spawn {||
let child_po = comm::port(); let child_po = comm::port();
comm::send(setup_ch, comm::chan(child_po)); comm::send(setup_ch, comm::chan(child_po));
pingpong(child_po, parent_ch); pingpong(child_po, parent_ch);
@ -1063,7 +1063,7 @@ fn avoid_copying_the_body(spawnfn: fn(+fn~())) {
let x = ~1; let x = ~1;
let x_in_parent = ptr::addr_of(*x) as uint; let x_in_parent = ptr::addr_of(*x) as uint;
spawnfn {|| do spawnfn {||
let x_in_child = ptr::addr_of(*x) as uint; let x_in_child = ptr::addr_of(*x) as uint;
comm::send(ch, x_in_child); comm::send(ch, x_in_child);
} }
@ -1079,7 +1079,7 @@ fn test_avoid_copying_the_body_spawn() {
#[test] #[test]
fn test_avoid_copying_the_body_spawn_listener() { fn test_avoid_copying_the_body_spawn_listener() {
avoid_copying_the_body {|f| do avoid_copying_the_body {|f|
spawn_listener(fn~(move f, _po: comm::port<int>) { spawn_listener(fn~(move f, _po: comm::port<int>) {
f(); f();
}); });
@ -1088,9 +1088,9 @@ fn test_avoid_copying_the_body_spawn_listener() {
#[test] #[test]
fn test_avoid_copying_the_body_run() { fn test_avoid_copying_the_body_run() {
avoid_copying_the_body {|f| do avoid_copying_the_body {|f|
let buildr = builder(); let buildr = builder();
run(buildr) {|| do run(buildr) {||
f(); f();
} }
} }
@ -1098,7 +1098,7 @@ fn test_avoid_copying_the_body_run() {
#[test] #[test]
fn test_avoid_copying_the_body_run_listener() { fn test_avoid_copying_the_body_run_listener() {
avoid_copying_the_body {|f| do avoid_copying_the_body {|f|
let buildr = builder(); let buildr = builder();
run_listener(buildr, fn~(move f, _po: comm::port<int>) { run_listener(buildr, fn~(move f, _po: comm::port<int>) {
f(); f();
@ -1108,8 +1108,8 @@ fn test_avoid_copying_the_body_run_listener() {
#[test] #[test]
fn test_avoid_copying_the_body_try() { fn test_avoid_copying_the_body_try() {
avoid_copying_the_body {|f| do avoid_copying_the_body {|f|
try {|| do try {||
f() f()
}; };
} }
@ -1117,10 +1117,10 @@ fn test_avoid_copying_the_body_try() {
#[test] #[test]
fn test_avoid_copying_the_body_future_task() { fn test_avoid_copying_the_body_future_task() {
avoid_copying_the_body {|f| do avoid_copying_the_body {|f|
let buildr = builder(); let buildr = builder();
future_task(buildr); future_task(buildr);
run(buildr) {|| do run(buildr) {||
f(); f();
} }
} }
@ -1128,10 +1128,10 @@ fn test_avoid_copying_the_body_future_task() {
#[test] #[test]
fn test_avoid_copying_the_body_unsupervise() { fn test_avoid_copying_the_body_unsupervise() {
avoid_copying_the_body {|f| do avoid_copying_the_body {|f|
let buildr = builder(); let buildr = builder();
unsupervise(buildr); unsupervise(buildr);
run(buildr) {|| do run(buildr) {||
f(); f();
} }
} }
@ -1151,7 +1151,7 @@ fn test_osmain() {
let po = comm::port(); let po = comm::port();
let ch = comm::chan(po); let ch = comm::chan(po);
run(buildr) {|| do run(buildr) {||
comm::send(ch, ()); comm::send(ch, ());
} }
comm::recv(po); comm::recv(po);
@ -1166,12 +1166,12 @@ fn test_unkillable() {
let ch = po.chan(); let ch = po.chan();
// We want to do this after failing // We want to do this after failing
spawn {|| do spawn {||
iter::repeat(10u, yield); iter::repeat(10u, yield);
ch.send(()); ch.send(());
} }
spawn {|| do spawn {||
yield(); yield();
// We want to fail after the unkillable task // We want to fail after the unkillable task
// blocks on recv // blocks on recv
@ -1179,7 +1179,7 @@ fn test_unkillable() {
} }
unsafe { unsafe {
unkillable {|| do unkillable {||
let p = ~0; let p = ~0;
let pp: *uint = unsafe::transmute(p); let pp: *uint = unsafe::transmute(p);
@ -1198,7 +1198,7 @@ fn test_unkillable() {
fn test_tls_multitask() unsafe { fn test_tls_multitask() unsafe {
fn my_key(+_x: @str) { } fn my_key(+_x: @str) { }
local_data_set(my_key, @"parent data"); local_data_set(my_key, @"parent data");
task::spawn {|| do task::spawn {||
assert local_data_get(my_key) == none; // TLS shouldn't carry over. assert local_data_get(my_key) == none; // TLS shouldn't carry over.
local_data_set(my_key, @"child data"); local_data_set(my_key, @"child data");
assert *(local_data_get(my_key).get()) == "child data"; assert *(local_data_get(my_key).get()) == "child data";
@ -1230,19 +1230,19 @@ fn test_tls_pop() unsafe {
#[test] #[test]
fn test_tls_modify() unsafe { fn test_tls_modify() unsafe {
fn my_key(+_x: @str) { } fn my_key(+_x: @str) { }
local_data_modify(my_key) {|data| local_data_modify(my_key, {|data|
alt data { alt data {
some(@val) { fail "unwelcome value: " + val } some(@val) { fail "unwelcome value: " + val }
none { some(@"first data") } none { some(@"first data") }
} }
} });
local_data_modify(my_key) {|data| local_data_modify(my_key, {|data|
alt data { alt data {
some(@"first data") { some(@"next data") } some(@"first data") { some(@"next data") }
some(@val) { fail "wrong value: " + val } some(@val) { fail "wrong value: " + val }
none { fail "missing value" } none { fail "missing value" }
} }
} });
assert *(local_data_pop(my_key).get()) == "next data"; assert *(local_data_pop(my_key).get()) == "next data";
} }
@ -1254,7 +1254,7 @@ fn test_tls_crust_automorestack_memorial_bug() unsafe {
// something within a rust stack segment. Then a subsequent upcall (esp. // something within a rust stack segment. Then a subsequent upcall (esp.
// for logging, think vsnprintf) would run on a stack smaller than 1 MB. // for logging, think vsnprintf) would run on a stack smaller than 1 MB.
fn my_key(+_x: @str) { } fn my_key(+_x: @str) { }
task::spawn {|| do task::spawn {||
unsafe { local_data_set(my_key, @"hax"); } unsafe { local_data_set(my_key, @"hax"); }
} }
} }
@ -1264,7 +1264,7 @@ fn test_tls_multiple_types() unsafe {
fn str_key(+_x: @str) { } fn str_key(+_x: @str) { }
fn box_key(+_x: @@()) { } fn box_key(+_x: @@()) { }
fn int_key(+_x: @int) { } fn int_key(+_x: @int) { }
task::spawn{|| do task::spawn{||
local_data_set(str_key, @"string data"); local_data_set(str_key, @"string data");
local_data_set(box_key, @@()); local_data_set(box_key, @@());
local_data_set(int_key, @42); local_data_set(int_key, @42);
@ -1276,7 +1276,7 @@ fn test_tls_overwrite_multiple_types() unsafe {
fn str_key(+_x: @str) { } fn str_key(+_x: @str) { }
fn box_key(+_x: @@()) { } fn box_key(+_x: @@()) { }
fn int_key(+_x: @int) { } fn int_key(+_x: @int) { }
task::spawn{|| do task::spawn{||
local_data_set(str_key, @"string data"); local_data_set(str_key, @"string data");
local_data_set(int_key, @42); local_data_set(int_key, @42);
// This could cause a segfault if overwriting-destruction is done with // This could cause a segfault if overwriting-destruction is done with
@ -1294,7 +1294,7 @@ fn test_tls_cleanup_on_failure() unsafe {
fn int_key(+_x: @int) { } fn int_key(+_x: @int) { }
local_data_set(str_key, @"parent data"); local_data_set(str_key, @"parent data");
local_data_set(box_key, @@()); local_data_set(box_key, @@());
task::spawn{|| // spawn_linked do task::spawn{|| // spawn_linked
local_data_set(str_key, @"string data"); local_data_set(str_key, @"string data");
local_data_set(box_key, @@()); local_data_set(box_key, @@());
local_data_set(int_key, @42); local_data_set(int_key, @42);

View file

@ -131,8 +131,8 @@ Convert to a string in a given base
Fails if `radix` < 2 or `radix` > 16 Fails if `radix` < 2 or `radix` > 16
"] "]
fn to_str(num: T, radix: uint) -> str { fn to_str(num: T, radix: uint) -> str {
to_str_bytes(false, num, radix) {|slice| do to_str_bytes(false, num, radix) {|slice|
vec::unpack_slice(slice) {|p, len| do vec::unpack_slice(slice) {|p, len|
unsafe { str::unsafe::from_buf_len(p, len) } unsafe { str::unsafe::from_buf_len(p, len) }
} }
} }
@ -177,7 +177,7 @@ fn to_str_bytes<U>(neg: bool, num: T, radix: uint,
// in-bounds, no extra cost. // in-bounds, no extra cost.
unsafe { unsafe {
vec::unpack_slice(buf) {|p, len| do vec::unpack_slice(buf) {|p, len|
let mp = p as *mut u8; let mp = p as *mut u8;
let mut i = len; let mut i = len;
let mut n = num; let mut n = num;

View file

@ -103,12 +103,12 @@ type init_op<T> = fn(uint) -> T;
#[doc = "Returns true if a vector contains no elements"] #[doc = "Returns true if a vector contains no elements"]
pure fn is_empty<T>(v: &[const T]) -> bool { pure fn is_empty<T>(v: &[const T]) -> bool {
unpack_const_slice(v) {|_p, len| len == 0u} unpack_const_slice(v, {|_p, len| len == 0u})
} }
#[doc = "Returns true if a vector contains some elements"] #[doc = "Returns true if a vector contains some elements"]
pure fn is_not_empty<T>(v: &[const T]) -> bool { pure fn is_not_empty<T>(v: &[const T]) -> bool {
unpack_const_slice(v) {|_p, len| len > 0u} unpack_const_slice(v, {|_p, len| len > 0u})
} }
#[doc = "Returns true if two vectors have the same length"] #[doc = "Returns true if two vectors have the same length"]
@ -169,7 +169,7 @@ pure fn capacity<T>(&&v: ~[const T]) -> uint {
#[doc = "Returns the length of a vector"] #[doc = "Returns the length of a vector"]
#[inline(always)] #[inline(always)]
pure fn len<T>(&&v: &[const T]) -> uint { pure fn len<T>(&&v: &[const T]) -> uint {
unpack_const_slice(v) {|_p, len| len} unpack_const_slice(v, { |_p, len| len})
} }
#[doc = " #[doc = "
@ -266,7 +266,7 @@ pure fn slice<T: copy>(v: &[const T], start: uint, end: uint) -> ~[T] {
pure fn view<T: copy>(v: &[const T], start: uint, end: uint) -> &a.[T] { pure fn view<T: copy>(v: &[const T], start: uint, end: uint) -> &a.[T] {
assert (start <= end); assert (start <= end);
assert (end <= len(v)); assert (end <= len(v));
unpack_slice(v) {|p, _len| do unpack_slice(v) {|p, _len|
unsafe { unsafe {
::unsafe::reinterpret_cast( ::unsafe::reinterpret_cast(
(ptr::offset(p, start), (end - start) * sys::size_of::<T>())) (ptr::offset(p, start), (end - start) * sys::size_of::<T>()))
@ -455,9 +455,9 @@ fn push_slow<T>(&v: ~[const T], +initval: T) {
// Unchecked vector indexing // Unchecked vector indexing
#[inline(always)] #[inline(always)]
unsafe fn ref<T: copy>(v: &[const T], i: uint) -> T { unsafe fn ref<T: copy>(v: &[const T], i: uint) -> T {
unpack_slice(v) {|p, _len| unpack_slice(v, {|p, _len|
*ptr::offset(p, i) *ptr::offset(p, i)
} })
} }
#[inline(always)] #[inline(always)]
@ -473,7 +473,7 @@ fn push_all<T: copy>(&v: ~[const T], rhs: &[const T]) {
fn push_all_move<T>(&v: ~[const T], -rhs: ~[const T]) { fn push_all_move<T>(&v: ~[const T], -rhs: ~[const T]) {
reserve(v, v.len() + rhs.len()); reserve(v, v.len() + rhs.len());
unsafe { unsafe {
unpack_slice(rhs) {|p, len| do unpack_slice(rhs) {|p, len|
for uint::range(0, len) {|i| for uint::range(0, len) {|i|
let x <- *ptr::offset(p, i); let x <- *ptr::offset(p, i);
push(v, x); push(v, x);
@ -678,7 +678,7 @@ pure fn connect<T: copy>(v: &[[T]/~], sep: T) -> ~[T] {
#[doc = "Reduce a vector from left to right"] #[doc = "Reduce a vector from left to right"]
pure fn foldl<T: copy, U>(z: T, v: &[U], p: fn(T, U) -> T) -> T { pure fn foldl<T: copy, U>(z: T, v: &[U], p: fn(T, U) -> T) -> T {
let mut accum = z; let mut accum = z;
iter(v) { |elt| do iter(v) { |elt|
accum = p(accum, elt); accum = p(accum, elt);
} }
ret accum; ret accum;
@ -687,7 +687,7 @@ pure fn foldl<T: copy, U>(z: T, v: &[U], p: fn(T, U) -> T) -> T {
#[doc = "Reduce a vector from right to left"] #[doc = "Reduce a vector from right to left"]
pure fn foldr<T, U: copy>(v: &[T], z: U, p: fn(T, U) -> U) -> U { pure fn foldr<T, U: copy>(v: &[T], z: U, p: fn(T, U) -> U) -> U {
let mut accum = z; let mut accum = z;
riter(v) { |elt| do riter(v) { |elt|
accum = p(elt, accum); accum = p(elt, accum);
} }
ret accum; ret accum;
@ -787,7 +787,7 @@ is returned. If `f` matches no elements then none is returned.
"] "]
pure fn find_between<T: copy>(v: &[T], start: uint, end: uint, pure fn find_between<T: copy>(v: &[T], start: uint, end: uint,
f: fn(T) -> bool) -> option<T> { f: fn(T) -> bool) -> option<T> {
option::map(position_between(v, start, end, f)) { |i| v[i] } option::map(position_between(v, start, end, f), { |i| v[i] })
} }
#[doc = " #[doc = "
@ -810,12 +810,12 @@ the element is returned. If `f` matches no elements then none is returned.
"] "]
pure fn rfind_between<T: copy>(v: &[T], start: uint, end: uint, pure fn rfind_between<T: copy>(v: &[T], start: uint, end: uint,
f: fn(T) -> bool) -> option<T> { f: fn(T) -> bool) -> option<T> {
option::map(rposition_between(v, start, end, f)) { |i| v[i] } option::map(rposition_between(v, start, end, f), { |i| v[i] })
} }
#[doc = "Find the first index containing a matching value"] #[doc = "Find the first index containing a matching value"]
pure fn position_elem<T>(v: &[T], x: T) -> option<uint> { pure fn position_elem<T>(v: &[T], x: T) -> option<uint> {
position(v) { |y| x == y } position(v, { |y| x == y })
} }
#[doc = " #[doc = "
@ -847,7 +847,7 @@ pure fn position_between<T>(v: &[T], start: uint, end: uint,
#[doc = "Find the last index containing a matching value"] #[doc = "Find the last index containing a matching value"]
pure fn rposition_elem<T>(v: &[T], x: T) -> option<uint> { pure fn rposition_elem<T>(v: &[T], x: T) -> option<uint> {
rposition(v) { |y| x == y } rposition(v, { |y| x == y })
} }
#[doc = " #[doc = "
@ -974,7 +974,7 @@ element's value.
*/ */
#[inline(always)] #[inline(always)]
pure fn iter_between<T>(v: &[T], start: uint, end: uint, f: fn(T)) { pure fn iter_between<T>(v: &[T], start: uint, end: uint, f: fn(T)) {
unpack_slice(v) { |base_ptr, len| do unpack_slice(v) { |base_ptr, len|
assert start <= end; assert start <= end;
assert end <= len; assert end <= len;
unsafe { unsafe {
@ -996,7 +996,7 @@ Return true to continue, false to break.
"] "]
#[inline(always)] #[inline(always)]
pure fn each<T>(v: &[const T], f: fn(T) -> bool) { pure fn each<T>(v: &[const T], f: fn(T) -> bool) {
vec::unpack_slice(v) {|p, n| do vec::unpack_slice(v) {|p, n|
let mut n = n; let mut n = n;
let mut p = p; let mut p = p;
while n > 0u { while n > 0u {
@ -1016,7 +1016,7 @@ Return true to continue, false to break.
"] "]
#[inline(always)] #[inline(always)]
pure fn eachi<T>(v: &[const T], f: fn(uint, T) -> bool) { pure fn eachi<T>(v: &[const T], f: fn(uint, T) -> bool) {
vec::unpack_slice(v) {|p, n| do vec::unpack_slice(v) {|p, n|
let mut i = 0u; let mut i = 0u;
let mut p = p; let mut p = p;
while i < n { while i < n {
@ -1064,7 +1064,7 @@ Iterates over vector `v` and, for each element, calls function `f` with the
element's value. element's value.
"] "]
pure fn riter<T>(v: &[T], f: fn(T)) { pure fn riter<T>(v: &[T], f: fn(T)) {
riteri(v) { |_i, v| f(v) } riteri(v, { |_i, v| f(v) })
} }
#[doc =" #[doc ="
@ -1102,9 +1102,9 @@ pure fn permute<T: copy>(v: &[T], put: fn(~[T])) {
let mut rest = slice(v, 0u, i); let mut rest = slice(v, 0u, i);
unchecked { unchecked {
push_all(rest, view(v, i+1u, ln)); push_all(rest, view(v, i+1u, ln));
permute(rest) {|permutation| permute(rest, {|permutation|
put(append(~[elt], permutation)) put(append(~[elt], permutation))
} })
} }
i += 1u; i += 1u;
} }
@ -1130,11 +1130,11 @@ Allows for unsafe manipulation of vector contents, which is useful for native
interop. interop.
"] "]
fn as_buf<E,T>(v: &[E], f: fn(*E) -> T) -> T { fn as_buf<E,T>(v: &[E], f: fn(*E) -> T) -> T {
unpack_slice(v) { |buf, _len| f(buf) } unpack_slice(v, { |buf, _len| f(buf) })
} }
fn as_mut_buf<E,T>(v: &[mut E], f: fn(*mut E) -> T) -> T { fn as_mut_buf<E,T>(v: &[mut E], f: fn(*mut E) -> T) -> T {
unpack_mut_slice(v) { |buf, _len| f(buf) } unpack_mut_slice(v, { |buf, _len| f(buf) })
} }
#[doc = " #[doc = "
@ -1896,19 +1896,19 @@ mod tests {
let mut results: ~[~[int]]; let mut results: ~[~[int]];
results = ~[]; results = ~[];
permute(~[]) {|v| vec::push(results, v); } permute(~[], {|v| vec::push(results, v); });
assert results == ~[~[]]; assert results == ~[~[]];
results = ~[]; results = ~[];
permute(~[7]) {|v| results += ~[v]; } permute(~[7], {|v| results += ~[v]; });
assert results == ~[~[7]]; assert results == ~[~[7]];
results = ~[]; results = ~[];
permute(~[1,1]) {|v| results += ~[v]; } permute(~[1,1], {|v| results += ~[v]; });
assert results == ~[~[1,1],~[1,1]]; assert results == ~[~[1,1],~[1,1]];
results = ~[]; results = ~[];
permute(~[5,2,0]) {|v| results += ~[v]; } permute(~[5,2,0], {|v| results += ~[v]; });
assert results == assert results ==
~[~[5,2,0],~[5,0,2],~[2,5,0],~[2,0,5],~[0,5,2],~[0,2,5]]; ~[~[5,2,0],~[5,0,2],~[2,5,0],~[2,0,5],~[0,5,2],~[0,2,5]];
} }

View file

@ -222,19 +222,19 @@ impl writer for writer {
} }
fn wr_tagged_u64(tag_id: uint, v: u64) { fn wr_tagged_u64(tag_id: uint, v: u64) {
io::u64_to_be_bytes(v, 8u) {|v| do io::u64_to_be_bytes(v, 8u) {|v|
self.wr_tagged_bytes(tag_id, v); self.wr_tagged_bytes(tag_id, v);
} }
} }
fn wr_tagged_u32(tag_id: uint, v: u32) { fn wr_tagged_u32(tag_id: uint, v: u32) {
io::u64_to_be_bytes(v as u64, 4u) {|v| do io::u64_to_be_bytes(v as u64, 4u) {|v|
self.wr_tagged_bytes(tag_id, v); self.wr_tagged_bytes(tag_id, v);
} }
} }
fn wr_tagged_u16(tag_id: uint, v: u16) { fn wr_tagged_u16(tag_id: uint, v: u16) {
io::u64_to_be_bytes(v as u64, 2u) {|v| do io::u64_to_be_bytes(v as u64, 2u) {|v|
self.wr_tagged_bytes(tag_id, v); self.wr_tagged_bytes(tag_id, v);
} }
} }
@ -244,19 +244,19 @@ impl writer for writer {
} }
fn wr_tagged_i64(tag_id: uint, v: i64) { fn wr_tagged_i64(tag_id: uint, v: i64) {
io::u64_to_be_bytes(v as u64, 8u) {|v| do io::u64_to_be_bytes(v as u64, 8u) {|v|
self.wr_tagged_bytes(tag_id, v); self.wr_tagged_bytes(tag_id, v);
} }
} }
fn wr_tagged_i32(tag_id: uint, v: i32) { fn wr_tagged_i32(tag_id: uint, v: i32) {
io::u64_to_be_bytes(v as u64, 4u) {|v| do io::u64_to_be_bytes(v as u64, 4u) {|v|
self.wr_tagged_bytes(tag_id, v); self.wr_tagged_bytes(tag_id, v);
} }
} }
fn wr_tagged_i16(tag_id: uint, v: i16) { fn wr_tagged_i16(tag_id: uint, v: i16) {
io::u64_to_be_bytes(v as u64, 2u) {|v| do io::u64_to_be_bytes(v as u64, 2u) {|v|
self.wr_tagged_bytes(tag_id, v); self.wr_tagged_bytes(tag_id, v);
} }
} }
@ -355,7 +355,7 @@ impl serializer of serialization::serializer for ebml::writer {
fn emit_enum_variant_arg(_idx: uint, f: fn()) { f() } fn emit_enum_variant_arg(_idx: uint, f: fn()) { f() }
fn emit_vec(len: uint, f: fn()) { fn emit_vec(len: uint, f: fn()) {
self.wr_tag(es_vec as uint) {|| do self.wr_tag(es_vec as uint) {||
self._emit_tagged_uint(es_vec_len, len); self._emit_tagged_uint(es_vec_len, len);
f() f()
} }
@ -482,7 +482,7 @@ impl deserializer of serialization::deserializer for ebml_deserializer {
#debug["read_enum_variant()"]; #debug["read_enum_variant()"];
let idx = self._next_uint(es_enum_vid); let idx = self._next_uint(es_enum_vid);
#debug[" idx=%u", idx]; #debug[" idx=%u", idx];
self.push_doc(self.next_doc(es_enum_body)) {|| do self.push_doc(self.next_doc(es_enum_body)) {||
f(idx) f(idx)
} }
} }
@ -494,7 +494,7 @@ impl deserializer of serialization::deserializer for ebml_deserializer {
fn read_vec<T:copy>(f: fn(uint) -> T) -> T { fn read_vec<T:copy>(f: fn(uint) -> T) -> T {
#debug["read_vec()"]; #debug["read_vec()"];
self.push_doc(self.next_doc(es_vec)) {|| do self.push_doc(self.next_doc(es_vec)) {||
let len = self._next_uint(es_vec_len); let len = self._next_uint(es_vec_len);
#debug[" len=%u", len]; #debug[" len=%u", len];
f(len) f(len)
@ -549,14 +549,14 @@ fn test_option_int() {
} }
fn serialize_0<S: serialization::serializer>(s: S, v: option<int>) { fn serialize_0<S: serialization::serializer>(s: S, v: option<int>) {
s.emit_enum("core::option::t") {|| do s.emit_enum("core::option::t") {||
alt v { alt v {
none { none {
s.emit_enum_variant("core::option::none", 0u, 0u) {||} s.emit_enum_variant("core::option::none", 0u, 0u, {||});
} }
some(v0) { some(v0) {
s.emit_enum_variant("core::option::some", 1u, 1u) {|| do s.emit_enum_variant("core::option::some", 1u, 1u) {||
s.emit_enum_variant_arg(0u) {|| serialize_1(s, v0) } s.emit_enum_variant_arg(0u, {|| serialize_1(s, v0) });
} }
} }
} }
@ -568,12 +568,12 @@ fn test_option_int() {
} }
fn deserialize_0<S: serialization::deserializer>(s: S) -> option<int> { fn deserialize_0<S: serialization::deserializer>(s: S) -> option<int> {
s.read_enum("core::option::t") {|| do s.read_enum("core::option::t") {||
s.read_enum_variant {|i| do s.read_enum_variant {|i|
alt check i { alt check i {
0u { none } 0u { none }
1u { 1u {
let v0 = s.read_enum_variant_arg(0u) {|| let v0 = do s.read_enum_variant_arg(0u) {||
deserialize_1(s) deserialize_1(s)
}; };
some(v0) some(v0)

View file

@ -90,7 +90,7 @@ fn to_writer(wr: io::writer, j: json) {
fn escape_str(s: str) -> str { fn escape_str(s: str) -> str {
let mut escaped = "\""; let mut escaped = "\"";
str::chars_iter(s) { |c| do str::chars_iter(s) { |c|
alt c { alt c {
'"' { escaped += "\\\""; } '"' { escaped += "\\\""; }
'\\' { escaped += "\\\\"; } '\\' { escaped += "\\\\"; }
@ -110,7 +110,7 @@ fn escape_str(s: str) -> str {
#[doc = "Serializes a json value into a string"] #[doc = "Serializes a json value into a string"]
fn to_str(j: json) -> str { fn to_str(j: json) -> str {
io::with_str_writer { |wr| to_writer(wr, j) } io::with_str_writer({ |wr| to_writer(wr, j) })
} }
type parser = { type parser = {
@ -598,7 +598,7 @@ impl <A: to_json copy, B: to_json copy, C: to_json copy>
} }
impl <A: to_json> of to_json for ~[A] { impl <A: to_json> of to_json for ~[A] {
fn to_json() -> json { list(@self.map { |elt| elt.to_json() }) } fn to_json() -> json { list(@self.map({ |elt| elt.to_json() })) }
} }
impl <A: to_json copy> of to_json for hashmap<str, A> { impl <A: to_json copy> of to_json for hashmap<str, A> {
@ -635,7 +635,7 @@ mod tests {
fn mk_dict(items: ~[(str, json)]) -> json { fn mk_dict(items: ~[(str, json)]) -> json {
let d = map::str_hash(); let d = map::str_hash();
vec::iter(items) { |item| do vec::iter(items) { |item|
let (key, value) = copy item; let (key, value) = copy item;
d.insert(key, value); d.insert(key, value);
}; };

View file

@ -29,7 +29,7 @@ accumulated result.
"] "]
fn foldl<T: copy, U>(z: T, ls: @list<U>, f: fn(T, U) -> T) -> T { fn foldl<T: copy, U>(z: T, ls: @list<U>, f: fn(T, U) -> T) -> T {
let mut accum: T = z; let mut accum: T = z;
iter(ls) {|elt| accum = f(accum, elt);} do iter(ls) {|elt| accum = f(accum, elt);}
accum accum
} }
@ -77,7 +77,7 @@ pure fn is_not_empty<T: copy>(ls: @list<T>) -> bool {
#[doc = "Returns the length of a list"] #[doc = "Returns the length of a list"]
fn len<T>(ls: @list<T>) -> uint { fn len<T>(ls: @list<T>) -> uint {
let mut count = 0u; let mut count = 0u;
iter(ls) {|_e| count += 1u;} iter(ls, {|_e| count += 1u;});
count count
} }

View file

@ -261,9 +261,9 @@ mod chained {
} }
} }
fn each_key(blk: fn(K) -> bool) { self.each { |k, _v| blk(k)} } fn each_key(blk: fn(K) -> bool) { self.each({ |k, _v| blk(k)}) }
fn each_value(blk: fn(V) -> bool) { self.each { |_k, v| blk(v)} } fn each_value(blk: fn(V) -> bool) { self.each({ |_k, v| blk(v)}) }
} }
fn chains<K,V>(nchains: uint) -> ~[mut chain<K,V>] { fn chains<K,V>(nchains: uint) -> ~[mut chain<K,V>] {
@ -332,7 +332,7 @@ Convert a set into a vector.
"] "]
fn vec_from_set<T: copy>(s: set<T>) -> ~[T] { fn vec_from_set<T: copy>(s: set<T>) -> ~[T] {
let mut v = ~[]; let mut v = ~[];
s.each_key() {|k| do s.each_key() {|k|
vec::push(v, k); vec::push(v, k);
true true
}; };
@ -343,7 +343,7 @@ fn vec_from_set<T: copy>(s: set<T>) -> ~[T] {
fn hash_from_vec<K: const copy, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>, fn hash_from_vec<K: const copy, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>,
items: ~[(K, V)]) -> hashmap<K, V> { items: ~[(K, V)]) -> hashmap<K, V> {
let map = hashmap(hasher, eqer); let map = hashmap(hasher, eqer);
vec::iter(items) { |item| do vec::iter(items) { |item|
let (key, value) = item; let (key, value) = item;
map.insert(key, value); map.insert(key, value);
} }

View file

@ -88,7 +88,7 @@ fn md4_str(msg: ~[u8]) -> str {
f(a); f(b); f(c); f(d); f(a); f(b); f(c); f(d);
} }
let mut result = ""; let mut result = "";
app(a, b, c, d) {|u| do app(a, b, c, d) {|u|
let mut i = 0u32; let mut i = 0u32;
while i < 4u32 { while i < 4u32 {
let byte = (u >> (i * 8u32)) as u8; let byte = (u >> (i * 8u32)) as u8;

View file

@ -48,7 +48,7 @@ class tcp_socket {
}; };
let close_data_ptr = ptr::addr_of(close_data); let close_data_ptr = ptr::addr_of(close_data);
let stream_handle_ptr = (*(self.socket_data)).stream_handle_ptr; let stream_handle_ptr = (*(self.socket_data)).stream_handle_ptr;
iotask::interact((*(self.socket_data)).iotask) {|loop_ptr| do iotask::interact((*(self.socket_data)).iotask) {|loop_ptr|
log(debug, #fmt("interact dtor for tcp_socket stream %? loop %?", log(debug, #fmt("interact dtor for tcp_socket stream %? loop %?",
stream_handle_ptr, loop_ptr)); stream_handle_ptr, loop_ptr));
uv::ll::set_data_for_uv_handle(stream_handle_ptr, uv::ll::set_data_for_uv_handle(stream_handle_ptr,
@ -72,7 +72,7 @@ class tcp_conn_port {
let server_stream_ptr = ptr::addr_of((*conn_data_ptr).server_stream); let server_stream_ptr = ptr::addr_of((*conn_data_ptr).server_stream);
let stream_closed_po = (*(self.conn_data)).stream_closed_po; let stream_closed_po = (*(self.conn_data)).stream_closed_po;
let iotask = (*conn_data_ptr).iotask; let iotask = (*conn_data_ptr).iotask;
iotask::interact(iotask) {|loop_ptr| do iotask::interact(iotask) {|loop_ptr|
log(debug, #fmt("dtor for tcp_conn_port loop: %?", log(debug, #fmt("dtor for tcp_conn_port loop: %?",
loop_ptr)); loop_ptr));
uv::ll::close(server_stream_ptr, tcp_nl_close_cb); uv::ll::close(server_stream_ptr, tcp_nl_close_cb);
@ -131,7 +131,7 @@ fn connect(input_ip: ip::ip_addr, port: uint,
// we can send into the interact cb to be handled in libuv.. // we can send into the interact cb to be handled in libuv..
log(debug, #fmt("stream_handle_ptr outside interact %?", log(debug, #fmt("stream_handle_ptr outside interact %?",
stream_handle_ptr)); stream_handle_ptr));
iotask::interact(iotask) {|loop_ptr| do iotask::interact(iotask) {|loop_ptr|
log(debug, "in interact cb for tcp client connect.."); log(debug, "in interact cb for tcp client connect..");
log(debug, #fmt("stream_handle_ptr in interact %?", log(debug, #fmt("stream_handle_ptr in interact %?",
stream_handle_ptr)); stream_handle_ptr));
@ -251,7 +251,7 @@ value as the `err` variant
fn write_future(sock: tcp_socket, raw_write_data: ~[u8]) fn write_future(sock: tcp_socket, raw_write_data: ~[u8])
-> future<result::result<(), tcp_err_data>> unsafe { -> future<result::result<(), tcp_err_data>> unsafe {
let socket_data_ptr = ptr::addr_of(*(sock.socket_data)); let socket_data_ptr = ptr::addr_of(*(sock.socket_data));
future_spawn {|| do future_spawn {||
write_common_impl(socket_data_ptr, raw_write_data) write_common_impl(socket_data_ptr, raw_write_data)
} }
} }
@ -340,7 +340,7 @@ read attempt. Pass `0u` to wait indefinitely
fn read_future(sock: tcp_socket, timeout_msecs: uint) fn read_future(sock: tcp_socket, timeout_msecs: uint)
-> future<result::result<~[u8],tcp_err_data>> { -> future<result::result<~[u8],tcp_err_data>> {
let socket_data = ptr::addr_of(*(sock.socket_data)); let socket_data = ptr::addr_of(*(sock.socket_data));
future_spawn {|| do future_spawn {||
read_common_impl(socket_data, timeout_msecs) read_common_impl(socket_data, timeout_msecs)
} }
} }
@ -387,7 +387,7 @@ fn new_listener(host_ip: ip::ip_addr, port: uint, backlog: uint,
let setup_po = comm::port::<option<tcp_err_data>>(); let setup_po = comm::port::<option<tcp_err_data>>();
let setup_ch = comm::chan(setup_po); let setup_ch = comm::chan(setup_po);
iotask::interact(iotask) {|loop_ptr| do iotask::interact(iotask) {|loop_ptr|
let tcp_addr = ipv4_ip_addr_to_sockaddr_in(host_ip, let tcp_addr = ipv4_ip_addr_to_sockaddr_in(host_ip,
port); port);
alt uv::ll::tcp_init(loop_ptr, server_stream_ptr) { alt uv::ll::tcp_init(loop_ptr, server_stream_ptr) {
@ -488,7 +488,7 @@ fn conn_recv_spawn(server_port: tcp_conn_port,
let new_conn_po = (*(server_port.conn_data)).new_conn_po; let new_conn_po = (*(server_port.conn_data)).new_conn_po;
let iotask = (*(server_port.conn_data)).iotask; let iotask = (*(server_port.conn_data)).iotask;
let new_conn_result = comm::recv(new_conn_po); let new_conn_result = comm::recv(new_conn_po);
task::spawn {|| do task::spawn {||
let sock_create_result = alt new_conn_result { let sock_create_result = alt new_conn_result {
ok(client_stream_ptr) { ok(client_stream_ptr) {
conn_port_new_tcp_socket(client_stream_ptr, iotask) conn_port_new_tcp_socket(client_stream_ptr, iotask)
@ -709,7 +709,7 @@ fn listen_for_conn(host_ip: ip::ip_addr, port: uint, backlog: uint,
let setup_po = comm::port::<option<tcp_err_data>>(); let setup_po = comm::port::<option<tcp_err_data>>();
let setup_ch = comm::chan(setup_po); let setup_ch = comm::chan(setup_po);
iotask::interact(iotask) {|loop_ptr| do iotask::interact(iotask) {|loop_ptr|
let tcp_addr = ipv4_ip_addr_to_sockaddr_in(host_ip, let tcp_addr = ipv4_ip_addr_to_sockaddr_in(host_ip,
port); port);
alt uv::ll::tcp_init(loop_ptr, server_stream_ptr) { alt uv::ll::tcp_init(loop_ptr, server_stream_ptr) {
@ -755,7 +755,7 @@ fn listen_for_conn(host_ip: ip::ip_addr, port: uint, backlog: uint,
none { none {
on_establish_cb(kill_ch); on_establish_cb(kill_ch);
let kill_result = comm::recv(kill_po); let kill_result = comm::recv(kill_po);
iotask::interact(iotask) {|loop_ptr| do iotask::interact(iotask) {|loop_ptr|
log(debug, #fmt("tcp::listen post-kill recv hl interact %?", log(debug, #fmt("tcp::listen post-kill recv hl interact %?",
loop_ptr)); loop_ptr));
(*server_data_ptr).active = false; (*server_data_ptr).active = false;
@ -861,7 +861,7 @@ fn read_stop_common_impl(socket_data: *tcp_socket_data) ->
let stream_handle_ptr = (*socket_data).stream_handle_ptr; let stream_handle_ptr = (*socket_data).stream_handle_ptr;
let stop_po = comm::port::<option<tcp_err_data>>(); let stop_po = comm::port::<option<tcp_err_data>>();
let stop_ch = comm::chan(stop_po); let stop_ch = comm::chan(stop_po);
iotask::interact((*socket_data).iotask) {|loop_ptr| do iotask::interact((*socket_data).iotask) {|loop_ptr|
log(debug, "in interact cb for tcp::read_stop"); log(debug, "in interact cb for tcp::read_stop");
alt uv::ll::read_stop(stream_handle_ptr as *uv::ll::uv_stream_t) { alt uv::ll::read_stop(stream_handle_ptr as *uv::ll::uv_stream_t) {
0i32 { 0i32 {
@ -893,7 +893,7 @@ fn read_start_common_impl(socket_data: *tcp_socket_data)
let start_po = comm::port::<option<uv::ll::uv_err_data>>(); let start_po = comm::port::<option<uv::ll::uv_err_data>>();
let start_ch = comm::chan(start_po); let start_ch = comm::chan(start_po);
log(debug, "in tcp::read_start before interact loop"); log(debug, "in tcp::read_start before interact loop");
iotask::interact((*socket_data).iotask) {|loop_ptr| do iotask::interact((*socket_data).iotask) {|loop_ptr|
log(debug, #fmt("in tcp::read_start interact cb %?", loop_ptr)); log(debug, #fmt("in tcp::read_start interact cb %?", loop_ptr));
alt uv::ll::read_start(stream_handle_ptr as *uv::ll::uv_stream_t, alt uv::ll::read_start(stream_handle_ptr as *uv::ll::uv_stream_t,
on_alloc_cb, on_alloc_cb,
@ -935,7 +935,7 @@ fn write_common_impl(socket_data_ptr: *tcp_socket_data,
result_ch: comm::chan(result_po) result_ch: comm::chan(result_po)
}; };
let write_data_ptr = ptr::addr_of(write_data); let write_data_ptr = ptr::addr_of(write_data);
iotask::interact((*socket_data_ptr).iotask) {|loop_ptr| do iotask::interact((*socket_data_ptr).iotask) {|loop_ptr|
log(debug, #fmt("in interact cb for tcp::write %?", loop_ptr)); log(debug, #fmt("in interact cb for tcp::write %?", loop_ptr));
alt uv::ll::write(write_req_ptr, alt uv::ll::write(write_req_ptr,
stream_handle_ptr, stream_handle_ptr,
@ -979,8 +979,8 @@ fn conn_port_new_tcp_socket(
iotask : iotask iotask : iotask
}; };
let client_socket_data_ptr = ptr::addr_of(*client_socket_data); let client_socket_data_ptr = ptr::addr_of(*client_socket_data);
comm::listen {|cont_ch| do comm::listen {|cont_ch|
iotask::interact(iotask) {|loop_ptr| do iotask::interact(iotask) {|loop_ptr|
log(debug, #fmt("in interact cb 4 conn_port_new_tcp.. loop %?", log(debug, #fmt("in interact cb 4 conn_port_new_tcp.. loop %?",
loop_ptr)); loop_ptr));
uv::ll::set_data_for_uv_handle(stream_handle_ptr, uv::ll::set_data_for_uv_handle(stream_handle_ptr,
@ -1332,8 +1332,8 @@ mod test {
let cont_po = comm::port::<()>(); let cont_po = comm::port::<()>();
let cont_ch = comm::chan(cont_po); let cont_ch = comm::chan(cont_po);
// server // server
task::spawn_sched(task::manual_threads(1u)) {|| do task::spawn_sched(task::manual_threads(1u)) {||
let actual_req = comm::listen {|server_ch| let actual_req = do comm::listen {|server_ch|
run_tcp_test_server( run_tcp_test_server(
server_ip, server_ip,
server_port, server_port,
@ -1347,7 +1347,7 @@ mod test {
comm::recv(cont_po); comm::recv(cont_po);
// client // client
log(debug, "server started, firing up client.."); log(debug, "server started, firing up client..");
let actual_resp = comm::listen {|client_ch| let actual_resp = do comm::listen {|client_ch|
run_tcp_test_client( run_tcp_test_client(
server_ip, server_ip,
server_port, server_port,
@ -1376,8 +1376,8 @@ mod test {
let cont_po = comm::port::<()>(); let cont_po = comm::port::<()>();
let cont_ch = comm::chan(cont_po); let cont_ch = comm::chan(cont_po);
// server // server
task::spawn_sched(task::manual_threads(1u)) {|| do task::spawn_sched(task::manual_threads(1u)) {||
let actual_req = comm::listen {|server_ch| let actual_req = do comm::listen {|server_ch|
run_tcp_test_server_listener( run_tcp_test_server_listener(
server_ip, server_ip,
server_port, server_port,
@ -1391,7 +1391,7 @@ mod test {
comm::recv(cont_po); comm::recv(cont_po);
// client // client
log(debug, "server started, firing up client.."); log(debug, "server started, firing up client..");
let actual_resp = comm::listen {|client_ch| let actual_resp = do comm::listen {|client_ch|
run_tcp_test_client( run_tcp_test_client(
server_ip, server_ip,
server_port, server_port,
@ -1413,7 +1413,7 @@ mod test {
cont_ch: comm::chan<()>, cont_ch: comm::chan<()>,
iotask: iotask) -> str { iotask: iotask) -> str {
task::spawn_sched(task::manual_threads(1u)) {|| do task::spawn_sched(task::manual_threads(1u)) {||
let server_ip_addr = ip::v4::parse_addr(server_ip); let server_ip_addr = ip::v4::parse_addr(server_ip);
let listen_result = let listen_result =
listen_for_conn(server_ip_addr, server_port, 128u, listen_for_conn(server_ip_addr, server_port, 128u,
@ -1428,8 +1428,8 @@ mod test {
// will want the POWER // will want the POWER
{|new_conn, kill_ch| {|new_conn, kill_ch|
log(debug, "SERVER: new connection!"); log(debug, "SERVER: new connection!");
comm::listen {|cont_ch| do comm::listen {|cont_ch|
task::spawn_sched(task::manual_threads(1u)) {|| do task::spawn_sched(task::manual_threads(1u)) {||
log(debug, "SERVER: starting worker for new req"); log(debug, "SERVER: starting worker for new req");
let accept_result = accept(new_conn); let accept_result = accept(new_conn);
@ -1492,7 +1492,7 @@ mod test {
cont_ch: comm::chan<()>, cont_ch: comm::chan<()>,
iotask: iotask) -> str { iotask: iotask) -> str {
task::spawn_sched(task::manual_threads(1u)) {|| do task::spawn_sched(task::manual_threads(1u)) {||
let server_ip_addr = ip::v4::parse_addr(server_ip); let server_ip_addr = ip::v4::parse_addr(server_ip);
let new_listener_result = let new_listener_result =
new_listener(server_ip_addr, server_port, 128u, iotask); new_listener(server_ip_addr, server_port, 128u, iotask);

View file

@ -41,9 +41,9 @@ fn map_slices<A: copy send, B: copy send>(
while base < len { while base < len {
let end = uint::min(len, base + items_per_task); let end = uint::min(len, base + items_per_task);
// FIXME: why is the ::<A, ()> annotation required here? (#2617) // FIXME: why is the ::<A, ()> annotation required here? (#2617)
vec::unpack_slice::<A, ()>(xs) {|p, _len| do vec::unpack_slice::<A, ()>(xs) {|p, _len|
let f = f(); let f = f();
let f = future_spawn() {|copy base| let f = do future_spawn() {|copy base|
unsafe { unsafe {
let len = end - base; let len = end - base;
let slice = (ptr::offset(p, base), let slice = (ptr::offset(p, base),
@ -66,7 +66,7 @@ fn map_slices<A: copy send, B: copy send>(
log(info, #fmt("num_tasks: %?", (num_tasks, futures.len()))); log(info, #fmt("num_tasks: %?", (num_tasks, futures.len())));
assert(num_tasks == futures.len()); assert(num_tasks == futures.len());
let r = futures.map() {|ys| let r = do futures.map() {|ys|
ys.get() ys.get()
}; };
assert(r.len() == futures.len()); assert(r.len() == futures.len());
@ -76,23 +76,23 @@ fn map_slices<A: copy send, B: copy send>(
#[doc="A parallel version of map."] #[doc="A parallel version of map."]
fn map<A: copy send, B: copy send>(xs: ~[A], f: fn~(A) -> B) -> ~[B] { fn map<A: copy send, B: copy send>(xs: ~[A], f: fn~(A) -> B) -> ~[B] {
vec::concat(map_slices(xs) {|| vec::concat(map_slices(xs, {||
fn~(_base: uint, slice : &[A], copy f) -> ~[B] { fn~(_base: uint, slice : &[A], copy f) -> ~[B] {
vec::map(slice, f) vec::map(slice, f)
} }
}) }))
} }
#[doc="A parallel version of mapi."] #[doc="A parallel version of mapi."]
fn mapi<A: copy send, B: copy send>(xs: ~[A], fn mapi<A: copy send, B: copy send>(xs: ~[A],
f: fn~(uint, A) -> B) -> ~[B] { f: fn~(uint, A) -> B) -> ~[B] {
let slices = map_slices(xs) {|| let slices = map_slices(xs, {||
fn~(base: uint, slice : &[A], copy f) -> ~[B] { fn~(base: uint, slice : &[A], copy f) -> ~[B] {
vec::mapi(slice) {|i, x| vec::mapi(slice, {|i, x|
f(i + base, x) f(i + base, x)
} })
} }
}; });
let r = vec::concat(slices); let r = vec::concat(slices);
log(info, (r.len(), xs.len())); log(info, (r.len(), xs.len()));
assert(r.len() == xs.len()); assert(r.len() == xs.len());
@ -105,14 +105,14 @@ In this case, f is a function that creates functions to run over the
inner elements. This is to skirt the need for copy constructors."] inner elements. This is to skirt the need for copy constructors."]
fn mapi_factory<A: copy send, B: copy send>( fn mapi_factory<A: copy send, B: copy send>(
xs: ~[A], f: fn() -> fn~(uint, A) -> B) -> ~[B] { xs: ~[A], f: fn() -> fn~(uint, A) -> B) -> ~[B] {
let slices = map_slices(xs) {|| let slices = map_slices(xs, {||
let f = f(); let f = f();
fn~(base: uint, slice : &[A], move f) -> ~[B] { fn~(base: uint, slice : &[A], move f) -> ~[B] {
vec::mapi(slice) {|i, x| vec::mapi(slice, {|i, x|
f(i + base, x) f(i + base, x)
} })
} }
}; });
let r = vec::concat(slices); let r = vec::concat(slices);
log(info, (r.len(), xs.len())); log(info, (r.len(), xs.len()));
assert(r.len() == xs.len()); assert(r.len() == xs.len());
@ -121,20 +121,20 @@ fn mapi_factory<A: copy send, B: copy send>(
#[doc="Returns true if the function holds for all elements in the vector."] #[doc="Returns true if the function holds for all elements in the vector."]
fn alli<A: copy send>(xs: ~[A], f: fn~(uint, A) -> bool) -> bool { fn alli<A: copy send>(xs: ~[A], f: fn~(uint, A) -> bool) -> bool {
vec::all(map_slices(xs) {|| do vec::all(map_slices(xs, {||
fn~(base: uint, slice : &[A], copy f) -> bool { fn~(base: uint, slice : &[A], copy f) -> bool {
vec::alli(slice) {|i, x| vec::alli(slice, {|i, x|
f(i + base, x) f(i + base, x)
} })
} }
}) {|x| x } })) {|x| x }
} }
#[doc="Returns true if the function holds for any elements in the vector."] #[doc="Returns true if the function holds for any elements in the vector."]
fn any<A: copy send>(xs: ~[A], f: fn~(A) -> bool) -> bool { fn any<A: copy send>(xs: ~[A], f: fn~(A) -> bool) -> bool {
vec::any(map_slices(xs) {|| do vec::any(map_slices(xs, {||
fn~(_base : uint, slice: &[A], copy f) -> bool { fn~(_base : uint, slice: &[A], copy f) -> bool {
vec::any(slice, f) vec::any(slice, f)
} }
}) {|x| x } })) {|x| x }
} }

View file

@ -397,7 +397,7 @@ Loop through a rope, char by char, until the end.
* it - A block to execute with each consecutive character of the rope. * it - A block to execute with each consecutive character of the rope.
"] "]
fn iter_chars(rope: rope, it: fn(char)) { fn iter_chars(rope: rope, it: fn(char)) {
loop_chars(rope) {|x| do loop_chars(rope) {|x|
it(x); it(x);
true true
}; };

View file

@ -84,9 +84,9 @@ iface deserializer {
// In some cases, these should eventually be coded as traits. // In some cases, these should eventually be coded as traits.
fn emit_from_vec<S: serializer, T>(s: S, v: ~[T], f: fn(T)) { fn emit_from_vec<S: serializer, T>(s: S, v: ~[T], f: fn(T)) {
s.emit_vec(vec::len(v)) {|| do s.emit_vec(vec::len(v)) {||
vec::iteri(v) {|i,e| do vec::iteri(v) {|i,e|
s.emit_vec_elt(i) {|| do s.emit_vec_elt(i) {||
f(e) f(e)
} }
} }
@ -94,9 +94,9 @@ fn emit_from_vec<S: serializer, T>(s: S, v: ~[T], f: fn(T)) {
} }
fn read_to_vec<D: deserializer, T: copy>(d: D, f: fn() -> T) -> ~[T] { fn read_to_vec<D: deserializer, T: copy>(d: D, f: fn() -> T) -> ~[T] {
d.read_vec {|len| do d.read_vec {|len|
vec::from_fn(len) {|i| do vec::from_fn(len) {|i|
d.read_vec_elt(i) {|| f() } do d.read_vec_elt(i) {|| f() }
} }
} }
} }
@ -234,16 +234,16 @@ fn deserialize_bool<D: deserializer>(d: D) -> bool {
} }
fn serialize_option<S: serializer,T>(s: S, v: option<T>, st: fn(T)) { fn serialize_option<S: serializer,T>(s: S, v: option<T>, st: fn(T)) {
s.emit_enum("option") {|| do s.emit_enum("option") {||
alt v { alt v {
none { none {
s.emit_enum_variant("none", 0u, 0u) {|| do s.emit_enum_variant("none", 0u, 0u) {||
} }
} }
some(v) { some(v) {
s.emit_enum_variant("some", 1u, 1u) {|| do s.emit_enum_variant("some", 1u, 1u) {||
s.emit_enum_variant_arg(0u) {|| do s.emit_enum_variant_arg(0u) {||
st(v) st(v)
} }
} }
@ -254,16 +254,16 @@ fn serialize_option<S: serializer,T>(s: S, v: option<T>, st: fn(T)) {
fn deserialize_option<D: deserializer,T: copy>(d: D, st: fn() -> T) fn deserialize_option<D: deserializer,T: copy>(d: D, st: fn() -> T)
-> option<T> { -> option<T> {
d.read_enum("option") {|| do d.read_enum("option") {||
d.read_enum_variant {|i| do d.read_enum_variant {|i|
alt check i { alt check i {
0u { // none 0u { // none
none none
} }
1u { // some(v) 1u { // some(v)
some(d.read_enum_variant_arg(0u) {|| some(d.read_enum_variant_arg(0u, {||
st() st()
}) }))
} }
} }
} }

View file

@ -102,7 +102,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> {
} }
} }
fn each_value(it: fn(V) -> bool) { fn each_value(it: fn(V) -> bool) {
self.each {|_i, v| it(v)} self.each({|_i, v| it(v)});
} }
} }

View file

@ -216,7 +216,7 @@ fn run_tests_console(opts: test_opts,
fn print_failures(st: console_test_state) { fn print_failures(st: console_test_state) {
st.out.write_line("\nfailures:"); st.out.write_line("\nfailures:");
let failures = copy st.failures; let failures = copy st.failures;
let failures = vec::map(failures) {|test| test.name}; let failures = vec::map(failures, {|test| test.name});
let failures = sort::merge_sort(str::le, failures); let failures = sort::merge_sort(str::le, failures);
for vec::each(failures) {|name| for vec::each(failures) {|name|
st.out.write_line(#fmt[" %s", name]); st.out.write_line(#fmt[" %s", name]);
@ -390,7 +390,7 @@ fn run_test(+test: test_desc, monitor_ch: comm::chan<monitor_msg>) {
ret; ret;
} }
task::spawn {|| do task::spawn {||
let testfn = copy test.fn; let testfn = copy test.fn;
let mut builder = task::builder(); let mut builder = task::builder();
let result_future = task::future_result(builder); let result_future = task::future_result(builder);

View file

@ -283,21 +283,21 @@ fn strptime(s: str, format: str) -> result<tm, str> {
} }
'c' { 'c' {
parse_type(s, pos, 'a', tm) parse_type(s, pos, 'a', tm)
.chain { |pos| parse_char(s, pos, ' ') } .chain({ |pos| parse_char(s, pos, ' ') })
.chain { |pos| parse_type(s, pos, 'b', tm) } .chain({ |pos| parse_type(s, pos, 'b', tm) })
.chain { |pos| parse_char(s, pos, ' ') } .chain({ |pos| parse_char(s, pos, ' ') })
.chain { |pos| parse_type(s, pos, 'e', tm) } .chain({ |pos| parse_type(s, pos, 'e', tm) })
.chain { |pos| parse_char(s, pos, ' ') } .chain({ |pos| parse_char(s, pos, ' ') })
.chain { |pos| parse_type(s, pos, 'T', tm) } .chain({ |pos| parse_type(s, pos, 'T', tm) })
.chain { |pos| parse_char(s, pos, ' ') } .chain({ |pos| parse_char(s, pos, ' ') })
.chain { |pos| parse_type(s, pos, 'Y', tm) } .chain({ |pos| parse_type(s, pos, 'Y', tm) })
} }
'D' | 'x' { 'D' | 'x' {
parse_type(s, pos, 'm', tm) parse_type(s, pos, 'm', tm)
.chain { |pos| parse_char(s, pos, '/') } .chain({ |pos| parse_char(s, pos, '/') })
.chain { |pos| parse_type(s, pos, 'd', tm) } .chain({ |pos| parse_type(s, pos, 'd', tm) })
.chain { |pos| parse_char(s, pos, '/') } .chain({ |pos| parse_char(s, pos, '/') })
.chain { |pos| parse_type(s, pos, 'y', tm) } .chain({ |pos| parse_type(s, pos, 'y', tm) })
} }
'd' { 'd' {
alt match_digits(s, pos, 2u, false) { alt match_digits(s, pos, 2u, false) {
@ -313,10 +313,10 @@ fn strptime(s: str, format: str) -> result<tm, str> {
} }
'F' { 'F' {
parse_type(s, pos, 'Y', tm) parse_type(s, pos, 'Y', tm)
.chain { |pos| parse_char(s, pos, '-') } .chain({ |pos| parse_char(s, pos, '-') })
.chain { |pos| parse_type(s, pos, 'm', tm) } .chain({ |pos| parse_type(s, pos, 'm', tm) })
.chain { |pos| parse_char(s, pos, '-') } .chain({ |pos| parse_char(s, pos, '-') })
.chain { |pos| parse_type(s, pos, 'd', tm) } .chain({ |pos| parse_type(s, pos, 'd', tm) })
} }
'H' { 'H' {
// FIXME (#2350): range check. // FIXME (#2350): range check.
@ -398,17 +398,17 @@ fn strptime(s: str, format: str) -> result<tm, str> {
} }
'R' { 'R' {
parse_type(s, pos, 'H', tm) parse_type(s, pos, 'H', tm)
.chain { |pos| parse_char(s, pos, ':') } .chain({ |pos| parse_char(s, pos, ':') })
.chain { |pos| parse_type(s, pos, 'M', tm) } .chain({ |pos| parse_type(s, pos, 'M', tm) })
} }
'r' { 'r' {
parse_type(s, pos, 'I', tm) parse_type(s, pos, 'I', tm)
.chain { |pos| parse_char(s, pos, ':') } .chain({ |pos| parse_char(s, pos, ':') })
.chain { |pos| parse_type(s, pos, 'M', tm) } .chain({ |pos| parse_type(s, pos, 'M', tm) })
.chain { |pos| parse_char(s, pos, ':') } .chain({ |pos| parse_char(s, pos, ':') })
.chain { |pos| parse_type(s, pos, 'S', tm) } .chain({ |pos| parse_type(s, pos, 'S', tm) })
.chain { |pos| parse_char(s, pos, ' ') } .chain({ |pos| parse_char(s, pos, ' ') })
.chain { |pos| parse_type(s, pos, 'p', tm) } .chain({ |pos| parse_type(s, pos, 'p', tm) })
} }
'S' { 'S' {
// FIXME (#2350): range check. // FIXME (#2350): range check.
@ -424,10 +424,10 @@ fn strptime(s: str, format: str) -> result<tm, str> {
//'s' {} //'s' {}
'T' | 'X' { 'T' | 'X' {
parse_type(s, pos, 'H', tm) parse_type(s, pos, 'H', tm)
.chain { |pos| parse_char(s, pos, ':') } .chain({ |pos| parse_char(s, pos, ':') })
.chain { |pos| parse_type(s, pos, 'M', tm) } .chain({ |pos| parse_type(s, pos, 'M', tm) })
.chain { |pos| parse_char(s, pos, ':') } .chain({ |pos| parse_char(s, pos, ':') })
.chain { |pos| parse_type(s, pos, 'S', tm) } .chain({ |pos| parse_type(s, pos, 'S', tm) })
} }
't' { parse_char(s, pos, '\t') } 't' { parse_char(s, pos, '\t') }
'u' { 'u' {
@ -443,10 +443,10 @@ fn strptime(s: str, format: str) -> result<tm, str> {
} }
'v' { 'v' {
parse_type(s, pos, 'e', tm) parse_type(s, pos, 'e', tm)
.chain { |pos| parse_char(s, pos, '-') } .chain({ |pos| parse_char(s, pos, '-') })
.chain { |pos| parse_type(s, pos, 'b', tm) } .chain({ |pos| parse_type(s, pos, 'b', tm) })
.chain { |pos| parse_char(s, pos, '-') } .chain({ |pos| parse_char(s, pos, '-') })
.chain { |pos| parse_type(s, pos, 'Y', tm) } .chain({ |pos| parse_type(s, pos, 'Y', tm) })
} }
//'W' {} //'W' {}
'w' { 'w' {
@ -526,7 +526,7 @@ fn strptime(s: str, format: str) -> result<tm, str> {
} }
} }
io::with_str_reader(format) { |rdr| do io::with_str_reader(format) { |rdr|
let tm = { let tm = {
mut tm_sec: 0_i32, mut tm_sec: 0_i32,
mut tm_min: 0_i32, mut tm_min: 0_i32,
@ -738,7 +738,7 @@ fn strftime(format: str, tm: tm) -> str {
let mut buf = ""; let mut buf = "";
io::with_str_reader(format) { |rdr| do io::with_str_reader(format) { |rdr|
while !rdr.eof() { while !rdr.eof() {
alt rdr.read_char() { alt rdr.read_char() {
'%' { buf += parse_type(rdr.read_char(), tm); } '%' { buf += parse_type(rdr.read_char(), tm); }
@ -1002,7 +1002,7 @@ mod tests {
} }
} }
[ do [
"Sunday", "Sunday",
"Monday", "Monday",
"Tuesday", "Tuesday",
@ -1012,7 +1012,7 @@ mod tests {
"Saturday" "Saturday"
]/_.iter { |day| assert test(day, "%A"); } ]/_.iter { |day| assert test(day, "%A"); }
[ do [
"Sun", "Sun",
"Mon", "Mon",
"Tue", "Tue",
@ -1022,7 +1022,7 @@ mod tests {
"Sat" "Sat"
]/_.iter { |day| assert test(day, "%a"); } ]/_.iter { |day| assert test(day, "%a"); }
[ do [
"January", "January",
"February", "February",
"March", "March",
@ -1037,7 +1037,7 @@ mod tests {
"December" "December"
]/_.iter { |day| assert test(day, "%B"); } ]/_.iter { |day| assert test(day, "%B"); }
[ do [
"Jan", "Jan",
"Feb", "Feb",
"Mar", "Mar",

View file

@ -31,7 +31,7 @@ fn delayed_send<T: copy send>(iotask: iotask,
let timer_done_ch_ptr = ptr::addr_of(timer_done_ch); let timer_done_ch_ptr = ptr::addr_of(timer_done_ch);
let timer = uv::ll::timer_t(); let timer = uv::ll::timer_t();
let timer_ptr = ptr::addr_of(timer); let timer_ptr = ptr::addr_of(timer);
iotask::interact(iotask) {|loop_ptr| do iotask::interact(iotask) {|loop_ptr|
let init_result = uv::ll::timer_init(loop_ptr, timer_ptr); let init_result = uv::ll::timer_init(loop_ptr, timer_ptr);
if (init_result == 0i32) { if (init_result == 0i32) {
let start_result = uv::ll::timer_start( let start_result = uv::ll::timer_start(
@ -151,7 +151,7 @@ mod test {
#[test] #[test]
fn test_gl_timer_sleep_stress1() { fn test_gl_timer_sleep_stress1() {
let hl_loop = uv::global_loop::get(); let hl_loop = uv::global_loop::get();
iter::repeat(200u) {|| do iter::repeat(200u) {||
sleep(hl_loop, 1u); sleep(hl_loop, 1u);
} }
} }
@ -171,14 +171,14 @@ mod test {
}; };
iter::repeat(repeat) {|| do iter::repeat(repeat) {||
for spec.each {|spec| for spec.each {|spec|
let (times, maxms) = spec; let (times, maxms) = spec;
task::spawn {|| do task::spawn {||
import rand::*; import rand::*;
let rng = rng(); let rng = rng();
iter::repeat(times) {|| do iter::repeat(times) {||
sleep(hl_loop, rng.next() as uint % maxms); sleep(hl_loop, rng.next() as uint % maxms);
} }
comm::send(ch, ()); comm::send(ch, ());
@ -186,7 +186,7 @@ mod test {
} }
} }
iter::repeat(repeat * spec.len()) {|| do iter::repeat(repeat * spec.len()) {||
comm::recv(po) comm::recv(po)
} }
} }
@ -204,14 +204,14 @@ mod test {
let mut failures = 0; let mut failures = 0;
let hl_loop = uv::global_loop::get(); let hl_loop = uv::global_loop::get();
iter::repeat(times as uint) {|| do iter::repeat(times as uint) {||
task::yield(); task::yield();
let expected = rand::rng().gen_str(16u); let expected = rand::rng().gen_str(16u);
let test_po = comm::port::<str>(); let test_po = comm::port::<str>();
let test_ch = comm::chan(test_po); let test_ch = comm::chan(test_po);
task::spawn() {|| do task::spawn() {||
delayed_send(hl_loop, 1u, test_ch, expected); delayed_send(hl_loop, 1u, test_ch, expected);
}; };
@ -231,12 +231,12 @@ mod test {
let mut failures = 0; let mut failures = 0;
let hl_loop = uv::global_loop::get(); let hl_loop = uv::global_loop::get();
iter::repeat(times as uint) {|| do iter::repeat(times as uint) {||
let expected = rand::rng().gen_str(16u); let expected = rand::rng().gen_str(16u);
let test_po = comm::port::<str>(); let test_po = comm::port::<str>();
let test_ch = comm::chan(test_po); let test_ch = comm::chan(test_po);
task::spawn() {|| do task::spawn() {||
delayed_send(hl_loop, 1000u, test_ch, expected); delayed_send(hl_loop, 1000u, test_ch, expected);
}; };

View file

@ -56,12 +56,12 @@ fn get_monitor_task_gl() -> iotask unsafe {
#debug("before priv::chan_from_global_ptr"); #debug("before priv::chan_from_global_ptr");
type monchan = chan<iotask>; type monchan = chan<iotask>;
let monitor_ch = chan_from_global_ptr::<monchan>(monitor_loop_chan_ptr, let monitor_ch = do chan_from_global_ptr::<monchan>(monitor_loop_chan_ptr,
builder_fn) {|msg_po| builder_fn) {|msg_po|
#debug("global monitor task starting"); #debug("global monitor task starting");
// As a weak task the runtime will notify us when to exit // As a weak task the runtime will notify us when to exit
weaken_task() {|weak_exit_po| do weaken_task() {|weak_exit_po|
#debug("global monitor task is now weak"); #debug("global monitor task is now weak");
let hl_loop = spawn_loop(); let hl_loop = spawn_loop();
loop { loop {
@ -87,7 +87,7 @@ fn get_monitor_task_gl() -> iotask unsafe {
// once we have a chan to the monitor loop, we ask it for // once we have a chan to the monitor loop, we ask it for
// the libuv loop's async handle // the libuv loop's async handle
listen { |fetch_ch| do listen { |fetch_ch|
monitor_ch.send(fetch_ch); monitor_ch.send(fetch_ch);
fetch_ch.recv() fetch_ch.recv()
} }
@ -95,11 +95,11 @@ fn get_monitor_task_gl() -> iotask unsafe {
fn spawn_loop() -> iotask unsafe { fn spawn_loop() -> iotask unsafe {
let builder = task::builder(); let builder = task::builder();
task::add_wrapper(builder) {|task_body| do task::add_wrapper(builder) {|task_body|
fn~(move task_body) { fn~(move task_body) {
// The I/O loop task also needs to be weak so it doesn't keep // The I/O loop task also needs to be weak so it doesn't keep
// the runtime alive // the runtime alive
weaken_task {|weak_exit_po| do weaken_task {|weak_exit_po|
#debug("global libuv task is now weak %?", weak_exit_po); #debug("global libuv task is now weak %?", weak_exit_po);
task_body(); task_body();
@ -129,7 +129,7 @@ mod test {
log(debug, "in simple timer cb"); log(debug, "in simple timer cb");
ll::timer_stop(timer_ptr); ll::timer_stop(timer_ptr);
let hl_loop = get_gl(); let hl_loop = get_gl();
iotask::interact(hl_loop) {|_loop_ptr| do iotask::interact(hl_loop) {|_loop_ptr|
log(debug, "closing timer"); log(debug, "closing timer");
ll::close(timer_ptr, simple_timer_close_cb); ll::close(timer_ptr, simple_timer_close_cb);
log(debug, "about to deref exit_ch_ptr"); log(debug, "about to deref exit_ch_ptr");
@ -146,7 +146,7 @@ mod test {
exit_ch_ptr)); exit_ch_ptr));
let timer_handle = ll::timer_t(); let timer_handle = ll::timer_t();
let timer_ptr = ptr::addr_of(timer_handle); let timer_ptr = ptr::addr_of(timer_handle);
iotask::interact(iotask) {|loop_ptr| do iotask::interact(iotask) {|loop_ptr|
log(debug, "user code inside interact loop!!!"); log(debug, "user code inside interact loop!!!");
let init_status = ll::timer_init(loop_ptr, timer_ptr); let init_status = ll::timer_init(loop_ptr, timer_ptr);
if(init_status == 0i32) { if(init_status == 0i32) {
@ -191,13 +191,13 @@ mod test {
let exit_po = comm::port::<()>(); let exit_po = comm::port::<()>();
let exit_ch = comm::chan(exit_po); let exit_ch = comm::chan(exit_po);
let cycles = 5000u; let cycles = 5000u;
iter::repeat(cycles) {|| do iter::repeat(cycles) {||
task::spawn_sched(task::manual_threads(1u), {|| task::spawn_sched(task::manual_threads(1u), {||
impl_uv_hl_simple_timer(hl_loop); impl_uv_hl_simple_timer(hl_loop);
comm::send(exit_ch, ()); comm::send(exit_ch, ());
}); });
}; };
iter::repeat(cycles) {|| do iter::repeat(cycles) {||
comm::recv(exit_po); comm::recv(exit_po);
}; };
log(debug, "test_stress_gl_uv_global_loop_high_level_global_timer"+ log(debug, "test_stress_gl_uv_global_loop_high_level_global_timer"+

View file

@ -39,9 +39,9 @@ fn spawn_iotask(-builder: task::builder) -> iotask {
with get_opts(builder) with get_opts(builder)
}); });
listen {|iotask_ch| do listen {|iotask_ch|
run(copy(builder)) {|| do run(copy(builder)) {||
#debug("entering libuv task"); #debug("entering libuv task");
run_loop(iotask_ch); run_loop(iotask_ch);
#debug("libuv task exiting"); #debug("libuv task exiting");
@ -211,7 +211,7 @@ mod test {
exit_ch: exit_ch exit_ch: exit_ch
}; };
let ah_data_ptr = ptr::addr_of(ah_data); let ah_data_ptr = ptr::addr_of(ah_data);
interact(iotask) {|loop_ptr| do interact(iotask) {|loop_ptr|
ll::async_init(loop_ptr, ah_ptr, async_handle_cb); ll::async_init(loop_ptr, ah_ptr, async_handle_cb);
ll::set_data_for_uv_handle(ah_ptr, ah_data_ptr as *libc::c_void); ll::set_data_for_uv_handle(ah_ptr, ah_data_ptr as *libc::c_void);
ll::async_send(ah_ptr); ll::async_send(ah_ptr);
@ -224,7 +224,7 @@ mod test {
unsafe fn spawn_test_loop(exit_ch: comm::chan<()>) -> iotask { unsafe fn spawn_test_loop(exit_ch: comm::chan<()>) -> iotask {
let iotask_port = comm::port::<iotask>(); let iotask_port = comm::port::<iotask>();
let iotask_ch = comm::chan(iotask_port); let iotask_ch = comm::chan(iotask_port);
task::spawn_sched(task::manual_threads(1u)) {|| do task::spawn_sched(task::manual_threads(1u)) {||
run_loop(iotask_ch); run_loop(iotask_ch);
exit_ch.send(()); exit_ch.send(());
}; };
@ -255,13 +255,13 @@ mod test {
// called, at least. // called, at least.
let work_exit_po = comm::port::<()>(); let work_exit_po = comm::port::<()>();
let work_exit_ch = comm::chan(work_exit_po); let work_exit_ch = comm::chan(work_exit_po);
iter::repeat(7u) {|| do iter::repeat(7u) {||
task::spawn_sched(task::manual_threads(1u), {|| do task::spawn_sched(task::manual_threads(1u)) {||
impl_uv_iotask_async(iotask); impl_uv_iotask_async(iotask);
comm::send(work_exit_ch, ()); comm::send(work_exit_ch, ());
}); };
}; };
iter::repeat(7u) {|| do iter::repeat(7u) {||
comm::recv(work_exit_po); comm::recv(work_exit_po);
}; };
log(debug, "sending teardown_loop msg.."); log(debug, "sending teardown_loop msg..");

View file

@ -1262,7 +1262,7 @@ mod test {
let continue_chan = comm::chan::<bool>(continue_port); let continue_chan = comm::chan::<bool>(continue_port);
let continue_chan_ptr = ptr::addr_of(continue_chan); let continue_chan_ptr = ptr::addr_of(continue_chan);
task::spawn_sched(task::manual_threads(1u)) {|| do task::spawn_sched(task::manual_threads(1u)) {||
impl_uv_tcp_server(bind_ip, port, impl_uv_tcp_server(bind_ip, port,
kill_server_msg, kill_server_msg,
server_resp_msg, server_resp_msg,
@ -1275,7 +1275,7 @@ mod test {
comm::recv(continue_port); comm::recv(continue_port);
log(debug, "received on continue port, set up tcp client"); log(debug, "received on continue port, set up tcp client");
task::spawn_sched(task::manual_threads(1u)) {|| do task::spawn_sched(task::manual_threads(1u)) {||
impl_uv_tcp_request(request_ip, port, impl_uv_tcp_request(request_ip, port,
kill_server_msg, kill_server_msg,
ptr::addr_of(client_chan)); ptr::addr_of(client_chan));

View file

@ -11,7 +11,7 @@ type path = ~[path_elt];
/* FIXMEs that say "bad" are as per #2543 */ /* FIXMEs that say "bad" are as per #2543 */
fn path_to_str_with_sep(p: path, sep: str) -> str { fn path_to_str_with_sep(p: path, sep: str) -> str {
let strs = vec::map(p) {|e| let strs = do vec::map(p) {|e|
alt e { alt e {
path_mod(s) { /* FIXME (#2543) */ copy *s } path_mod(s) { /* FIXME (#2543) */ copy *s }
path_name(s) { /* FIXME (#2543) */ copy *s } path_name(s) { /* FIXME (#2543) */ copy *s }
@ -156,7 +156,7 @@ fn map_block(b: blk, cx: ctx, v: vt) {
} }
fn number_pat(cx: ctx, pat: @pat) { fn number_pat(cx: ctx, pat: @pat) {
ast_util::walk_pat(pat) {|p| do ast_util::walk_pat(pat) {|p|
alt p.node { alt p.node {
pat_ident(_, _) { pat_ident(_, _) {
cx.map.insert(p.id, node_local(cx.local_id)); cx.map.insert(p.id, node_local(cx.local_id));
@ -218,12 +218,12 @@ fn map_item(i: @item, cx: ctx, v: vt) {
let (_, ms) = ast_util::split_class_items(items); let (_, ms) = ast_util::split_class_items(items);
// Map iface refs to their parent classes. This is // Map iface refs to their parent classes. This is
// so we can find the self_ty // so we can find the self_ty
vec::iter(ifces) {|p| cx.map.insert(p.id, do vec::iter(ifces) {|p| cx.map.insert(p.id,
node_item(i, item_path)); }; node_item(i, item_path)); };
let d_id = ast_util::local_def(i.id); let d_id = ast_util::local_def(i.id);
let p = extend(cx, i.ident); let p = extend(cx, i.ident);
// only need to handle methods // only need to handle methods
vec::iter(ms) {|m| map_method(d_id, p, m, cx); } do vec::iter(ms) {|m| map_method(d_id, p, m, cx); }
} }
_ { } _ { }
} }

View file

@ -408,7 +408,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
alt vi.node { alt vi.node {
view_item_use(_, _, id) { vfn(id) } view_item_use(_, _, id) { vfn(id) }
view_item_import(vps) | view_item_export(vps) { view_item_import(vps) | view_item_export(vps) {
vec::iter(vps) {|vp| do vec::iter(vps) {|vp|
alt vp.node { alt vp.node {
view_path_simple(_, _, id) { vfn(id) } view_path_simple(_, _, id) { vfn(id) }
view_path_glob(_, id) { vfn(id) } view_path_glob(_, id) { vfn(id) }
@ -473,7 +473,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
}, },
visit_ty_params: fn@(ps: ~[ty_param]) { visit_ty_params: fn@(ps: ~[ty_param]) {
vec::iter(ps) {|p| vfn(p.id) } vec::iter(ps, {|p| vfn(p.id) })
}, },
visit_constr: fn@(_p: @path, _sp: span, id: node_id) { visit_constr: fn@(_p: @path, _sp: span, id: node_id) {
@ -486,23 +486,23 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
alt fk { alt fk {
visit::fk_ctor(nm, tps, self_id, parent_id) { visit::fk_ctor(nm, tps, self_id, parent_id) {
vec::iter(tps) {|tp| vfn(tp.id)} vec::iter(tps, {|tp| vfn(tp.id)});
vfn(id); vfn(id);
vfn(self_id); vfn(self_id);
vfn(parent_id.node); vfn(parent_id.node);
} }
visit::fk_dtor(tps, self_id, parent_id) { visit::fk_dtor(tps, self_id, parent_id) {
vec::iter(tps) {|tp| vfn(tp.id)} vec::iter(tps, {|tp| vfn(tp.id)});
vfn(id); vfn(id);
vfn(self_id); vfn(self_id);
vfn(parent_id.node); vfn(parent_id.node);
} }
visit::fk_item_fn(_, tps) { visit::fk_item_fn(_, tps) {
vec::iter(tps) {|tp| vfn(tp.id)} vec::iter(tps, {|tp| vfn(tp.id)});
} }
visit::fk_method(_, tps, m) { visit::fk_method(_, tps, m) {
vfn(m.self_id); vfn(m.self_id);
vec::iter(tps) {|tp| vfn(tp.id)} vec::iter(tps, {|tp| vfn(tp.id)});
} }
visit::fk_anon(_, capture_clause) visit::fk_anon(_, capture_clause)
| visit::fk_fn_block(capture_clause) { | visit::fk_fn_block(capture_clause) {
@ -512,7 +512,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
} }
} }
vec::iter(d.inputs) {|arg| do vec::iter(d.inputs) {|arg|
vfn(arg.id) vfn(arg.id)
} }
}, },
@ -536,7 +536,7 @@ fn visit_ids_for_inlined_item(item: inlined_item, vfn: fn@(node_id)) {
fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range { fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range {
let min = @mut int::max_value; let min = @mut int::max_value;
let max = @mut int::min_value; let max = @mut int::min_value;
visit_ids_fn { |id| do visit_ids_fn { |id|
*min = int::min(*min, id); *min = int::min(*min, id);
*max = int::max(*max, id + 1); *max = int::max(*max, id + 1);
} }
@ -544,7 +544,7 @@ fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range {
} }
fn compute_id_range_for_inlined_item(item: inlined_item) -> id_range { fn compute_id_range_for_inlined_item(item: inlined_item) -> id_range {
compute_id_range { |f| visit_ids_for_inlined_item(item, f) } compute_id_range({ |f| visit_ids_for_inlined_item(item, f) })
} }
pure fn is_item_impl(item: @ast::item) -> bool { pure fn is_item_impl(item: @ast::item) -> bool {

View file

@ -315,7 +315,7 @@ From a list of crate attributes get only the meta_items that impact crate
linkage linkage
"] "]
fn find_linkage_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { fn find_linkage_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] {
find_linkage_attrs(attrs).flat_map {|attr| do find_linkage_attrs(attrs).flat_map {|attr|
alt check attr.node.value.node { alt check attr.node.value.node {
ast::meta_list(_, items) { /* FIXME (#2543) */ copy items } ast::meta_list(_, items) { /* FIXME (#2543) */ copy items }
} }
@ -351,7 +351,7 @@ enum inline_attr {
#[doc = "True if something like #[inline] is found in the list of attrs."] #[doc = "True if something like #[inline] is found in the list of attrs."]
fn find_inline_attr(attrs: ~[ast::attribute]) -> inline_attr { fn find_inline_attr(attrs: ~[ast::attribute]) -> inline_attr {
// TODO---validate the usage of #[inline] and #[inline(always)] // TODO---validate the usage of #[inline] and #[inline(always)]
vec::foldl(ia_none, attrs) {|ia,attr| do vec::foldl(ia_none, attrs) {|ia,attr|
alt attr.node.value.node { alt attr.node.value.node {
ast::meta_word(@"inline") { ia_hint } ast::meta_word(@"inline") { ia_hint }
ast::meta_list(@"inline", items) { ast::meta_list(@"inline", items) {

View file

@ -249,7 +249,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
} }
fn print_macro_backtrace(cm: codemap::codemap, sp: span) { fn print_macro_backtrace(cm: codemap::codemap, sp: span) {
option::iter (sp.expn_info) {|ei| do option::iter (sp.expn_info) {|ei|
let ss = option::map_default(ei.callie.span, @"", { let ss = option::map_default(ei.callie.span, @"", {
|span| |span|
@codemap::span_to_str(span, cm) @codemap::span_to_str(span, cm)

View file

@ -100,7 +100,7 @@ fn expand(cx: ext_ctxt,
with *item} with *item}
} }
vec::flat_map(in_items) {|in_item| do vec::flat_map(in_items) {|in_item|
alt in_item.node { alt in_item.node {
ast::item_ty(ty, tps, _) { ast::item_ty(ty, tps, _) {
vec::append(~[filter_attrs(in_item)], vec::append(~[filter_attrs(in_item)],
@ -151,7 +151,7 @@ impl helpers for ext_ctxt {
fn ty_fn(span: span, fn ty_fn(span: span,
-input_tys: ~[@ast::ty], -input_tys: ~[@ast::ty],
-output: @ast::ty) -> @ast::ty { -output: @ast::ty) -> @ast::ty {
let args = vec::map(input_tys) {|ty| let args = do vec::map(input_tys) {|ty|
{mode: ast::expl(ast::by_ref), {mode: ast::expl(ast::by_ref),
ty: ty, ty: ty,
ident: @"", ident: @"",
@ -294,7 +294,7 @@ fn ser_path(cx: ext_ctxt, tps: ser_tps_map, path: @ast::path,
ast::expr_path( ast::expr_path(
cx.helper_path(path, "serialize"))); cx.helper_path(path, "serialize")));
let ty_args = vec::map(path.types) {|ty| let ty_args = do vec::map(path.types) {|ty|
let sv_stmts = ser_ty(cx, tps, ty, cx.clone(s), #ast{ __v }); let sv_stmts = ser_ty(cx, tps, ty, cx.clone(s), #ast{ __v });
let sv = cx.expr(path.span, let sv = cx.expr(path.span,
ast::expr_block(cx.blk(path.span, sv_stmts))); ast::expr_block(cx.blk(path.span, sv_stmts)));
@ -316,12 +316,14 @@ fn ser_variant(cx: ext_ctxt,
bodyfn: fn(-@ast::expr, ast::blk) -> @ast::expr, bodyfn: fn(-@ast::expr, ast::blk) -> @ast::expr,
argfn: fn(-@ast::expr, uint, ast::blk) -> @ast::expr) argfn: fn(-@ast::expr, uint, ast::blk) -> @ast::expr)
-> ast::arm { -> ast::arm {
let vnames = vec::from_fn(vec::len(tys)) {|i| @#fmt["__v%u", i]}; let vnames = do vec::from_fn(vec::len(tys)) {|i|
let pats = vec::from_fn(vec::len(tys)) {|i| @#fmt["__v%u", i]
};
let pats = do vec::from_fn(vec::len(tys)) {|i|
cx.binder_pat(tys[i].span, vnames[i]) cx.binder_pat(tys[i].span, vnames[i])
}; };
let pat: @ast::pat = @{id: cx.next_id(), node: pfn(pats), span: span}; let pat: @ast::pat = @{id: cx.next_id(), node: pfn(pats), span: span};
let stmts = vec::from_fn(vec::len(tys)) {|i| let stmts = do vec::from_fn(vec::len(tys)) {|i|
let v = cx.var_ref(span, vnames[i]); let v = cx.var_ref(span, vnames[i]);
let arg_blk = let arg_blk =
cx.blk( cx.blk(
@ -374,7 +376,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
} }
ast::ty_rec(flds) { ast::ty_rec(flds) {
let fld_stmts = vec::from_fn(vec::len(flds)) {|fidx| let fld_stmts = do vec::from_fn(vec::len(flds)) {|fidx|
let fld = flds[fidx]; let fld = flds[fidx];
let vf = cx.expr(fld.span, let vf = cx.expr(fld.span,
ast::expr_field(cx.clone(v), ast::expr_field(cx.clone(v),
@ -516,7 +518,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident,
tp_inputs); tp_inputs);
let tps_map = map::str_hash(); let tps_map = map::str_hash();
vec::iter2(tps, tp_inputs) {|tp, arg| do vec::iter2(tps, tp_inputs) {|tp, arg|
let arg_ident = arg.ident; let arg_ident = arg.ident;
tps_map.insert( tps_map.insert(
*tp.ident, *tp.ident,
@ -537,7 +539,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident,
vec::append(~[{ident: @"__S", vec::append(~[{ident: @"__S",
id: cx.next_id(), id: cx.next_id(),
bounds: ser_bnds}], bounds: ser_bnds}],
vec::map(tps) {|tp| cx.clone_ty_param(tp) }); vec::map(tps, {|tp| cx.clone_ty_param(tp) }));
let ser_output: @ast::ty = @{id: cx.next_id(), let ser_output: @ast::ty = @{id: cx.next_id(),
node: ast::ty_nil, node: ast::ty_nil,
@ -573,7 +575,7 @@ fn deser_path(cx: ext_ctxt, tps: deser_tps_map, path: @ast::path,
ast::expr_path( ast::expr_path(
cx.helper_path(path, "deserialize"))); cx.helper_path(path, "deserialize")));
let ty_args = vec::map(path.types) {|ty| let ty_args = do vec::map(path.types) {|ty|
let dv_expr = deser_ty(cx, tps, ty, cx.clone(d)); let dv_expr = deser_ty(cx, tps, ty, cx.clone(d));
cx.lambda(cx.expr_blk(dv_expr)) cx.lambda(cx.expr_blk(dv_expr))
}; };
@ -616,7 +618,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map,
} }
ast::ty_rec(flds) { ast::ty_rec(flds) {
let fields = vec::from_fn(vec::len(flds)) {|fidx| let fields = do vec::from_fn(vec::len(flds)) {|fidx|
let fld = flds[fidx]; let fld = flds[fidx];
let d = cx.clone(d); let d = cx.clone(d);
let f = cx.lit_str(fld.span, fld.node.ident); let f = cx.lit_str(fld.span, fld.node.ident);
@ -645,7 +647,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map,
// d.read_tup_elt(2u, {||...})) // d.read_tup_elt(2u, {||...}))
// } // }
let arg_exprs = vec::from_fn(vec::len(tys)) {|i| let arg_exprs = do vec::from_fn(vec::len(tys)) {|i|
let idx = cx.lit_uint(ty.span, i); let idx = cx.lit_uint(ty.span, i);
let body = deser_lambda(cx, tps, tys[i], cx.clone(d)); let body = deser_lambda(cx, tps, tys[i], cx.clone(d));
#ast{ $(d).read_tup_elt($(idx), $(body)) } #ast{ $(d).read_tup_elt($(idx), $(body)) }
@ -723,7 +725,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span,
tp_inputs); tp_inputs);
let tps_map = map::str_hash(); let tps_map = map::str_hash();
vec::iter2(tps, tp_inputs) {|tp, arg| do vec::iter2(tps, tp_inputs) {|tp, arg|
let arg_ident = arg.ident; let arg_ident = arg.ident;
tps_map.insert( tps_map.insert(
*tp.ident, *tp.ident,
@ -743,12 +745,12 @@ fn mk_deser_fn(cx: ext_ctxt, span: span,
vec::append(~[{ident: @"__D", vec::append(~[{ident: @"__D",
id: cx.next_id(), id: cx.next_id(),
bounds: deser_bnds}], bounds: deser_bnds}],
vec::map(tps) {|tp| vec::map(tps, {|tp|
let cloned = cx.clone_ty_param(tp); let cloned = cx.clone_ty_param(tp);
{bounds: @(vec::append(*cloned.bounds, {bounds: @(vec::append(*cloned.bounds,
~[ast::bound_copy])) ~[ast::bound_copy]))
with cloned} with cloned}
}); }));
let deser_blk = cx.expr_blk(f(cx, tps_map, #ast(expr){__d})); let deser_blk = cx.expr_blk(f(cx, tps_map, #ast(expr){__d}));
@ -781,11 +783,11 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident,
e_span: span, variants: ~[ast::variant], e_span: span, variants: ~[ast::variant],
-s: @ast::expr, -v: @ast::expr) -> ~[@ast::stmt] { -s: @ast::expr, -v: @ast::expr) -> ~[@ast::stmt] {
let ext_cx = cx; let ext_cx = cx;
let arms = vec::from_fn(vec::len(variants)) {|vidx| let arms = do vec::from_fn(vec::len(variants)) {|vidx|
let variant = variants[vidx]; let variant = variants[vidx];
let v_span = variant.span; let v_span = variant.span;
let v_name = variant.node.name; let v_name = variant.node.name;
let variant_tys = vec::map(variant.node.args) {|a| a.ty }; let variant_tys = vec::map(variant.node.args, {|a| a.ty });
ser_variant( ser_variant(
cx, tps, variant_tys, v_span, cx.clone(s), cx, tps, variant_tys, v_span, cx.clone(s),
@ -830,13 +832,13 @@ fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident,
e_span: span, variants: ~[ast::variant], e_span: span, variants: ~[ast::variant],
-d: @ast::expr) -> @ast::expr { -d: @ast::expr) -> @ast::expr {
let ext_cx = cx; let ext_cx = cx;
let arms: ~[ast::arm] = vec::from_fn(vec::len(variants)) {|vidx| let arms: ~[ast::arm] = do vec::from_fn(vec::len(variants)) {|vidx|
let variant = variants[vidx]; let variant = variants[vidx];
let v_span = variant.span; let v_span = variant.span;
let v_name = variant.node.name; let v_name = variant.node.name;
let tys = vec::map(variant.node.args) {|a| a.ty }; let tys = vec::map(variant.node.args, {|a| a.ty });
let arg_exprs = vec::from_fn(vec::len(tys)) {|i| let arg_exprs = do vec::from_fn(vec::len(tys)) {|i|
let idx = cx.lit_uint(v_span, i); let idx = cx.lit_uint(v_span, i);
let body = deser_lambda(cx, tps, tys[i], cx.clone(d)); let body = deser_lambda(cx, tps, tys[i], cx.clone(d));
#ast{ $(d).read_enum_variant_arg($(idx), $(body)) } #ast{ $(d).read_enum_variant_arg($(idx), $(body)) }

View file

@ -100,8 +100,8 @@ fn expand_mod_items(exts: hashmap<str, syntax_extension>, cx: ext_ctxt,
// For each item, look through the attributes. If any of them are // For each item, look through the attributes. If any of them are
// decorated with "item decorators", then use that function to transform // decorated with "item decorators", then use that function to transform
// the item into a new set of items. // the item into a new set of items.
let new_items = vec::flat_map(module.items) {|item| let new_items = do vec::flat_map(module.items) {|item|
vec::foldr(item.attrs, ~[item]) {|attr, items| do vec::foldr(item.attrs, ~[item]) {|attr, items|
let mname = alt attr.node.value.node { let mname = alt attr.node.value.node {
ast::meta_word(n) { n } ast::meta_word(n) { n }
ast::meta_name_value(n, _) { n } ast::meta_name_value(n, _) { n }

View file

@ -106,7 +106,7 @@ fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt
node.visit(cx, mk_vt(v)); node.visit(cx, mk_vt(v));
// FIXME (#2250): Maybe this is an overkill (merge_sort), it might // FIXME (#2250): Maybe this is an overkill (merge_sort), it might
// be better to just keep the gather array in sorted order. // be better to just keep the gather array in sorted order.
cx.gather.swap { |v| do cx.gather.swap { |v|
vec::to_mut(std::sort::merge_sort({|a,b| a.lo < b.lo}, v)) vec::to_mut(std::sort::merge_sort({|a,b| a.lo < b.lo}, v))
}; };
ret cx; ret cx;
@ -132,7 +132,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span,
-> @ast::expr -> @ast::expr
{ {
let mut what = "expr"; let mut what = "expr";
option::iter(arg) {|arg| do option::iter(arg) {|arg|
let args: ~[@ast::expr] = let args: ~[@ast::expr] =
alt arg.node { alt arg.node {
ast::expr_vec(elts, _) { elts } ast::expr_vec(elts, _) { elts }
@ -205,7 +205,7 @@ fn finish<T: qq_helper>
let mut state = active; let mut state = active;
let mut i = 0u, j = 0u; let mut i = 0u, j = 0u;
let g_len = cx.gather.len(); let g_len = cx.gather.len();
str::chars_iter(*str) {|ch| do str::chars_iter(*str) {|ch|
if (j < g_len && i == cx.gather[j].lo) { if (j < g_len && i == cx.gather[j].lo) {
assert ch == '$'; assert ch == '$';
let repl = #fmt("$%u ", j); let repl = #fmt("$%u ", j);
@ -259,11 +259,11 @@ fn finish<T: qq_helper>
rcall = mk_call(cx,sp, rcall = mk_call(cx,sp,
~[@"syntax", @"ext", @"qquote", @"replace"], ~[@"syntax", @"ext", @"qquote", @"replace"],
~[pcall, ~[pcall,
mk_uniq_vec_e(cx,sp, qcx.gather.map_to_vec {|g| mk_uniq_vec_e(cx,sp, qcx.gather.map_to_vec({|g|
mk_call(cx,sp, mk_call(cx,sp,
~[@"syntax", @"ext", ~[@"syntax", @"ext",
@"qquote", @g.constr], @"qquote", @g.constr],
~[g.e])}), ~[g.e])})),
mk_path(cx,sp, mk_path(cx,sp,
~[@"syntax", @"ext", @"qquote", ~[@"syntax", @"ext", @"qquote",
@node.get_fold_fn()])]); @node.get_fold_fn()])]);

View file

@ -276,7 +276,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint],
let mut repeat: option<{rep_count: uint, name: ident}> = none; let mut repeat: option<{rep_count: uint, name: ident}> = none;
/* we need to walk over all the free vars in lockstep, except for /* we need to walk over all the free vars in lockstep, except for
the leaves, which are just duplicated */ the leaves, which are just duplicated */
free_vars(b, repeat_me) {|fv| do free_vars(b, repeat_me) {|fv|
let cur_pos = follow(b.get(fv), idx_path); let cur_pos = follow(b.get(fv), idx_path);
alt cur_pos { alt cur_pos {
leaf(_) { } leaf(_) { }

View file

@ -88,9 +88,9 @@ fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
alt io::read_whole_file(res_rel_file(cx, sp, file)) { alt io::read_whole_file(res_rel_file(cx, sp, file)) {
result::ok(src) { result::ok(src) {
let u8_exprs = vec::map(src) { |char: u8| let u8_exprs = vec::map(src, { |char: u8|
mk_lit(cx, sp, ast::lit_uint(char as u64, ast::ty_u8)) mk_lit(cx, sp, ast::lit_uint(char as u64, ast::ty_u8))
}; });
ret mk_uniq_vec_e(cx, sp, u8_exprs); ret mk_uniq_vec_e(cx, sp, u8_exprs);
} }
result::err(e) { result::err(e) {

View file

@ -255,7 +255,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
let ctor_body = fld.fold_block(ctor.node.body); let ctor_body = fld.fold_block(ctor.node.body);
let ctor_decl = fold_fn_decl(ctor.node.dec, fld); let ctor_decl = fold_fn_decl(ctor.node.dec, fld);
let ctor_id = fld.new_id(ctor.node.id); let ctor_id = fld.new_id(ctor.node.id);
let dtor = option::map(m_dtor) {|dtor| let dtor = do option::map(m_dtor) {|dtor|
let dtor_body = fld.fold_block(dtor.node.body); let dtor_body = fld.fold_block(dtor.node.body);
let dtor_id = fld.new_id(dtor.node.id); let dtor_id = fld.new_id(dtor.node.id);
{node: {body: dtor_body, {node: {body: dtor_body,
@ -273,7 +273,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
item_impl(tps, rp, ifce, ty, methods) { item_impl(tps, rp, ifce, ty, methods) {
item_impl(fold_ty_params(tps, fld), item_impl(fold_ty_params(tps, fld),
rp, rp,
ifce.map { |p| fold_iface_ref(p, fld) }, ifce.map({ |p| fold_iface_ref(p, fld) }),
fld.fold_ty(ty), fld.fold_ty(ty),
vec::map(methods, fld.fold_method)) vec::map(methods, fld.fold_method))
} }
@ -332,8 +332,8 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
} }
pat_lit(e) { pat_lit(fld.fold_expr(e)) } pat_lit(e) { pat_lit(fld.fold_expr(e)) }
pat_enum(pth, pats) { pat_enum(pth, pats) {
pat_enum(fld.fold_path(pth), option::map(pats) pat_enum(fld.fold_path(pth), option::map(pats,
{|pats| vec::map(pats, fld.fold_pat)}) {|pats| vec::map(pats, fld.fold_pat)}))
} }
pat_rec(fields, etc) { pat_rec(fields, etc) {
let mut fs = ~[]; let mut fs = ~[];
@ -490,9 +490,9 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
ty_vec(mt) {ty_vec(fold_mt(mt, fld))} ty_vec(mt) {ty_vec(fold_mt(mt, fld))}
ty_ptr(mt) {ty_ptr(fold_mt(mt, fld))} ty_ptr(mt) {ty_ptr(fold_mt(mt, fld))}
ty_rptr(region, mt) {ty_rptr(region, fold_mt(mt, fld))} ty_rptr(region, mt) {ty_rptr(region, fold_mt(mt, fld))}
ty_rec(fields) {ty_rec(vec::map(fields) {|f| fold_field(f, fld)})} ty_rec(fields) {ty_rec(vec::map(fields, {|f| fold_field(f, fld)}))}
ty_fn(proto, decl) {ty_fn(proto, fold_fn_decl(decl, fld))} ty_fn(proto, decl) {ty_fn(proto, fold_fn_decl(decl, fld))}
ty_tup(tys) {ty_tup(vec::map(tys) {|ty| fld.fold_ty(ty)})} ty_tup(tys) {ty_tup(vec::map(tys, {|ty| fld.fold_ty(ty)}))}
ty_path(path, id) {ty_path(fld.fold_path(path), fld.new_id(id))} ty_path(path, id) {ty_path(fld.fold_path(path), fld.new_id(id))}
ty_constr(ty, constrs) {ty_constr(fld.fold_ty(ty), ty_constr(ty, constrs) {ty_constr(fld.fold_ty(ty),
vec::map(constrs, fld.fold_ty_constr))} vec::map(constrs, fld.fold_ty_constr))}

View file

@ -159,7 +159,7 @@ class parser {
} }
fn parse_ty_fn_decl(purity: ast::purity) -> fn_decl { fn parse_ty_fn_decl(purity: ast::purity) -> fn_decl {
let inputs = self.parse_unspanned_seq( let inputs = do self.parse_unspanned_seq(
token::LPAREN, token::RPAREN, token::LPAREN, token::RPAREN,
seq_sep_trailing_disallowed(token::COMMA)) { |p| seq_sep_trailing_disallowed(token::COMMA)) { |p|
let mode = p.parse_arg_mode(); let mode = p.parse_arg_mode();
@ -186,7 +186,7 @@ class parser {
} }
fn parse_ty_methods() -> ~[ty_method] { fn parse_ty_methods() -> ~[ty_method] {
self.parse_unspanned_seq(token::LBRACE, token::RBRACE, do self.parse_unspanned_seq(token::LBRACE, token::RBRACE,
seq_sep_none()) { |p| seq_sep_none()) { |p|
let attrs = p.parse_outer_attributes(); let attrs = p.parse_outer_attributes();
let flo = p.span.lo; let flo = p.span.lo;
@ -494,11 +494,11 @@ class parser {
} }
fn parse_arg_or_capture_item() -> arg_or_capture_item { fn parse_arg_or_capture_item() -> arg_or_capture_item {
self.parse_capture_item_or() {|p| p.parse_arg() } self.parse_capture_item_or({|p| p.parse_arg() })
} }
fn parse_fn_block_arg() -> arg_or_capture_item { fn parse_fn_block_arg() -> arg_or_capture_item {
self.parse_capture_item_or() {|p| do self.parse_capture_item_or {|p|
let m = p.parse_arg_mode(); let m = p.parse_arg_mode();
let i = p.parse_value_ident(); let i = p.parse_value_ident();
let t = if p.eat(token::COLON) { let t = if p.eat(token::COLON) {
@ -2065,7 +2065,7 @@ class parser {
members(mms) { ms = vec::append(ms, mms); } members(mms) { ms = vec::append(ms, mms); }
} }
} }
let actual_dtor = option::map(the_dtor) {|dtor| let actual_dtor = do option::map(the_dtor) {|dtor|
let (d_body, d_s) = dtor; let (d_body, d_s) = dtor;
{node: {id: self.get_id(), {node: {id: self.get_id(),
self_id: self.get_id(), self_id: self.get_id(),

View file

@ -511,7 +511,7 @@ fn print_item(s: ps, &&item: @ast::item) {
print_fn_args_and_ret(s, ctor.node.dec, ~[]); print_fn_args_and_ret(s, ctor.node.dec, ~[]);
space(s.s); space(s.s);
print_block(s, ctor.node.body); print_block(s, ctor.node.body);
option::iter(m_dtor) {|dtor| do option::iter(m_dtor) {|dtor|
hardbreak_if_not_bol(s); hardbreak_if_not_bol(s);
maybe_print_comment(s, dtor.span.lo); maybe_print_comment(s, dtor.span.lo);
head(s, "drop"); head(s, "drop");
@ -1136,8 +1136,8 @@ fn print_decl(s: ps, decl: @ast::decl) {
word_nbsp(s, "let"); word_nbsp(s, "let");
// if any are mut, all are mut // if any are mut, all are mut
if vec::any(locs) {|l| l.node.is_mutbl } { if vec::any(locs, {|l| l.node.is_mutbl }) {
assert vec::all(locs) {|l| l.node.is_mutbl }; assert vec::all(locs, {|l| l.node.is_mutbl });
word_nbsp(s, "mut"); word_nbsp(s, "mut");
} }
@ -1405,7 +1405,7 @@ fn print_view_path(s: ps, &&vp: @ast::view_path) {
ast::view_path_list(path, idents, _) { ast::view_path_list(path, idents, _) {
print_path(s, path, false); print_path(s, path, false);
word(s.s, "::{"); word(s.s, "::{");
commasep(s, inconsistent, idents) {|s, w| do commasep(s, inconsistent, idents) {|s, w|
word(s.s, *w.node.name) word(s.s, *w.node.name)
} }
word(s.s, "}"); word(s.s, "}");

View file

@ -151,7 +151,7 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
for ifaces.each {|p| visit_path(p.path, e, v); } for ifaces.each {|p| visit_path(p.path, e, v); }
visit_class_ctor_helper(ctor, i.ident, tps, visit_class_ctor_helper(ctor, i.ident, tps,
ast_util::local_def(i.id), e, v); ast_util::local_def(i.id), e, v);
option::iter(m_dtor) {|dtor| do option::iter(m_dtor) {|dtor|
visit_class_dtor_helper(dtor, tps, visit_class_dtor_helper(dtor, tps,
ast_util::local_def(i.id), e, v)}; ast_util::local_def(i.id), e, v)};
} }
@ -227,7 +227,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
alt p.node { alt p.node {
pat_enum(path, children) { pat_enum(path, children) {
visit_path(path, e, v); visit_path(path, e, v);
option::iter(children) {|children| do option::iter(children) {|children|
for children.each {|child| v.visit_pat(child, e, v); }} for children.each {|child| v.visit_pat(child, e, v); }}
} }
pat_rec(fields, _) { pat_rec(fields, _) {
@ -239,7 +239,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
} }
pat_ident(path, inner) { pat_ident(path, inner) {
visit_path(path, e, v); visit_path(path, e, v);
option::iter(inner) {|subpat| v.visit_pat(subpat, e, v)}; do option::iter(inner) {|subpat| v.visit_pat(subpat, e, v)};
} }
pat_lit(ex) { v.visit_expr(ex, e, v); } pat_lit(ex) { v.visit_expr(ex, e, v); }
pat_range(e1, e2) { v.visit_expr(e1, e, v); v.visit_expr(e2, e, v); } pat_range(e1, e2) { v.visit_expr(e1, e, v); v.visit_expr(e2, e, v); }
@ -344,7 +344,7 @@ fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) {
fn visit_mac<E>(m: mac, e: E, v: vt<E>) { fn visit_mac<E>(m: mac, e: E, v: vt<E>) {
alt m.node { alt m.node {
ast::mac_invoc(pth, arg, body) { ast::mac_invoc(pth, arg, body) {
option::map(arg) {|arg| v.visit_expr(arg, e, v)}; } option::map(arg, {|arg| v.visit_expr(arg, e, v)}); }
ast::mac_invoc_tt(pth, tt) { /* no user-serviceable parts inside */ } ast::mac_invoc_tt(pth, tt) { /* no user-serviceable parts inside */ }
ast::mac_embed_type(ty) { v.visit_ty(ty, e, v); } ast::mac_embed_type(ty) { v.visit_ty(ty, e, v); }
ast::mac_embed_block(blk) { v.visit_block(blk, e, v); } ast::mac_embed_block(blk) { v.visit_block(blk, e, v); }

View file

@ -443,7 +443,7 @@ fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> str {
// gas doesn't! // gas doesn't!
fn sanitize(s: str) -> str { fn sanitize(s: str) -> str {
let mut result = ""; let mut result = "";
str::chars_iter(s) {|c| do str::chars_iter(s) {|c|
alt c { alt c {
'@' { result += "_sbox_"; } '@' { result += "_sbox_"; }
'~' { result += "_ubox_"; } '~' { result += "_ubox_"; }

View file

@ -322,7 +322,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input,
}; };
let is_expanded = upto != cu_parse; let is_expanded = upto != cu_parse;
let src = codemap::get_filemap(sess.codemap, source_name(input)).src; let src = codemap::get_filemap(sess.codemap, source_name(input)).src;
io::with_str_reader(*src) { |rdr| do io::with_str_reader(*src) { |rdr|
pprust::print_crate(sess.codemap, sess.span_diagnostic, crate, pprust::print_crate(sess.codemap, sess.span_diagnostic, crate,
source_name(input), source_name(input),
rdr, io::stdout(), ann, is_expanded); rdr, io::stdout(), ann, is_expanded);
@ -417,7 +417,7 @@ fn build_session_options(match: getopts::match,
let lint_flags = vec::append(getopts::opt_strs(match, "W"), let lint_flags = vec::append(getopts::opt_strs(match, "W"),
getopts::opt_strs(match, "warn")); getopts::opt_strs(match, "warn"));
let lint_dict = lint::get_lint_dict(); let lint_dict = lint::get_lint_dict();
let lint_opts = vec::map(lint_flags) {|flag| let lint_opts = do vec::map(lint_flags) {|flag|
alt lint::lookup_lint(lint_dict, flag) { alt lint::lookup_lint(lint_dict, flag) {
(flag, none) { (flag, none) {
early_error(demitter, #fmt("unknown warning: %s", flag)) early_error(demitter, #fmt("unknown warning: %s", flag))

View file

@ -211,7 +211,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) {
let p = comm::port(); let p = comm::port();
let ch = comm::chan(p); let ch = comm::chan(p);
alt task::try {|| alt do task::try {||
// The 'diagnostics emitter'. Every error, warning, etc. should // The 'diagnostics emitter'. Every error, warning, etc. should
// go through this function. // go through this function.
@ -259,7 +259,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) {
} }
fn main(args: ~[str]) { fn main(args: ~[str]) {
monitor {|demitter| do monitor {|demitter|
run_compiler(args, demitter); run_compiler(args, demitter);
} }
} }

View file

@ -13,7 +13,7 @@ type ctxt = @{
// Support conditional compilation by transforming the AST, stripping out // Support conditional compilation by transforming the AST, stripping out
// any items that do not belong in the current configuration // any items that do not belong in the current configuration
fn strip_unconfigured_items(crate: @ast::crate) -> @ast::crate { fn strip_unconfigured_items(crate: @ast::crate) -> @ast::crate {
strip_items(crate) {|attrs| do strip_items(crate) {|attrs|
in_cfg(crate.node.config, attrs) in_cfg(crate.node.config, attrs)
} }
} }

View file

@ -57,7 +57,7 @@ fn generate_test_harness(sess: session::session,
fn strip_test_functions(crate: @ast::crate) -> @ast::crate { fn strip_test_functions(crate: @ast::crate) -> @ast::crate {
// When not compiling with --test we should not compile the // When not compiling with --test we should not compile the
// #[test] functions // #[test] functions
config::strip_items(crate) {|attrs| do config::strip_items(crate) {|attrs|
!attr::contains_name(attr::attr_metas(attrs), "test") !attr::contains_name(attr::attr_metas(attrs), "test")
} }
} }

View file

@ -68,14 +68,14 @@ fn warn_if_multiple_versions(diag: span_handler,
if crate_cache.len() != 0u { if crate_cache.len() != 0u {
let name = loader::crate_name_from_metas(*crate_cache.last().metas); let name = loader::crate_name_from_metas(*crate_cache.last().metas);
let {lefts: matches, rights: non_matches} = let {lefts: matches, rights: non_matches} =
partition(crate_cache.map_to_vec {|entry| partition(crate_cache.map_to_vec({|entry|
let othername = loader::crate_name_from_metas(*entry.metas); let othername = loader::crate_name_from_metas(*entry.metas);
if name == othername { if name == othername {
left(entry) left(entry)
} else { } else {
right(entry) right(entry)
} }
}); }));
assert matches.is_not_empty(); assert matches.is_not_empty();

View file

@ -120,7 +120,7 @@ fn get_impls_for_mod(cstore: cstore::cstore, def: ast::def_id,
name: option<ast::ident>) name: option<ast::ident>)
-> @~[@decoder::_impl] { -> @~[@decoder::_impl] {
let cdata = cstore::get_crate_data(cstore, def.crate); let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::get_impls_for_mod(cdata, def.node, name) {|cnum| do decoder::get_impls_for_mod(cdata, def.node, name) {|cnum|
cstore::get_crate_data(cstore, cnum) cstore::get_crate_data(cstore, cnum)
} }
} }

View file

@ -96,7 +96,7 @@ fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> @str {
fn set_crate_data(cstore: cstore, cnum: ast::crate_num, fn set_crate_data(cstore: cstore, cnum: ast::crate_num,
data: crate_metadata) { data: crate_metadata) {
p(cstore).metas.insert(cnum, data); p(cstore).metas.insert(cnum, data);
vec::iter(decoder::get_crate_module_paths(data.data)) {|dp| do vec::iter(decoder::get_crate_module_paths(data.data)) {|dp|
let (did, path) = dp; let (did, path) = dp;
let d = {crate: cnum, node: did.node}; let d = {crate: cnum, node: did.node};
p(cstore).mod_path_map.insert(d, @path); p(cstore).mod_path_map.insert(d, @path);

View file

@ -64,7 +64,7 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn@(~[u8]) -> bool, hash: uint) ->
let mut result: ~[ebml::doc] = ~[]; let mut result: ~[ebml::doc] = ~[];
let belt = tag_index_buckets_bucket_elt; let belt = tag_index_buckets_bucket_elt;
ebml::tagged_docs(bucket, belt) {|elt| do ebml::tagged_docs(bucket, belt) {|elt|
let pos = io::u64_from_be_bytes(*elt.data, elt.start, 4u) as uint; let pos = io::u64_from_be_bytes(*elt.data, elt.start, 4u) as uint;
if eq_fn(vec::slice::<u8>(*elt.data, elt.start + 4u, elt.end)) { if eq_fn(vec::slice::<u8>(*elt.data, elt.start + 4u, elt.end)) {
vec::push(result, ebml::doc_at(d.data, pos).doc); vec::push(result, ebml::doc_at(d.data, pos).doc);
@ -110,7 +110,7 @@ fn item_symbol(item: ebml::doc) -> str {
fn item_parent_item(d: ebml::doc) -> option<ast::def_id> { fn item_parent_item(d: ebml::doc) -> option<ast::def_id> {
let mut found = none; let mut found = none;
ebml::tagged_docs(d, tag_items_data_parent_item) {|did| do ebml::tagged_docs(d, tag_items_data_parent_item) {|did|
found = some(parse_def_id(ebml::doc_data(did))); found = some(parse_def_id(ebml::doc_data(did)));
} }
found found
@ -134,7 +134,7 @@ fn field_mutability(d: ebml::doc) -> ast::class_mutability {
} }
fn variant_disr_val(d: ebml::doc) -> option<int> { fn variant_disr_val(d: ebml::doc) -> option<int> {
option::chain(ebml::maybe_get_doc(d, tag_disr_val)) {|val_doc| do option::chain(ebml::maybe_get_doc(d, tag_disr_val)) {|val_doc|
int::parse_buf(ebml::doc_data(val_doc), 10u) int::parse_buf(ebml::doc_data(val_doc), 10u)
} }
} }
@ -157,7 +157,7 @@ fn item_type(item_id: ast::def_id, item: ebml::doc,
fn item_impl_iface(item: ebml::doc, tcx: ty::ctxt, cdata: cmd) fn item_impl_iface(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
-> option<ty::t> { -> option<ty::t> {
let mut result = none; let mut result = none;
ebml::tagged_docs(item, tag_impl_iface) {|ity| do ebml::tagged_docs(item, tag_impl_iface) {|ity|
result = some(doc_type(ity, tcx, cdata)); result = some(doc_type(ity, tcx, cdata));
}; };
result result
@ -166,7 +166,7 @@ fn item_impl_iface(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
fn item_ty_param_bounds(item: ebml::doc, tcx: ty::ctxt, cdata: cmd) fn item_ty_param_bounds(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
-> @~[ty::param_bounds] { -> @~[ty::param_bounds] {
let mut bounds = ~[]; let mut bounds = ~[];
ebml::tagged_docs(item, tag_items_data_item_ty_param_bounds) {|p| do ebml::tagged_docs(item, tag_items_data_item_ty_param_bounds) {|p|
let bd = parse_bounds_data(p.data, p.start, cdata.cnum, tcx, {|did| let bd = parse_bounds_data(p.data, p.start, cdata.cnum, tcx, {|did|
translate_def_id(cdata, did) translate_def_id(cdata, did)
}); });
@ -197,7 +197,7 @@ fn item_ty_param_count(item: ebml::doc) -> uint {
fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> ~[ast::def_id] { fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> ~[ast::def_id] {
let mut ids: ~[ast::def_id] = ~[]; let mut ids: ~[ast::def_id] = ~[];
let v = tag_items_data_item_variant; let v = tag_items_data_item_variant;
ebml::tagged_docs(item, v) {|p| do ebml::tagged_docs(item, v) {|p|
let ext = parse_def_id(ebml::doc_data(p)); let ext = parse_def_id(ebml::doc_data(p));
vec::push(ids, {crate: cdata.cnum, node: ext.node}); vec::push(ids, {crate: cdata.cnum, node: ext.node});
}; };
@ -232,7 +232,7 @@ fn item_path(item_doc: ebml::doc) -> ast_map::path {
let mut result = ~[]; let mut result = ~[];
vec::reserve(result, len); vec::reserve(result, len);
ebml::docs(path_doc) {|tag, elt_doc| do ebml::docs(path_doc) {|tag, elt_doc|
if tag == tag_path_elt_mod { if tag == tag_path_elt_mod {
let str = ebml::doc_as_str(elt_doc); let str = ebml::doc_as_str(elt_doc);
vec::push(result, ast_map::path_mod(@str)); vec::push(result, ast_map::path_mod(@str));
@ -306,7 +306,7 @@ fn get_impl_method(cdata: cmd, id: ast::node_id,
name: ast::ident) -> ast::def_id { name: ast::ident) -> ast::def_id {
let items = ebml::get_doc(ebml::doc(cdata.data), tag_items); let items = ebml::get_doc(ebml::doc(cdata.data), tag_items);
let mut found = none; let mut found = none;
ebml::tagged_docs(find_item(id, items), tag_item_impl_method) {|mid| do ebml::tagged_docs(find_item(id, items), tag_item_impl_method) {|mid|
let m_did = parse_def_id(ebml::doc_data(mid)); let m_did = parse_def_id(ebml::doc_data(mid));
if item_name(find_item(m_did.node, items)) == name { if item_name(find_item(m_did.node, items)) == name {
found = some(translate_def_id(cdata, m_did)); found = some(translate_def_id(cdata, m_did));
@ -323,7 +323,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id,
some(it) { it } some(it) { it }
none { fail (#fmt("get_class_method: class id not found \ none { fail (#fmt("get_class_method: class id not found \
when looking up method %s", *name)) }}; when looking up method %s", *name)) }};
ebml::tagged_docs(cls_items, tag_item_iface_method) {|mid| do ebml::tagged_docs(cls_items, tag_item_iface_method) {|mid|
let m_did = class_member_id(mid, cdata); let m_did = class_member_id(mid, cdata);
if item_name(mid) == name { if item_name(mid) == name {
found = some(m_did); found = some(m_did);
@ -343,7 +343,7 @@ fn class_dtor(cdata: cmd, id: ast::node_id) -> option<ast::def_id> {
none { fail (#fmt("class_dtor: class id not found \ none { fail (#fmt("class_dtor: class id not found \
when looking up dtor for %d", id)); } when looking up dtor for %d", id)); }
}; };
ebml::tagged_docs(cls_items, tag_item_dtor) {|doc| do ebml::tagged_docs(cls_items, tag_item_dtor) {|doc|
let doc1 = ebml::get_doc(doc, tag_def_id); let doc1 = ebml::get_doc(doc, tag_def_id);
let did = parse_def_id(ebml::doc_data(doc1)); let did = parse_def_id(ebml::doc_data(doc1));
found = some(translate_def_id(cdata, did)); found = some(translate_def_id(cdata, did));
@ -429,7 +429,7 @@ type _impl = {did: ast::def_id, ident: ast::ident, methods: ~[@method_info]};
fn item_impl_methods(cdata: cmd, item: ebml::doc, base_tps: uint) fn item_impl_methods(cdata: cmd, item: ebml::doc, base_tps: uint)
-> ~[@method_info] { -> ~[@method_info] {
let mut rslt = ~[]; let mut rslt = ~[];
ebml::tagged_docs(item, tag_item_impl_method) {|doc| do ebml::tagged_docs(item, tag_item_impl_method) {|doc|
let m_did = parse_def_id(ebml::doc_data(doc)); let m_did = parse_def_id(ebml::doc_data(doc));
let mth_item = lookup_item(m_did.node, cdata.data); let mth_item = lookup_item(m_did.node, cdata.data);
vec::push(rslt, @{did: translate_def_id(cdata, m_did), vec::push(rslt, @{did: translate_def_id(cdata, m_did),
@ -447,7 +447,7 @@ fn get_impls_for_mod(cdata: cmd, m_id: ast::node_id,
let data = cdata.data; let data = cdata.data;
let mod_item = lookup_item(m_id, data); let mod_item = lookup_item(m_id, data);
let mut result = ~[]; let mut result = ~[];
ebml::tagged_docs(mod_item, tag_mod_impl) {|doc| do ebml::tagged_docs(mod_item, tag_mod_impl) {|doc|
let did = parse_def_id(ebml::doc_data(doc)); let did = parse_def_id(ebml::doc_data(doc));
let local_did = translate_def_id(cdata, did); let local_did = translate_def_id(cdata, did);
// The impl may be defined in a different crate. Ask the caller // The impl may be defined in a different crate. Ask the caller
@ -473,7 +473,7 @@ fn get_iface_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
let data = cdata.data; let data = cdata.data;
let item = lookup_item(id, data); let item = lookup_item(id, data);
let mut result = ~[]; let mut result = ~[];
ebml::tagged_docs(item, tag_item_iface_method) {|mth| do ebml::tagged_docs(item, tag_item_iface_method) {|mth|
let bounds = item_ty_param_bounds(mth, tcx, cdata); let bounds = item_ty_param_bounds(mth, tcx, cdata);
let name = item_name(mth); let name = item_name(mth);
let ty = doc_type(mth, tcx, cdata); let ty = doc_type(mth, tcx, cdata);
@ -498,7 +498,7 @@ fn get_class_members(cdata: cmd, id: ast::node_id,
let data = cdata.data; let data = cdata.data;
let item = lookup_item(id, data); let item = lookup_item(id, data);
let mut result = ~[]; let mut result = ~[];
ebml::tagged_docs(item, tag_item_field) {|an_item| do ebml::tagged_docs(item, tag_item_field) {|an_item|
let f = item_family(an_item); let f = item_family(an_item);
if p(f) { if p(f) {
let name = item_name(an_item); let name = item_name(an_item);
@ -578,12 +578,12 @@ fn item_family_to_str(fam: char) -> str {
fn get_meta_items(md: ebml::doc) -> ~[@ast::meta_item] { fn get_meta_items(md: ebml::doc) -> ~[@ast::meta_item] {
let mut items: ~[@ast::meta_item] = ~[]; let mut items: ~[@ast::meta_item] = ~[];
ebml::tagged_docs(md, tag_meta_item_word) {|meta_item_doc| do ebml::tagged_docs(md, tag_meta_item_word) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
let n = str::from_bytes(ebml::doc_data(nd)); let n = str::from_bytes(ebml::doc_data(nd));
vec::push(items, attr::mk_word_item(@n)); vec::push(items, attr::mk_word_item(@n));
}; };
ebml::tagged_docs(md, tag_meta_item_name_value) {|meta_item_doc| do ebml::tagged_docs(md, tag_meta_item_name_value) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
let vd = ebml::get_doc(meta_item_doc, tag_meta_item_value); let vd = ebml::get_doc(meta_item_doc, tag_meta_item_value);
let n = str::from_bytes(ebml::doc_data(nd)); let n = str::from_bytes(ebml::doc_data(nd));
@ -592,7 +592,7 @@ fn get_meta_items(md: ebml::doc) -> ~[@ast::meta_item] {
// but currently the encoder just drops them // but currently the encoder just drops them
vec::push(items, attr::mk_name_value_item_str(@n, v)); vec::push(items, attr::mk_name_value_item_str(@n, v));
}; };
ebml::tagged_docs(md, tag_meta_item_list) {|meta_item_doc| do ebml::tagged_docs(md, tag_meta_item_list) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name); let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
let n = str::from_bytes(ebml::doc_data(nd)); let n = str::from_bytes(ebml::doc_data(nd));
let subitems = get_meta_items(meta_item_doc); let subitems = get_meta_items(meta_item_doc);
@ -605,7 +605,7 @@ fn get_attributes(md: ebml::doc) -> ~[ast::attribute] {
let mut attrs: ~[ast::attribute] = ~[]; let mut attrs: ~[ast::attribute] = ~[];
alt ebml::maybe_get_doc(md, tag_attributes) { alt ebml::maybe_get_doc(md, tag_attributes) {
option::some(attrs_d) { option::some(attrs_d) {
ebml::tagged_docs(attrs_d, tag_attribute) {|attr_doc| do ebml::tagged_docs(attrs_d, tag_attribute) {|attr_doc|
let meta_items = get_meta_items(attr_doc); let meta_items = get_meta_items(attr_doc);
// Currently it's only possible to have a single meta item on // Currently it's only possible to have a single meta item on
// an attribute // an attribute
@ -652,7 +652,7 @@ fn get_crate_deps(data: @~[u8]) -> ~[crate_dep] {
fn docstr(doc: ebml::doc, tag_: uint) -> str { fn docstr(doc: ebml::doc, tag_: uint) -> str {
str::from_bytes(ebml::doc_data(ebml::get_doc(doc, tag_))) str::from_bytes(ebml::doc_data(ebml::get_doc(doc, tag_)))
} }
ebml::tagged_docs(depsdoc, tag_crate_dep) {|depdoc| do ebml::tagged_docs(depsdoc, tag_crate_dep) {|depdoc|
vec::push(deps, {cnum: crate_num, vec::push(deps, {cnum: crate_num,
name: @docstr(depdoc, tag_crate_dep_name), name: @docstr(depdoc, tag_crate_dep_name),
vers: @docstr(depdoc, tag_crate_dep_vers), vers: @docstr(depdoc, tag_crate_dep_vers),
@ -691,7 +691,7 @@ fn get_crate_vers(data: @~[u8]) -> @str {
fn list_crate_items(bytes: @~[u8], md: ebml::doc, out: io::writer) { fn list_crate_items(bytes: @~[u8], md: ebml::doc, out: io::writer) {
out.write_str("=Items=\n"); out.write_str("=Items=\n");
let items = ebml::get_doc(md, tag_items); let items = ebml::get_doc(md, tag_items);
iter_crate_items(bytes) {|path, did| do iter_crate_items(bytes) {|path, did|
out.write_str(#fmt["%s (%s)\n", path, describe_def(items, did)]); out.write_str(#fmt["%s (%s)\n", path, describe_def(items, did)]);
} }
out.write_str("\n"); out.write_str("\n");
@ -702,9 +702,9 @@ fn iter_crate_items(bytes: @~[u8], proc: fn(str, ast::def_id)) {
let paths = ebml::get_doc(md, tag_paths); let paths = ebml::get_doc(md, tag_paths);
let index = ebml::get_doc(paths, tag_index); let index = ebml::get_doc(paths, tag_index);
let bs = ebml::get_doc(index, tag_index_buckets); let bs = ebml::get_doc(index, tag_index_buckets);
ebml::tagged_docs(bs, tag_index_buckets_bucket) {|bucket| do ebml::tagged_docs(bs, tag_index_buckets_bucket) {|bucket|
let et = tag_index_buckets_bucket_elt; let et = tag_index_buckets_bucket_elt;
ebml::tagged_docs(bucket, et) {|elt| do ebml::tagged_docs(bucket, et) {|elt|
let data = read_path(elt); let data = read_path(elt);
let {tag:_, doc:def} = ebml::doc_at(bytes, data.pos); let {tag:_, doc:def} = ebml::doc_at(bytes, data.pos);
let did_doc = ebml::get_doc(def, tag_def_id); let did_doc = ebml::get_doc(def, tag_def_id);
@ -723,7 +723,7 @@ fn get_crate_module_paths(bytes: @~[u8]) -> ~[(ast::def_id, str)] {
// fowarded path due to renamed import or reexport // fowarded path due to renamed import or reexport
let mut res = ~[]; let mut res = ~[];
let mods = map::str_hash(); let mods = map::str_hash();
iter_crate_items(bytes) {|path, did| do iter_crate_items(bytes) {|path, did|
let m = mod_of_path(path); let m = mod_of_path(path);
if str::is_not_empty(m) { if str::is_not_empty(m) {
// if m has a sub-item, it must be a module // if m has a sub-item, it must be a module
@ -734,7 +734,7 @@ fn get_crate_module_paths(bytes: @~[u8]) -> ~[(ast::def_id, str)] {
// unified later by using the mods map // unified later by using the mods map
vec::push(res, (did, path)); vec::push(res, (did, path));
} }
ret vec::filter(res) {|x| ret do vec::filter(res) {|x|
let (_, xp) = x; let (_, xp) = x;
mods.contains_key(xp) mods.contains_key(xp)
} }

View file

@ -87,20 +87,20 @@ fn encode_name_and_def_id(ebml_w: ebml::writer, nm: ident,
} }
fn encode_region_param(ebml_w: ebml::writer, rp: region_param) { fn encode_region_param(ebml_w: ebml::writer, rp: region_param) {
ebml_w.wr_tag(tag_region_param) {|| do ebml_w.wr_tag(tag_region_param) {||
serialize_region_param(ebml_w, rp) serialize_region_param(ebml_w, rp)
} }
} }
fn encode_named_def_id(ebml_w: ebml::writer, name: ident, id: def_id) { fn encode_named_def_id(ebml_w: ebml::writer, name: ident, id: def_id) {
ebml_w.wr_tag(tag_paths_data_item) {|| do ebml_w.wr_tag(tag_paths_data_item) {||
encode_name(ebml_w, name); encode_name(ebml_w, name);
encode_def_id(ebml_w, id); encode_def_id(ebml_w, id);
} }
} }
fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) { fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) {
ebml_w.wr_tag(tag_class_mut) {|| do ebml_w.wr_tag(tag_class_mut) {||
ebml_w.writer.write(&[alt mt { class_immutable { 'i' } ebml_w.writer.write(&[alt mt { class_immutable { 'i' }
class_mutable { 'm' } } as u8]); class_mutable { 'm' } } as u8]);
} }
@ -112,7 +112,7 @@ fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: ~[variant],
path: ~[ident], &index: ~[entry<str>]) { path: ~[ident], &index: ~[entry<str>]) {
for variants.each {|variant| for variants.each {|variant|
add_to_index(ebml_w, path, index, variant.node.name); add_to_index(ebml_w, path, index, variant.node.name);
ebml_w.wr_tag(tag_paths_data_item) {|| do ebml_w.wr_tag(tag_paths_data_item) {||
encode_name(ebml_w, variant.node.name); encode_name(ebml_w, variant.node.name);
encode_def_id(ebml_w, local_def(variant.node.id)); encode_def_id(ebml_w, local_def(variant.node.id));
} }
@ -170,7 +170,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
encode_named_def_id(ebml_w, it.ident, local_def(it.id)); encode_named_def_id(ebml_w, it.ident, local_def(it.id));
} }
item_mod(_mod) { item_mod(_mod) {
ebml_w.wr_tag(tag_paths_data_mod) {|| do ebml_w.wr_tag(tag_paths_data_mod) {||
encode_name_and_def_id(ebml_w, it.ident, it.id); encode_name_and_def_id(ebml_w, it.ident, it.id);
encode_module_item_paths(ebml_w, ecx, _mod, encode_module_item_paths(ebml_w, ecx, _mod,
vec::append_one(path, it.ident), vec::append_one(path, it.ident),
@ -178,7 +178,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
} }
} }
item_foreign_mod(nmod) { item_foreign_mod(nmod) {
ebml_w.wr_tag(tag_paths_data_mod) {|| do ebml_w.wr_tag(tag_paths_data_mod) {||
encode_name_and_def_id(ebml_w, it.ident, it.id); encode_name_and_def_id(ebml_w, it.ident, it.id);
encode_foreign_module_item_paths( encode_foreign_module_item_paths(
ebml_w, nmod, ebml_w, nmod,
@ -186,15 +186,15 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
} }
} }
item_ty(_, tps, _) { item_ty(_, tps, _) {
ebml_w.wr_tag(tag_paths_data_item) {|| do ebml_w.wr_tag(tag_paths_data_item) {||
encode_name_and_def_id(ebml_w, it.ident, it.id); encode_name_and_def_id(ebml_w, it.ident, it.id);
} }
} }
item_class(_, _, items, ctor, m_dtor, _) { item_class(_, _, items, ctor, m_dtor, _) {
ebml_w.wr_tag(tag_paths_data_item) {|| do ebml_w.wr_tag(tag_paths_data_item) {||
encode_name_and_def_id(ebml_w, it.ident, it.id); encode_name_and_def_id(ebml_w, it.ident, it.id);
} }
ebml_w.wr_tag(tag_paths) {|| do ebml_w.wr_tag(tag_paths) {||
// We add the same ident twice: for the // We add the same ident twice: for the
// class and for its ctor // class and for its ctor
add_to_index(ebml_w, path, index, it.ident); add_to_index(ebml_w, path, index, it.ident);
@ -206,13 +206,13 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
} }
} }
item_enum(variants, _, _) { item_enum(variants, _, _) {
ebml_w.wr_tag(tag_paths_data_item) {|| do ebml_w.wr_tag(tag_paths_data_item) {||
encode_name_and_def_id(ebml_w, it.ident, it.id); encode_name_and_def_id(ebml_w, it.ident, it.id);
} }
encode_enum_variant_paths(ebml_w, variants, path, index); encode_enum_variant_paths(ebml_w, variants, path, index);
} }
item_iface(*) { item_iface(*) {
ebml_w.wr_tag(tag_paths_data_item) {|| do ebml_w.wr_tag(tag_paths_data_item) {||
encode_name_and_def_id(ebml_w, it.ident, it.id); encode_name_and_def_id(ebml_w, it.ident, it.id);
} }
} }
@ -372,9 +372,9 @@ fn encode_path(ebml_w: ebml::writer,
ebml_w.wr_tagged_str(tag, *name); ebml_w.wr_tagged_str(tag, *name);
} }
ebml_w.wr_tag(tag_path) {|| do ebml_w.wr_tag(tag_path) {||
ebml_w.wr_tagged_u32(tag_path_len, (vec::len(path) + 1u) as u32); ebml_w.wr_tagged_u32(tag_path_len, (vec::len(path) + 1u) as u32);
vec::iter(path) {|pe| encode_path_elt(ebml_w, pe); } do vec::iter(path) {|pe| encode_path_elt(ebml_w, pe); }
encode_path_elt(ebml_w, name); encode_path_elt(ebml_w, name);
} }
} }
@ -602,7 +602,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
} }
item_enum(variants, tps, rp) { item_enum(variants, tps, rp) {
add_to_index(); add_to_index();
ebml_w.wr_tag(tag_items_data_item) {|| do ebml_w.wr_tag(tag_items_data_item) {||
encode_def_id(ebml_w, local_def(item.id)); encode_def_id(ebml_w, local_def(item.id));
encode_family(ebml_w, 't'); encode_family(ebml_w, 't');
encode_type_param_bounds(ebml_w, ecx, tps); encode_type_param_bounds(ebml_w, ecx, tps);
@ -626,7 +626,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
let idx = encode_info_for_class(ecx, ebml_w, item.id, path, tps, let idx = encode_info_for_class(ecx, ebml_w, item.id, path, tps,
items, index); items, index);
/* Encode the dtor */ /* Encode the dtor */
option::iter(m_dtor) {|dtor| do option::iter(m_dtor) {|dtor|
vec::push(*index, {val: dtor.node.id, pos: ebml_w.writer.tell()}); vec::push(*index, {val: dtor.node.id, pos: ebml_w.writer.tell()});
encode_info_for_fn(ecx, ebml_w, dtor.node.id, @(*item.ident encode_info_for_fn(ecx, ebml_w, dtor.node.id, @(*item.ident
+ "_dtor"), path, if tps.len() > 0u { + "_dtor"), path, if tps.len() > 0u {
@ -651,8 +651,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
} }
/* Encode the dtor */ /* Encode the dtor */
/* Encode id for dtor */ /* Encode id for dtor */
option::iter(m_dtor) {|dtor| do option::iter(m_dtor) {|dtor|
ebml_w.wr_tag(tag_item_dtor) {|| do ebml_w.wr_tag(tag_item_dtor) {||
encode_def_id(ebml_w, local_def(dtor.node.id)); encode_def_id(ebml_w, local_def(dtor.node.id));
} }
}; };
@ -708,7 +708,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
ebml_w.writer.write(str::bytes(def_to_str(local_def(m.id)))); ebml_w.writer.write(str::bytes(def_to_str(local_def(m.id))));
ebml_w.end_tag(); ebml_w.end_tag();
} }
option::iter(ifce) {|t| do option::iter(ifce) {|t|
encode_iface_ref(ebml_w, ecx, t) encode_iface_ref(ebml_w, ecx, t)
}; };
encode_path(ebml_w, path, ast_map::path_name(item.ident)); encode_path(ebml_w, path, ast_map::path_name(item.ident));
@ -977,7 +977,7 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
// Pull the cnums and name,vers,hash out of cstore // Pull the cnums and name,vers,hash out of cstore
let mut deps: ~[mut numdep] = ~[mut]; let mut deps: ~[mut numdep] = ~[mut];
cstore::iter_crate_data(cstore) {|key, val| do cstore::iter_crate_data(cstore) {|key, val|
let dep = {cnum: key, name: @val.name, let dep = {cnum: key, name: @val.name,
vers: decoder::get_crate_vers(val.data), vers: decoder::get_crate_vers(val.data),
hash: decoder::get_crate_hash(val.data)}; hash: decoder::get_crate_hash(val.data)};

View file

@ -134,7 +134,7 @@ fn get_cargo_root() -> result<path, str> {
} }
fn get_cargo_root_nearest() -> result<path, str> { fn get_cargo_root_nearest() -> result<path, str> {
result::chain(get_cargo_root()) { |p| do result::chain(get_cargo_root()) { |p|
let cwd = os::getcwd(); let cwd = os::getcwd();
let mut dirname = path::dirname(cwd); let mut dirname = path::dirname(cwd);
let mut dirpath = path::split(dirname); let mut dirpath = path::split(dirname);
@ -158,13 +158,13 @@ fn get_cargo_root_nearest() -> result<path, str> {
} }
fn get_cargo_lib_path() -> result<path, str> { fn get_cargo_lib_path() -> result<path, str> {
result::chain(get_cargo_root()) { |p| do result::chain(get_cargo_root()) { |p|
result::ok(path::connect(p, libdir())) result::ok(path::connect(p, libdir()))
} }
} }
fn get_cargo_lib_path_nearest() -> result<path, str> { fn get_cargo_lib_path_nearest() -> result<path, str> {
result::chain(get_cargo_root_nearest()) { |p| do result::chain(get_cargo_root_nearest()) { |p|
result::ok(path::connect(p, libdir())) result::ok(path::connect(p, libdir()))
} }
} }

View file

@ -192,9 +192,9 @@ fn parse_vstore(st: @pstate) -> ty::vstore {
} }
fn parse_substs(st: @pstate, conv: conv_did) -> ty::substs { fn parse_substs(st: @pstate, conv: conv_did) -> ty::substs {
let self_r = parse_opt(st) {|| parse_region(st) }; let self_r = parse_opt(st, {|| parse_region(st) });
let self_ty = parse_opt(st) {|| parse_ty(st, conv) }; let self_ty = parse_opt(st, {|| parse_ty(st, conv) });
assert next(st) == '['; assert next(st) == '[';
let mut params: [ty::t]/~ = []/~; let mut params: [ty::t]/~ = []/~;

View file

@ -115,8 +115,8 @@ fn enc_opt<T>(w: io::writer, t: option<T>, enc_f: fn(T)) {
} }
fn enc_substs(w: io::writer, cx: @ctxt, substs: ty::substs) { fn enc_substs(w: io::writer, cx: @ctxt, substs: ty::substs) {
enc_opt(w, substs.self_r) { |r| enc_region(w, cx, r) } do enc_opt(w, substs.self_r) { |r| enc_region(w, cx, r) }
enc_opt(w, substs.self_ty) { |t| enc_ty(w, cx, t) } do enc_opt(w, substs.self_ty) { |t| enc_ty(w, cx, t) }
w.write_char('['); w.write_char('[');
for substs.tps.each { |t| enc_ty(w, cx, t); } for substs.tps.each { |t| enc_ty(w, cx, t); }
w.write_char(']'); w.write_char(']');

View file

@ -87,7 +87,7 @@ fn encode_inlined_item(ecx: @e::encode_ctxt,
ebml_w.writer.tell()]; ebml_w.writer.tell()];
let id_range = ast_util::compute_id_range_for_inlined_item(ii); let id_range = ast_util::compute_id_range_for_inlined_item(ii);
ebml_w.wr_tag(c::tag_ast as uint) {|| do ebml_w.wr_tag(c::tag_ast as uint) {||
ast_util::serialize_id_range(ebml_w, id_range); ast_util::serialize_id_range(ebml_w, id_range);
encode_ast(ebml_w, simplify_ast(ii)); encode_ast(ebml_w, simplify_ast(ii));
encode_side_tables_for_ii(ecx, maps, ebml_w, ii); encode_side_tables_for_ii(ecx, maps, ebml_w, ii);
@ -210,7 +210,7 @@ impl deserializer_helpers<D: deserializer> for D {
// but eventually we should add entries to the local codemap as required. // but eventually we should add entries to the local codemap as required.
fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) { fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) {
ebml_w.wr_tag(c::tag_tree as uint) {|| do ebml_w.wr_tag(c::tag_tree as uint) {||
ast::serialize_inlined_item(ebml_w, item) ast::serialize_inlined_item(ebml_w, item)
} }
} }
@ -227,7 +227,7 @@ fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) {
// inlined items. // inlined items.
fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item { fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ { fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
let stmts_sans_items = vec::filter(blk.stmts) {|stmt| let stmts_sans_items = do vec::filter(blk.stmts) {|stmt|
alt stmt.node { alt stmt.node {
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) | ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
ast::stmt_decl(@{node: ast::decl_local(_), span: _}, _) { true } ast::stmt_decl(@{node: ast::decl_local(_), span: _}, _) { true }
@ -425,7 +425,7 @@ fn encode_vtable_res(ecx: @e::encode_ctxt,
// ty::t doesn't work, and there is no way (atm) to have // ty::t doesn't work, and there is no way (atm) to have
// hand-written serialization routines combine with auto-generated // hand-written serialization routines combine with auto-generated
// ones. perhaps we should fix this. // ones. perhaps we should fix this.
ebml_w.emit_from_vec(*dr) {|vtable_origin| do ebml_w.emit_from_vec(*dr) {|vtable_origin|
encode_vtable_origin(ecx, ebml_w, vtable_origin) encode_vtable_origin(ecx, ebml_w, vtable_origin)
} }
} }
@ -433,37 +433,37 @@ fn encode_vtable_res(ecx: @e::encode_ctxt,
fn encode_vtable_origin(ecx: @e::encode_ctxt, fn encode_vtable_origin(ecx: @e::encode_ctxt,
ebml_w: ebml::writer, ebml_w: ebml::writer,
vtable_origin: typeck::vtable_origin) { vtable_origin: typeck::vtable_origin) {
ebml_w.emit_enum("vtable_origin") {|| do ebml_w.emit_enum("vtable_origin") {||
alt vtable_origin { alt vtable_origin {
typeck::vtable_static(def_id, tys, vtable_res) { typeck::vtable_static(def_id, tys, vtable_res) {
ebml_w.emit_enum_variant("vtable_static", 0u, 3u) {|| do ebml_w.emit_enum_variant("vtable_static", 0u, 3u) {||
ebml_w.emit_enum_variant_arg(0u) {|| do ebml_w.emit_enum_variant_arg(0u) {||
ebml_w.emit_def_id(def_id) ebml_w.emit_def_id(def_id)
} }
ebml_w.emit_enum_variant_arg(1u) {|| do ebml_w.emit_enum_variant_arg(1u) {||
ebml_w.emit_tys(ecx, tys); ebml_w.emit_tys(ecx, tys);
} }
ebml_w.emit_enum_variant_arg(2u) {|| do ebml_w.emit_enum_variant_arg(2u) {||
encode_vtable_res(ecx, ebml_w, vtable_res); encode_vtable_res(ecx, ebml_w, vtable_res);
} }
} }
} }
typeck::vtable_param(pn, bn) { typeck::vtable_param(pn, bn) {
ebml_w.emit_enum_variant("vtable_param", 1u, 2u) {|| do ebml_w.emit_enum_variant("vtable_param", 1u, 2u) {||
ebml_w.emit_enum_variant_arg(0u) {|| do ebml_w.emit_enum_variant_arg(0u) {||
ebml_w.emit_uint(pn); ebml_w.emit_uint(pn);
} }
ebml_w.emit_enum_variant_arg(1u) {|| do ebml_w.emit_enum_variant_arg(1u) {||
ebml_w.emit_uint(bn); ebml_w.emit_uint(bn);
} }
} }
} }
typeck::vtable_iface(def_id, tys) { typeck::vtable_iface(def_id, tys) {
ebml_w.emit_enum_variant("vtable_iface", 1u, 3u) {|| do ebml_w.emit_enum_variant("vtable_iface", 1u, 3u) {||
ebml_w.emit_enum_variant_arg(0u) {|| do ebml_w.emit_enum_variant_arg(0u) {||
ebml_w.emit_def_id(def_id) ebml_w.emit_def_id(def_id)
} }
ebml_w.emit_enum_variant_arg(1u) {|| do ebml_w.emit_enum_variant_arg(1u) {||
ebml_w.emit_tys(ecx, tys); ebml_w.emit_tys(ecx, tys);
} }
} }
@ -475,43 +475,43 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt,
impl helpers for ebml::ebml_deserializer { impl helpers for ebml::ebml_deserializer {
fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res { fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res {
@self.read_to_vec {|| self.read_vtable_origin(xcx) } @self.read_to_vec({|| self.read_vtable_origin(xcx) })
} }
fn read_vtable_origin(xcx: extended_decode_ctxt) fn read_vtable_origin(xcx: extended_decode_ctxt)
-> typeck::vtable_origin { -> typeck::vtable_origin {
self.read_enum("vtable_origin") {|| do self.read_enum("vtable_origin") {||
self.read_enum_variant {|i| do self.read_enum_variant {|i|
alt check i { alt check i {
0u { 0u {
typeck::vtable_static( typeck::vtable_static(
self.read_enum_variant_arg(0u) {|| do self.read_enum_variant_arg(0u) {||
self.read_def_id(xcx) self.read_def_id(xcx)
}, },
self.read_enum_variant_arg(1u) {|| do self.read_enum_variant_arg(1u) {||
self.read_tys(xcx) self.read_tys(xcx)
}, },
self.read_enum_variant_arg(2u) {|| do self.read_enum_variant_arg(2u) {||
self.read_vtable_res(xcx) self.read_vtable_res(xcx)
} }
) )
} }
1u { 1u {
typeck::vtable_param( typeck::vtable_param(
self.read_enum_variant_arg(0u) {|| do self.read_enum_variant_arg(0u) {||
self.read_uint() self.read_uint()
}, },
self.read_enum_variant_arg(1u) {|| do self.read_enum_variant_arg(1u) {||
self.read_uint() self.read_uint()
} }
) )
} }
2u { 2u {
typeck::vtable_iface( typeck::vtable_iface(
self.read_enum_variant_arg(0u) {|| do self.read_enum_variant_arg(0u) {||
self.read_def_id(xcx) self.read_def_id(xcx)
}, },
self.read_enum_variant_arg(1u) {|| do self.read_enum_variant_arg(1u) {||
self.read_tys(xcx) self.read_tys(xcx)
} }
) )
@ -541,7 +541,7 @@ impl helpers for ebml::writer {
} }
fn emit_tys(ecx: @e::encode_ctxt, tys: ~[ty::t]) { fn emit_tys(ecx: @e::encode_ctxt, tys: ~[ty::t]) {
self.emit_from_vec(tys) {|ty| do self.emit_from_vec(tys) {|ty|
e::write_type(ecx, self, ty) e::write_type(ecx, self, ty)
} }
} }
@ -551,16 +551,16 @@ impl helpers for ebml::writer {
} }
fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty) { fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty) {
self.emit_rec {|| do self.emit_rec {||
self.emit_rec_field("bounds", 0u) {|| do self.emit_rec_field("bounds", 0u) {||
self.emit_from_vec(*tpbt.bounds) {|bs| do self.emit_from_vec(*tpbt.bounds) {|bs|
self.emit_bounds(ecx, bs) self.emit_bounds(ecx, bs)
} }
} }
self.emit_rec_field("rp", 1u) {|| do self.emit_rec_field("rp", 1u) {||
ast::serialize_region_param(self, tpbt.rp) ast::serialize_region_param(self, tpbt.rp)
} }
self.emit_rec_field("ty", 2u) {|| do self.emit_rec_field("ty", 2u) {||
self.emit_ty(ecx, tpbt.ty); self.emit_ty(ecx, tpbt.ty);
} }
} }
@ -569,7 +569,7 @@ impl helpers for ebml::writer {
impl writer for ebml::writer { impl writer for ebml::writer {
fn tag(tag_id: c::astencode_tag, f: fn()) { fn tag(tag_id: c::astencode_tag, f: fn()) {
self.wr_tag(tag_id as uint) {|| f() } do self.wr_tag(tag_id as uint) {|| f() }
} }
fn id(id: ast::node_id) { fn id(id: ast::node_id) {
@ -581,7 +581,7 @@ fn encode_side_tables_for_ii(ecx: @e::encode_ctxt,
maps: maps, maps: maps,
ebml_w: ebml::writer, ebml_w: ebml::writer,
ii: ast::inlined_item) { ii: ast::inlined_item) {
ebml_w.wr_tag(c::tag_table as uint) {|| do ebml_w.wr_tag(c::tag_table as uint) {||
ast_util::visit_ids_for_inlined_item( ast_util::visit_ids_for_inlined_item(
ii, ii,
fn@(id: ast::node_id, copy ebml_w) { fn@(id: ast::node_id, copy ebml_w) {
@ -601,37 +601,37 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
#debug["Encoding side tables for id %d", id]; #debug["Encoding side tables for id %d", id];
option::iter(tcx.def_map.find(id)) {|def| do option::iter(tcx.def_map.find(id)) {|def|
ebml_w.tag(c::tag_table_def) {|| do ebml_w.tag(c::tag_table_def) {||
ebml_w.id(id); ebml_w.id(id);
ebml_w.tag(c::tag_table_val) {|| do ebml_w.tag(c::tag_table_val) {||
ast::serialize_def(ebml_w, def) ast::serialize_def(ebml_w, def)
} }
} }
} }
option::iter((*tcx.node_types).find(id as uint)) {|ty| do option::iter((*tcx.node_types).find(id as uint)) {|ty|
ebml_w.tag(c::tag_table_node_type) {|| do ebml_w.tag(c::tag_table_node_type) {||
ebml_w.id(id); ebml_w.id(id);
ebml_w.tag(c::tag_table_val) {|| do ebml_w.tag(c::tag_table_val) {||
e::write_type(ecx, ebml_w, ty) e::write_type(ecx, ebml_w, ty)
} }
} }
} }
option::iter(tcx.node_type_substs.find(id)) {|tys| do option::iter(tcx.node_type_substs.find(id)) {|tys|
ebml_w.tag(c::tag_table_node_type_subst) {|| do ebml_w.tag(c::tag_table_node_type_subst) {||
ebml_w.id(id); ebml_w.id(id);
ebml_w.tag(c::tag_table_val) {|| do ebml_w.tag(c::tag_table_val) {||
ebml_w.emit_tys(ecx, tys) ebml_w.emit_tys(ecx, tys)
} }
} }
} }
option::iter(tcx.freevars.find(id)) {|fv| do option::iter(tcx.freevars.find(id)) {|fv|
ebml_w.tag(c::tag_table_freevars) {|| do ebml_w.tag(c::tag_table_freevars) {||
ebml_w.id(id); ebml_w.id(id);
ebml_w.tag(c::tag_table_val) {|| do ebml_w.tag(c::tag_table_val) {||
ebml_w.emit_from_vec(*fv) {|fv_entry| do ebml_w.emit_from_vec(*fv) {|fv_entry|
encode_freevar_entry(ebml_w, *fv_entry) encode_freevar_entry(ebml_w, *fv_entry)
} }
} }
@ -639,19 +639,19 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
} }
let lid = {crate: ast::local_crate, node: id}; let lid = {crate: ast::local_crate, node: id};
option::iter(tcx.tcache.find(lid)) {|tpbt| do option::iter(tcx.tcache.find(lid)) {|tpbt|
ebml_w.tag(c::tag_table_tcache) {|| do ebml_w.tag(c::tag_table_tcache) {||
ebml_w.id(id); ebml_w.id(id);
ebml_w.tag(c::tag_table_val) {|| do ebml_w.tag(c::tag_table_val) {||
ebml_w.emit_tpbt(ecx, tpbt); ebml_w.emit_tpbt(ecx, tpbt);
} }
} }
} }
option::iter(tcx.ty_param_bounds.find(id)) {|pbs| do option::iter(tcx.ty_param_bounds.find(id)) {|pbs|
ebml_w.tag(c::tag_table_param_bounds) {|| do ebml_w.tag(c::tag_table_param_bounds) {||
ebml_w.id(id); ebml_w.id(id);
ebml_w.tag(c::tag_table_val) {|| do ebml_w.tag(c::tag_table_val) {||
ebml_w.emit_bounds(ecx, pbs) ebml_w.emit_bounds(ecx, pbs)
} }
} }
@ -671,17 +671,17 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
// } // }
//} //}
option::iter(maps.mutbl_map.find(id)) {|_m| do option::iter(maps.mutbl_map.find(id)) {|_m|
ebml_w.tag(c::tag_table_mutbl) {|| do ebml_w.tag(c::tag_table_mutbl) {||
ebml_w.id(id); ebml_w.id(id);
} }
} }
option::iter(maps.last_use_map.find(id)) {|m| do option::iter(maps.last_use_map.find(id)) {|m|
ebml_w.tag(c::tag_table_last_use) {|| do ebml_w.tag(c::tag_table_last_use) {||
ebml_w.id(id); ebml_w.id(id);
ebml_w.tag(c::tag_table_val) {|| do ebml_w.tag(c::tag_table_val) {||
ebml_w.emit_from_vec((*m).get()) {|id| do ebml_w.emit_from_vec((*m).get()) {|id|
ebml_w.emit_int(id); ebml_w.emit_int(id);
} }
} }
@ -691,28 +691,28 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
// impl_map is not used except when emitting metadata, // impl_map is not used except when emitting metadata,
// don't need to keep it. // don't need to keep it.
option::iter(maps.method_map.find(id)) {|mme| do option::iter(maps.method_map.find(id)) {|mme|
ebml_w.tag(c::tag_table_method_map) {|| do ebml_w.tag(c::tag_table_method_map) {||
ebml_w.id(id); ebml_w.id(id);
ebml_w.tag(c::tag_table_val) {|| do ebml_w.tag(c::tag_table_val) {||
serialize_method_map_entry(ebml_w, mme) serialize_method_map_entry(ebml_w, mme)
} }
} }
} }
option::iter(maps.vtable_map.find(id)) {|dr| do option::iter(maps.vtable_map.find(id)) {|dr|
ebml_w.tag(c::tag_table_vtable_map) {|| do ebml_w.tag(c::tag_table_vtable_map) {||
ebml_w.id(id); ebml_w.id(id);
ebml_w.tag(c::tag_table_val) {|| do ebml_w.tag(c::tag_table_val) {||
encode_vtable_res(ecx, ebml_w, dr); encode_vtable_res(ecx, ebml_w, dr);
} }
} }
} }
option::iter(tcx.borrowings.find(id)) {|borrow| do option::iter(tcx.borrowings.find(id)) {|borrow|
ebml_w.tag(c::tag_table_borrowings) {|| do ebml_w.tag(c::tag_table_borrowings) {||
ebml_w.id(id); ebml_w.id(id);
ebml_w.tag(c::tag_table_val) {|| do ebml_w.tag(c::tag_table_val) {||
ty::serialize_borrow(ebml_w, borrow) ty::serialize_borrow(ebml_w, borrow)
} }
} }
@ -742,7 +742,7 @@ impl decoder for ebml::ebml_deserializer {
} }
fn read_tys(xcx: extended_decode_ctxt) -> ~[ty::t] { fn read_tys(xcx: extended_decode_ctxt) -> ~[ty::t] {
self.read_to_vec {|| self.read_ty(xcx) } self.read_to_vec({|| self.read_ty(xcx) })
} }
fn read_bounds(xcx: extended_decode_ctxt) -> @~[ty::param_bound] { fn read_bounds(xcx: extended_decode_ctxt) -> @~[ty::param_bound] {
@ -753,17 +753,17 @@ impl decoder for ebml::ebml_deserializer {
fn read_ty_param_bounds_and_ty(xcx: extended_decode_ctxt) fn read_ty_param_bounds_and_ty(xcx: extended_decode_ctxt)
-> ty::ty_param_bounds_and_ty { -> ty::ty_param_bounds_and_ty {
self.read_rec {|| do self.read_rec {||
{ {
bounds: self.read_rec_field("bounds", 0u) {|| bounds: self.read_rec_field("bounds", 0u, {||
@self.read_to_vec {|| self.read_bounds(xcx) } @self.read_to_vec({|| self.read_bounds(xcx) })
}, }),
rp: self.read_rec_field("rp", 1u) {|| rp: self.read_rec_field("rp", 1u, {||
ast::deserialize_region_param(self) ast::deserialize_region_param(self)
}, }),
ty: self.read_rec_field("ty", 2u) {|| ty: self.read_rec_field("ty", 2u, {||
self.read_ty(xcx) self.read_ty(xcx)
} })
} }
} }
} }
@ -773,7 +773,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
ast_doc: ebml::doc) { ast_doc: ebml::doc) {
let dcx = xcx.dcx; let dcx = xcx.dcx;
let tbl_doc = ast_doc[c::tag_table]; let tbl_doc = ast_doc[c::tag_table];
ebml::docs(tbl_doc) {|tag, entry_doc| do ebml::docs(tbl_doc) {|tag, entry_doc|
let id0 = entry_doc[c::tag_table_id].as_int(); let id0 = entry_doc[c::tag_table_id].as_int();
let id = xcx.tr_id(id0); let id = xcx.tr_id(id0);
@ -796,9 +796,9 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
let tys = val_dsr.read_tys(xcx); let tys = val_dsr.read_tys(xcx);
dcx.tcx.node_type_substs.insert(id, tys); dcx.tcx.node_type_substs.insert(id, tys);
} else if tag == (c::tag_table_freevars as uint) { } else if tag == (c::tag_table_freevars as uint) {
let fv_info = @val_dsr.read_to_vec {|| let fv_info = @val_dsr.read_to_vec({||
@val_dsr.read_freevar_entry(xcx) @val_dsr.read_freevar_entry(xcx)
}; });
dcx.tcx.freevars.insert(id, fv_info); dcx.tcx.freevars.insert(id, fv_info);
} else if tag == (c::tag_table_tcache as uint) { } else if tag == (c::tag_table_tcache as uint) {
let tpbt = val_dsr.read_ty_param_bounds_and_ty(xcx); let tpbt = val_dsr.read_ty_param_bounds_and_ty(xcx);
@ -808,9 +808,9 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
let bounds = val_dsr.read_bounds(xcx); let bounds = val_dsr.read_bounds(xcx);
dcx.tcx.ty_param_bounds.insert(id, bounds); dcx.tcx.ty_param_bounds.insert(id, bounds);
} else if tag == (c::tag_table_last_use as uint) { } else if tag == (c::tag_table_last_use as uint) {
let ids = val_dsr.read_to_vec {|| let ids = val_dsr.read_to_vec({||
xcx.tr_id(val_dsr.read_int()) xcx.tr_id(val_dsr.read_int())
}; });
let dvec = @dvec::from_vec(vec::to_mut(ids)); let dvec = @dvec::from_vec(vec::to_mut(ids));
dcx.maps.last_use_map.insert(id, dvec); dcx.maps.last_use_map.insert(id, dvec);
} else if tag == (c::tag_table_method_map as uint) { } else if tag == (c::tag_table_method_map as uint) {
@ -838,7 +838,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
#[cfg(test)] #[cfg(test)]
fn encode_item_ast(ebml_w: ebml::writer, item: @ast::item) { fn encode_item_ast(ebml_w: ebml::writer, item: @ast::item) {
ebml_w.wr_tag(c::tag_tree as uint) {|| do ebml_w.wr_tag(c::tag_tree as uint) {||
ast::serialize_item(ebml_w, *item); ast::serialize_item(ebml_w, *item);
} }
} }
@ -881,9 +881,9 @@ fn roundtrip(in_item: @ast::item) {
#debug["out_item = %s", pprust::item_to_str(out_item)]; #debug["out_item = %s", pprust::item_to_str(out_item)];
let exp_str = let exp_str =
io::with_str_writer {|w| ast::serialize_item(w, *in_item) }; io::with_str_writer({|w| ast::serialize_item(w, *in_item) });
let out_str = let out_str =
io::with_str_writer {|w| ast::serialize_item(w, *out_item) }; io::with_str_writer({|w| ast::serialize_item(w, *out_item) });
#debug["expected string: %s", exp_str]; #debug["expected string: %s", exp_str];
#debug["actual string : %s", out_str]; #debug["actual string : %s", out_str];

View file

@ -280,7 +280,7 @@ impl public_methods for borrowck_ctxt {
cmt: cmt) -> cmt { cmt: cmt) -> cmt {
@{id: arg.id(), span: arg.span(), @{id: arg.id(), span: arg.span(),
cat: cat_comp(cmt, comp_variant(enum_did)), cat: cat_comp(cmt, comp_variant(enum_did)),
lp: cmt.lp.map { |l| @lp_comp(l, comp_variant(enum_did)) }, lp: cmt.lp.map({ |l| @lp_comp(l, comp_variant(enum_did)) }),
mutbl: cmt.mutbl, // imm iff in an immutable context mutbl: cmt.mutbl, // imm iff in an immutable context
ty: self.tcx.ty(arg)} ty: self.tcx.ty(arg)}
} }
@ -311,9 +311,9 @@ impl public_methods for borrowck_ctxt {
m_mutbl | m_const { f_mutbl } m_mutbl | m_const { f_mutbl }
}; };
let f_comp = comp_field(f_name, f_mutbl); let f_comp = comp_field(f_name, f_mutbl);
let lp = base_cmt.lp.map { |lp| let lp = base_cmt.lp.map({ |lp|
@lp_comp(lp, f_comp) @lp_comp(lp, f_comp)
}; });
@{id: node.id(), span: node.span(), @{id: node.id(), span: node.span(),
cat: cat_comp(base_cmt, f_comp), lp:lp, cat: cat_comp(base_cmt, f_comp), lp:lp,
mutbl: m, ty: self.tcx.ty(node)} mutbl: m, ty: self.tcx.ty(node)}
@ -321,10 +321,10 @@ impl public_methods for borrowck_ctxt {
fn cat_deref<N:ast_node>(node: N, base_cmt: cmt, derefs: uint, fn cat_deref<N:ast_node>(node: N, base_cmt: cmt, derefs: uint,
expl: bool) -> option<cmt> { expl: bool) -> option<cmt> {
ty::deref(self.tcx, base_cmt.ty, expl).map { |mt| do ty::deref(self.tcx, base_cmt.ty, expl).map { |mt|
alt deref_kind(self.tcx, base_cmt.ty) { alt deref_kind(self.tcx, base_cmt.ty) {
deref_ptr(ptr) { deref_ptr(ptr) {
let lp = base_cmt.lp.chain { |l| let lp = do base_cmt.lp.chain { |l|
// Given that the ptr itself is loanable, we can // Given that the ptr itself is loanable, we can
// loan out deref'd uniq ptrs as the data they are // loan out deref'd uniq ptrs as the data they are
// the only way to reach the data they point at. // the only way to reach the data they point at.
@ -341,7 +341,7 @@ impl public_methods for borrowck_ctxt {
} }
deref_comp(comp) { deref_comp(comp) {
let lp = base_cmt.lp.map { |l| @lp_comp(l, comp) }; let lp = base_cmt.lp.map({ |l| @lp_comp(l, comp) });
@{id:node.id(), span:node.span(), @{id:node.id(), span:node.span(),
cat:cat_comp(base_cmt, comp), lp:lp, cat:cat_comp(base_cmt, comp), lp:lp,
mutbl:mt.mutbl, ty:mt.ty} mutbl:mt.mutbl, ty:mt.ty}
@ -367,7 +367,7 @@ impl public_methods for borrowck_ctxt {
deref_ptr(ptr) { deref_ptr(ptr) {
// make deref of vectors explicit, as explained in the comment at // make deref of vectors explicit, as explained in the comment at
// the head of this section // the head of this section
let deref_lp = base_cmt.lp.map { |lp| @lp_deref(lp, ptr) }; let deref_lp = base_cmt.lp.map({ |lp| @lp_deref(lp, ptr) });
let deref_cmt = @{id:expr.id, span:expr.span, let deref_cmt = @{id:expr.id, span:expr.span,
cat:cat_deref(base_cmt, 0u, ptr), lp:deref_lp, cat:cat_deref(base_cmt, 0u, ptr), lp:deref_lp,
mutbl:m_imm, ty:mt.ty}; mutbl:m_imm, ty:mt.ty};
@ -383,7 +383,7 @@ impl public_methods for borrowck_ctxt {
fn comp(expr: @ast::expr, of_cmt: cmt, fn comp(expr: @ast::expr, of_cmt: cmt,
vect: ty::t, mt: ty::mt) -> cmt { vect: ty::t, mt: ty::mt) -> cmt {
let comp = comp_index(vect, mt.mutbl); let comp = comp_index(vect, mt.mutbl);
let index_lp = of_cmt.lp.map { |lp| @lp_comp(lp, comp) }; let index_lp = of_cmt.lp.map({ |lp| @lp_comp(lp, comp) });
@{id:expr.id, span:expr.span, @{id:expr.id, span:expr.span,
cat:cat_comp(of_cmt, comp), lp:index_lp, cat:cat_comp(of_cmt, comp), lp:index_lp,
mutbl:mt.mutbl, ty:mt.ty} mutbl:mt.mutbl, ty:mt.ty}
@ -393,7 +393,7 @@ impl public_methods for borrowck_ctxt {
fn cat_tuple_elt<N: ast_node>(elt: N, cmt: cmt) -> cmt { fn cat_tuple_elt<N: ast_node>(elt: N, cmt: cmt) -> cmt {
@{id: elt.id(), span: elt.span(), @{id: elt.id(), span: elt.span(),
cat: cat_comp(cmt, comp_tuple), cat: cat_comp(cmt, comp_tuple),
lp: cmt.lp.map { |l| @lp_comp(l, comp_tuple) }, lp: cmt.lp.map({ |l| @lp_comp(l, comp_tuple) }),
mutbl: cmt.mutbl, // imm iff in an immutable context mutbl: cmt.mutbl, // imm iff in an immutable context
ty: self.tcx.ty(elt)} ty: self.tcx.ty(elt)}
} }

View file

@ -488,7 +488,7 @@ impl methods for check_loan_ctxt {
let arg_tys = let arg_tys =
ty::ty_fn_args( ty::ty_fn_args(
ty::node_id_to_type(self.tcx(), callee_id)); ty::node_id_to_type(self.tcx(), callee_id));
vec::iter2(args, arg_tys) { |arg, arg_ty| do vec::iter2(args, arg_tys) { |arg, arg_ty|
alt ty::resolved_mode(self.tcx(), arg_ty.mode) { alt ty::resolved_mode(self.tcx(), arg_ty.mode) {
ast::by_move { ast::by_move {
self.check_move_out(arg); self.check_move_out(arg);
@ -508,9 +508,9 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
visitor: visit::vt<check_loan_ctxt>) { visitor: visit::vt<check_loan_ctxt>) {
#debug["purity on entry=%?", copy self.declared_purity]; #debug["purity on entry=%?", copy self.declared_purity];
save_and_restore(self.in_ctor) {|| do save_and_restore(self.in_ctor) {||
save_and_restore(self.declared_purity) {|| do save_and_restore(self.declared_purity) {||
save_and_restore(self.fn_args) {|| do save_and_restore(self.fn_args) {||
let is_stack_closure = self.is_stack_closure(id); let is_stack_closure = self.is_stack_closure(id);
// In principle, we could consider fk_anon(*) or // In principle, we could consider fk_anon(*) or
@ -637,7 +637,7 @@ fn check_loans_in_expr(expr: @ast::expr,
fn check_loans_in_block(blk: ast::blk, fn check_loans_in_block(blk: ast::blk,
&&self: check_loan_ctxt, &&self: check_loan_ctxt,
vt: visit::vt<check_loan_ctxt>) { vt: visit::vt<check_loan_ctxt>) {
save_and_restore(self.declared_purity) {|| do save_and_restore(self.declared_purity) {||
self.check_for_conflicting_loans(blk.node.id); self.check_for_conflicting_loans(blk.node.id);
alt blk.node.rules { alt blk.node.rules {

View file

@ -56,7 +56,7 @@ fn req_loans_in_expr(ex: @ast::expr,
ast::expr_call(f, args, _) { ast::expr_call(f, args, _) {
let arg_tys = ty::ty_fn_args(ty::expr_ty(self.tcx(), f)); let arg_tys = ty::ty_fn_args(ty::expr_ty(self.tcx(), f));
let scope_r = ty::re_scope(ex.id); let scope_r = ty::re_scope(ex.id);
vec::iter2(args, arg_tys) { |arg, arg_ty| do vec::iter2(args, arg_tys) { |arg, arg_ty|
alt ty::resolved_mode(self.tcx(), arg_ty.mode) { alt ty::resolved_mode(self.tcx(), arg_ty.mode) {
ast::by_mutbl_ref { ast::by_mutbl_ref {
let arg_cmt = self.bccx.cat_expr(arg); let arg_cmt = self.bccx.cat_expr(arg);
@ -215,7 +215,7 @@ impl methods for gather_loan_ctxt {
}; };
let result = { let result = {
self.check_mutbl(req_mutbl, cmt).chain { |_ok| do self.check_mutbl(req_mutbl, cmt).chain { |_ok|
self.bccx.preserve(cmt, opt_scope_id) self.bccx.preserve(cmt, opt_scope_id)
} }
}; };

View file

@ -106,7 +106,7 @@ fn compute_capture_vars(tcx: ty::ctxt,
ast::proto_bare | ast::proto_box | ast::proto_uniq { cap_copy } ast::proto_bare | ast::proto_box | ast::proto_uniq { cap_copy }
}; };
vec::iter(*freevars) { |fvar| do vec::iter(*freevars) { |fvar|
let fvar_def_id = ast_util::def_id_of_def(fvar.def).node; let fvar_def_id = ast_util::def_id_of_def(fvar.def).node;
alt cap_map.find(fvar_def_id) { alt cap_map.find(fvar_def_id) {
option::some(_) { /* was explicitly named, do nothing */ } option::some(_) { /* was explicitly named, do nothing */ }

View file

@ -219,7 +219,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> {
ty::ty_enum(eid, _) { ty::ty_enum(eid, _) {
let mut found = ~[]; let mut found = ~[];
for m.each {|r| for m.each {|r|
option::iter(pat_ctor_id(tcx, r[0])) {|id| do option::iter(pat_ctor_id(tcx, r[0])) {|id|
if !vec::contains(found, id) { vec::push(found, id); } if !vec::contains(found, id) { vec::push(found, id); }
} }
} }

View file

@ -27,7 +27,7 @@ fn check_item(sess: session, ast_map: ast_map::map, def_map: resolve::def_map,
} }
item_enum(vs, _, _) { item_enum(vs, _, _) {
for vs.each {|var| for vs.each {|var|
option::iter(var.node.disr_expr) {|ex| do option::iter(var.node.disr_expr) {|ex|
v.visit_expr(ex, true, v); v.visit_expr(ex, true, v);
} }
} }

View file

@ -150,7 +150,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
// Find the check function that enforces the appropriate bounds for this // Find the check function that enforces the appropriate bounds for this
// kind of function: // kind of function:
with_appropriate_checker(cx, fn_id) { |chk| do with_appropriate_checker(cx, fn_id) { |chk|
// Begin by checking the variables in the capture clause, if any. // Begin by checking the variables in the capture clause, if any.
// Here we slightly abuse the map function to both check and report // Here we slightly abuse the map function to both check and report
@ -162,7 +162,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
visit::fk_item_fn(*) | visit::fk_method(*) | visit::fk_item_fn(*) | visit::fk_method(*) |
visit::fk_ctor(*) | visit::fk_dtor(*) { @~[] } visit::fk_ctor(*) | visit::fk_dtor(*) { @~[] }
}; };
let captured_vars = (*cap_clause).map { |cap_item| let captured_vars = do (*cap_clause).map { |cap_item|
let cap_def = cx.tcx.def_map.get(cap_item.id); let cap_def = cx.tcx.def_map.get(cap_item.id);
let cap_def_id = ast_util::def_id_of_def(cap_def).node; let cap_def_id = ast_util::def_id_of_def(cap_def).node;
let ty = ty::node_id_to_type(cx.tcx, cap_def_id); let ty = ty::node_id_to_type(cx.tcx, cap_def_id);
@ -251,7 +251,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
} }
} }
expr_path(_) | expr_field(_, _, _) { expr_path(_) | expr_field(_, _, _) {
option::iter(cx.tcx.node_type_substs.find(e.id)) {|ts| do option::iter(cx.tcx.node_type_substs.find(e.id)) {|ts|
let bounds = alt check e.node { let bounds = alt check e.node {
expr_path(_) { expr_path(_) {
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(e.id)); let did = ast_util::def_id_of_def(cx.tcx.def_map.get(e.id));
@ -286,7 +286,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
%s (%u tys), declared = %? (%u tys)", %s (%u tys), declared = %? (%u tys)",
tys_to_str(cx.tcx, ts), ts.len(), *bounds, (*bounds).len()); tys_to_str(cx.tcx, ts), ts.len(), *bounds, (*bounds).len());
} }
vec::iter2(ts, *bounds) {|ty, bound| do vec::iter2(ts, *bounds) {|ty, bound|
check_bounds(cx, e.id, e.span, ty, bound) check_bounds(cx, e.id, e.span, ty, bound)
} }
} }
@ -314,10 +314,10 @@ fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) {
fn check_ty(aty: @ty, cx: ctx, v: visit::vt<ctx>) { fn check_ty(aty: @ty, cx: ctx, v: visit::vt<ctx>) {
alt aty.node { alt aty.node {
ty_path(_, id) { ty_path(_, id) {
option::iter(cx.tcx.node_type_substs.find(id)) {|ts| do option::iter(cx.tcx.node_type_substs.find(id)) {|ts|
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(id)); let did = ast_util::def_id_of_def(cx.tcx.def_map.get(id));
let bounds = ty::lookup_item_type(cx.tcx, did).bounds; let bounds = ty::lookup_item_type(cx.tcx, did).bounds;
vec::iter2(ts, *bounds) {|ty, bound| do vec::iter2(ts, *bounds) {|ty, bound|
check_bounds(cx, aty.id, aty.span, ty, bound) check_bounds(cx, aty.id, aty.span, ty, bound)
} }
} }

View file

@ -273,7 +273,7 @@ fn lookup_lint(dict: lint_dict, s: str)
} }
fn build_settings_item(i: @ast::item, &&cx: ctxt, v: visit::vt<ctxt>) { fn build_settings_item(i: @ast::item, &&cx: ctxt, v: visit::vt<ctxt>) {
cx.with_warn_attrs(i.attrs) {|cx| do cx.with_warn_attrs(i.attrs) {|cx|
if !cx.is_default { if !cx.is_default {
cx.sess.warning_settings.settings_map.insert(i.id, cx.curr); cx.sess.warning_settings.settings_map.insert(i.id, cx.curr);
} }
@ -297,7 +297,7 @@ fn build_settings_crate(sess: session::session, crate: @ast::crate) {
cx.set_level(lint, level); cx.set_level(lint, level);
} }
cx.with_warn_attrs(crate.node.attrs) {|cx| do cx.with_warn_attrs(crate.node.attrs) {|cx|
// Copy out the default settings // Copy out the default settings
for cx.curr.each {|k, v| for cx.curr.each {|k, v|
sess.warning_settings.default_settings.insert(k, v); sess.warning_settings.default_settings.insert(k, v);
@ -357,7 +357,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id, fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
decl: ast::fn_decl) { decl: ast::fn_decl) {
let tys = vec::map(decl.inputs) {|a| a.ty }; let tys = vec::map(decl.inputs, {|a| a.ty });
for vec::each(vec::append_one(tys, decl.output)) {|ty| for vec::each(vec::append_one(tys, decl.output)) {|ty|
alt ty.node { alt ty.node {
ast::ty_path(_, id) { ast::ty_path(_, id) {

View file

@ -406,7 +406,7 @@ fn add_class_fields(self: @ir_maps, did: def_id) {
fn visit_local(local: @local, &&self: @ir_maps, vt: vt<@ir_maps>) { fn visit_local(local: @local, &&self: @ir_maps, vt: vt<@ir_maps>) {
let def_map = self.tcx.def_map; let def_map = self.tcx.def_map;
pat_util::pat_bindings(def_map, local.node.pat) { |p_id, sp, path| do pat_util::pat_bindings(def_map, local.node.pat) { |p_id, sp, path|
#debug["adding local variable %d", p_id]; #debug["adding local variable %d", p_id];
let name = ast_util::path_to_ident(path); let name = ast_util::path_to_ident(path);
(*self).add_live_node_for_node(p_id, lnk_vdef(sp)); (*self).add_live_node_for_node(p_id, lnk_vdef(sp));
@ -560,9 +560,9 @@ class liveness {
alt expr.node { alt expr.node {
expr_path(_) { expr_path(_) {
let def = self.tcx.def_map.get(expr.id); let def = self.tcx.def_map.get(expr.id);
relevant_def(def).map { |rdef| relevant_def(def).map({ |rdef|
self.variable_from_rdef(rdef, expr.span) self.variable_from_rdef(rdef, expr.span)
} })
} }
_ {none} _ {none}
} }
@ -576,9 +576,9 @@ class liveness {
span: span) -> option<variable> { span: span) -> option<variable> {
alt self.tcx.def_map.find(node_id) { alt self.tcx.def_map.find(node_id) {
some(def) { some(def) {
relevant_def(def).map { |rdef| relevant_def(def).map({ |rdef|
self.variable_from_rdef(rdef, span) self.variable_from_rdef(rdef, span)
} })
} }
none { none {
self.tcx.sess.span_bug( self.tcx.sess.span_bug(
@ -589,7 +589,7 @@ class liveness {
fn pat_bindings(pat: @pat, f: fn(live_node, variable, span)) { fn pat_bindings(pat: @pat, f: fn(live_node, variable, span)) {
let def_map = self.tcx.def_map; let def_map = self.tcx.def_map;
pat_util::pat_bindings(def_map, pat) {|p_id, sp, _n| do pat_util::pat_bindings(def_map, pat) {|p_id, sp, _n|
let ln = self.live_node(p_id, sp); let ln = self.live_node(p_id, sp);
let var = self.variable(p_id, sp); let var = self.variable(p_id, sp);
f(ln, var, sp); f(ln, var, sp);
@ -663,7 +663,7 @@ class liveness {
} }
fn ln_str(ln: live_node) -> str { fn ln_str(ln: live_node) -> str {
io::with_str_writer { |wr| do io::with_str_writer { |wr|
wr.write_str("[ln("); wr.write_str("[ln(");
wr.write_uint(*ln); wr.write_uint(*ln);
wr.write_str(") of kind "); wr.write_str(") of kind ");
@ -695,9 +695,9 @@ class liveness {
fn init_from_succ(ln: live_node, succ_ln: live_node) { fn init_from_succ(ln: live_node, succ_ln: live_node) {
// more efficient version of init_empty() / merge_from_succ() // more efficient version of init_empty() / merge_from_succ()
self.successors[*ln] = succ_ln; self.successors[*ln] = succ_ln;
self.indices2(ln, succ_ln) { |idx, succ_idx| self.indices2(ln, succ_ln, { |idx, succ_idx|
self.users[idx] = self.users[succ_idx]; self.users[idx] = self.users[succ_idx];
} });
#debug["init_from_succ(ln=%s, succ=%s)", #debug["init_from_succ(ln=%s, succ=%s)",
self.ln_str(ln), self.ln_str(succ_ln)]; self.ln_str(ln), self.ln_str(succ_ln)];
} }
@ -707,7 +707,7 @@ class liveness {
if ln == succ_ln { ret false; } if ln == succ_ln { ret false; }
let mut changed = false; let mut changed = false;
self.indices2(ln, succ_ln) { |idx, succ_idx| do self.indices2(ln, succ_ln) { |idx, succ_idx|
changed |= copy_if_invalid(copy self.users[succ_idx].reader, changed |= copy_if_invalid(copy self.users[succ_idx].reader,
self.users[idx].reader); self.users[idx].reader);
changed |= copy_if_invalid(copy self.users[succ_idx].writer, changed |= copy_if_invalid(copy self.users[succ_idx].writer,
@ -776,9 +776,9 @@ class liveness {
// effectively a return---this only occurs in `for` loops, // effectively a return---this only occurs in `for` loops,
// where the body is really a closure. // where the body is really a closure.
let entry_ln: live_node = let entry_ln: live_node =
self.with_loop_nodes(self.s.exit_ln, self.s.exit_ln) {|| self.with_loop_nodes(self.s.exit_ln, self.s.exit_ln, {||
self.propagate_through_fn_block(decl, body) self.propagate_through_fn_block(decl, body)
}; });
// hack to skip the loop unless #debug is enabled: // hack to skip the loop unless #debug is enabled:
#debug["^^ liveness computation results for body %d (entry=%s)", #debug["^^ liveness computation results for body %d (entry=%s)",
@ -832,7 +832,7 @@ class liveness {
fn propagate_through_block(blk: blk, succ: live_node) -> live_node { fn propagate_through_block(blk: blk, succ: live_node) -> live_node {
let succ = self.propagate_through_opt_expr(blk.node.expr, succ); let succ = self.propagate_through_opt_expr(blk.node.expr, succ);
blk.node.stmts.foldr(succ) { |stmt, succ| do blk.node.stmts.foldr(succ) { |stmt, succ|
self.propagate_through_stmt(stmt, succ) self.propagate_through_stmt(stmt, succ)
} }
} }
@ -852,7 +852,7 @@ class liveness {
fn propagate_through_decl(decl: @decl, succ: live_node) -> live_node { fn propagate_through_decl(decl: @decl, succ: live_node) -> live_node {
alt decl.node { alt decl.node {
decl_local(locals) { decl_local(locals) {
locals.foldr(succ) { |local, succ| do locals.foldr(succ) { |local, succ|
self.propagate_through_local(local, succ) self.propagate_through_local(local, succ)
} }
} }
@ -877,9 +877,9 @@ class liveness {
// initialization, which is mildly more complex than checking // initialization, which is mildly more complex than checking
// once at the func header but otherwise equivalent. // once at the func header but otherwise equivalent.
let opt_init = local.node.init.map { |i| i.expr }; let opt_init = local.node.init.map({ |i| i.expr });
let mut succ = self.propagate_through_opt_expr(opt_init, succ); let mut succ = self.propagate_through_opt_expr(opt_init, succ);
self.pat_bindings(local.node.pat) { |ln, var, _sp| do self.pat_bindings(local.node.pat) { |ln, var, _sp|
self.init_from_succ(ln, succ); self.init_from_succ(ln, succ);
self.define(ln, var); self.define(ln, var);
succ = ln; succ = ln;
@ -889,14 +889,14 @@ class liveness {
fn propagate_through_exprs(exprs: ~[@expr], fn propagate_through_exprs(exprs: ~[@expr],
succ: live_node) -> live_node { succ: live_node) -> live_node {
exprs.foldr(succ) { |expr, succ| do exprs.foldr(succ) { |expr, succ|
self.propagate_through_expr(expr, succ) self.propagate_through_expr(expr, succ)
} }
} }
fn propagate_through_opt_expr(opt_expr: option<@expr>, fn propagate_through_opt_expr(opt_expr: option<@expr>,
succ: live_node) -> live_node { succ: live_node) -> live_node {
opt_expr.foldl(succ) { |succ, expr| do opt_expr.foldl(succ) { |succ, expr|
self.propagate_through_expr(expr, succ) self.propagate_through_expr(expr, succ)
} }
} }
@ -930,7 +930,7 @@ class liveness {
// the construction of a closure itself is not important, // the construction of a closure itself is not important,
// but we have to consider the closed over variables. // but we have to consider the closed over variables.
let caps = (*self.ir).captures(expr); let caps = (*self.ir).captures(expr);
(*caps).foldr(succ) { |cap, succ| do (*caps).foldr(succ) { |cap, succ|
self.init_from_succ(cap.ln, succ); self.init_from_succ(cap.ln, succ);
let var = self.variable_from_rdef(cap.rv, expr.span); let var = self.variable_from_rdef(cap.rv, expr.span);
self.acc(cap.ln, var, ACC_READ | ACC_USE); self.acc(cap.ln, var, ACC_READ | ACC_USE);
@ -1063,7 +1063,7 @@ class liveness {
expr_rec(fields, with_expr) { expr_rec(fields, with_expr) {
let succ = self.propagate_through_opt_expr(with_expr, succ); let succ = self.propagate_through_opt_expr(with_expr, succ);
fields.foldr(succ) { |field, succ| do fields.foldr(succ) { |field, succ|
self.propagate_through_expr(field.node.expr, succ) self.propagate_through_expr(field.node.expr, succ)
} }
} }
@ -1273,10 +1273,10 @@ class liveness {
alt def { alt def {
def_self(_) { def_self(_) {
// Note: the field_map is empty unless we are in a ctor // Note: the field_map is empty unless we are in a ctor
ret self.ir.field_map.find(fld).map { |var| ret self.ir.field_map.find(fld).map({ |var|
let ln = self.live_node(expr.id, expr.span); let ln = self.live_node(expr.id, expr.span);
(ln, var) (ln, var)
}; });
} }
_ { ret none; } _ { ret none; }
} }
@ -1320,17 +1320,17 @@ class liveness {
first_merge = false; first_merge = false;
} }
let cond_ln = self.propagate_through_opt_expr(cond, ln); let cond_ln = self.propagate_through_opt_expr(cond, ln);
let body_ln = self.with_loop_nodes(succ, ln) {|| let body_ln = self.with_loop_nodes(succ, ln, {||
self.propagate_through_block(body, cond_ln) self.propagate_through_block(body, cond_ln)
}; });
// repeat until fixed point is reached: // repeat until fixed point is reached:
while self.merge_from_succ(ln, body_ln, first_merge) { while self.merge_from_succ(ln, body_ln, first_merge) {
first_merge = false; first_merge = false;
assert cond_ln == self.propagate_through_opt_expr(cond, ln); assert cond_ln == self.propagate_through_opt_expr(cond, ln);
assert body_ln == self.with_loop_nodes(succ, ln) {|| assert body_ln == self.with_loop_nodes(succ, ln, {||
self.propagate_through_block(body, cond_ln) self.propagate_through_block(body, cond_ln)
}; });
} }
cond_ln cond_ln
@ -1373,7 +1373,7 @@ fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) {
// should not be live at this point. // should not be live at this point.
#debug["check_local() with no initializer"]; #debug["check_local() with no initializer"];
(*self).pat_bindings(local.node.pat) { |ln, var, sp| do (*self).pat_bindings(local.node.pat) { |ln, var, sp|
if !self.warn_about_unused(sp, ln, var) { if !self.warn_about_unused(sp, ln, var) {
alt (*self).live_on_exit(ln, var) { alt (*self).live_on_exit(ln, var) {
none { /* not live: good */ } none { /* not live: good */ }
@ -1438,7 +1438,7 @@ fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) {
expr_call(f, args, _) { expr_call(f, args, _) {
let targs = ty::ty_fn_args(ty::expr_ty(self.tcx, f)); let targs = ty::ty_fn_args(ty::expr_ty(self.tcx, f));
vt.visit_expr(f, self, vt); vt.visit_expr(f, self, vt);
vec::iter2(args, targs) { |arg_expr, arg_ty| do vec::iter2(args, targs) { |arg_expr, arg_ty|
alt ty::resolved_mode(self.tcx, arg_ty.mode) { alt ty::resolved_mode(self.tcx, arg_ty.mode) {
by_val | by_copy | by_ref | by_mutbl_ref{ by_val | by_copy | by_ref | by_mutbl_ref{
vt.visit_expr(arg_expr, self, vt); vt.visit_expr(arg_expr, self, vt);
@ -1621,7 +1621,7 @@ impl check_methods for @liveness {
} }
fn check_for_reassignments_in_pat(pat: @pat) { fn check_for_reassignments_in_pat(pat: @pat) {
(*self).pat_bindings(pat) { |ln, var, sp| do (*self).pat_bindings(pat) { |ln, var, sp|
self.check_for_reassignment(ln, var, sp); self.check_for_reassignment(ln, var, sp);
} }
} }
@ -1752,7 +1752,7 @@ impl check_methods for @liveness {
} }
fn warn_about_unused_or_dead_vars_in_pat(pat: @pat) { fn warn_about_unused_or_dead_vars_in_pat(pat: @pat) {
(*self).pat_bindings(pat) { |ln, var, sp| do (*self).pat_bindings(pat) { |ln, var, sp|
if !self.warn_about_unused(sp, ln, var) { if !self.warn_about_unused(sp, ln, var) {
self.warn_about_dead_assign(sp, ln, var); self.warn_about_dead_assign(sp, ln, var);
} }

View file

@ -15,7 +15,7 @@ type pat_id_map = std::map::hashmap<ident, node_id>;
// use the node_id of their namesake in the first pattern. // use the node_id of their namesake in the first pattern.
fn pat_id_map(dm: resolve::def_map, pat: @pat) -> pat_id_map { fn pat_id_map(dm: resolve::def_map, pat: @pat) -> pat_id_map {
let map = std::map::box_str_hash(); let map = std::map::box_str_hash();
pat_bindings(dm, pat) {|p_id, _s, n| do pat_bindings(dm, pat) {|p_id, _s, n|
map.insert(path_to_ident(n), p_id); map.insert(path_to_ident(n), p_id);
}; };
ret map; ret map;
@ -39,7 +39,7 @@ fn pat_is_variant(dm: resolve::def_map, pat: @pat) -> bool {
// Could return a constrained type in order to express that (future work) // Could return a constrained type in order to express that (future work)
fn pat_bindings(dm: resolve::def_map, pat: @pat, fn pat_bindings(dm: resolve::def_map, pat: @pat,
it: fn(node_id, span, @path)) { it: fn(node_id, span, @path)) {
walk_pat(pat) {|p| do walk_pat(pat) {|p|
alt p.node { alt p.node {
pat_ident(pth, _) if !pat_is_variant(dm, p) { pat_ident(pth, _) if !pat_is_variant(dm, p) {
it(p.id, p.span, pth); it(p.id, p.span, pth);
@ -51,6 +51,6 @@ fn pat_bindings(dm: resolve::def_map, pat: @pat,
fn pat_binding_ids(dm: resolve::def_map, pat: @pat) -> ~[node_id] { fn pat_binding_ids(dm: resolve::def_map, pat: @pat) -> ~[node_id] {
let mut found = ~[]; let mut found = ~[];
pat_bindings(dm, pat) {|b_id, _sp, _pt| vec::push(found, b_id); }; pat_bindings(dm, pat, {|b_id, _sp, _pt| vec::push(found, b_id); });
ret found; ret found;
} }

View file

@ -212,7 +212,7 @@ fn iter_import_paths(vi: ast::view_item, f: fn(vp: @ast::view_path)) {
fn iter_effective_import_paths(vi: ast::view_item, fn iter_effective_import_paths(vi: ast::view_item,
f: fn(vp: @ast::view_path)) { f: fn(vp: @ast::view_path)) {
iter_import_paths(vi, f); iter_import_paths(vi, f);
iter_export_paths(vi) {|vp| do iter_export_paths(vi) {|vp|
alt vp.node { alt vp.node {
ast::view_path_simple(_, _, _) { } ast::view_path_simple(_, _, _) { }
// FIXME (but also see #1893): support uniform ident-list exports // FIXME (but also see #1893): support uniform ident-list exports
@ -231,7 +231,7 @@ fn iter_effective_import_paths(vi: ast::view_item,
fn map_crate(e: @env, c: @ast::crate) { fn map_crate(e: @env, c: @ast::crate) {
fn index_vi(e: @env, i: @ast::view_item, &&sc: scopes, _v: vt<scopes>) { fn index_vi(e: @env, i: @ast::view_item, &&sc: scopes, _v: vt<scopes>) {
iter_effective_import_paths(*i) { |vp| do iter_effective_import_paths(*i) { |vp|
alt vp.node { alt vp.node {
ast::view_path_simple(name, path, id) { ast::view_path_simple(name, path, id) {
e.imports.insert(id, todo(name, @path.idents, vp.span, e.imports.insert(id, todo(name, @path.idents, vp.span,
@ -255,7 +255,7 @@ fn map_crate(e: @env, c: @ast::crate) {
fn path_from_scope(sc: scopes, n: str) -> str { fn path_from_scope(sc: scopes, n: str) -> str {
let mut path = n + "::"; let mut path = n + "::";
list::iter(sc) {|s| do list::iter(sc) {|s|
alt s { alt s {
scope_item(i) { path = *i.ident + "::" + path; } scope_item(i) { path = *i.ident + "::" + path; }
_ {} _ {}
@ -294,7 +294,7 @@ fn map_crate(e: @env, c: @ast::crate) {
// So we wind up reusing the glob-import machinery when looking at // So we wind up reusing the glob-import machinery when looking at
// glob exports. They just do re-exporting in a later step. // glob exports. They just do re-exporting in a later step.
fn link_glob(e: @env, vi: @ast::view_item, &&sc: scopes, _v: vt<scopes>) { fn link_glob(e: @env, vi: @ast::view_item, &&sc: scopes, _v: vt<scopes>) {
iter_effective_import_paths(*vi) { |vp| do iter_effective_import_paths(*vi) { |vp|
alt vp.node { alt vp.node {
ast::view_path_glob(path, _) { ast::view_path_glob(path, _) {
alt follow_import(*e, sc, path.idents, vp.span) { alt follow_import(*e, sc, path.idents, vp.span) {
@ -440,7 +440,7 @@ fn resolve_names(e: @env, c: @ast::crate) {
refer to, so it's possible to resolve them. refer to, so it's possible to resolve them.
*/ */
ast::item_impl(_, _, ifce, _, _) { ast::item_impl(_, _, ifce, _, _) {
ifce.iter {|p| resolve_iface_ref(p, sc, e);} ifce.iter({|p| resolve_iface_ref(p, sc, e);})
} }
ast::item_class(_, ifaces, _, _, _, _) { ast::item_class(_, ifaces, _, _, _, _) {
for ifaces.each {|p| for ifaces.each {|p|
@ -554,7 +554,7 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
alt i.node { alt i.node {
ast::item_impl(tps, _, ifce, sty, methods) { ast::item_impl(tps, _, ifce, sty, methods) {
v.visit_ty_params(tps, sc, v); v.visit_ty_params(tps, sc, v);
option::iter(ifce) {|p| visit::visit_path(p.path, sc, v)}; option::iter(ifce, {|p| visit::visit_path(p.path, sc, v)});
v.visit_ty(sty, sc, v); v.visit_ty(sty, sc, v);
for methods.each {|m| for methods.each {|m|
v.visit_ty_params(m.tps, sc, v); v.visit_ty_params(m.tps, sc, v);
@ -588,7 +588,7 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
local_def(i.id)), ctor.node.dec, local_def(i.id)), ctor.node.dec,
ctor.node.body, ctor.span, ctor.node.id, ctor.node.body, ctor.span, ctor.node.id,
ctor_scope, v); ctor_scope, v);
option::iter(m_dtor) {|dtor| do option::iter(m_dtor) {|dtor|
let dtor_scope = @cons(scope_method(dtor.node.self_id, tps), let dtor_scope = @cons(scope_method(dtor.node.self_id, tps),
class_scope); class_scope);
@ -694,7 +694,7 @@ fn visit_local_with_scope(e: @env, loc: @local, &&sc: scopes, v:vt<scopes>) {
// scope. We disallow this, in order to make alt patterns consisting of a // scope. We disallow this, in order to make alt patterns consisting of a
// single identifier unambiguous (does the pattern "foo" refer to enum // single identifier unambiguous (does the pattern "foo" refer to enum
// foo, or is it binding a new name foo?) // foo, or is it binding a new name foo?)
ast_util::walk_pat(loc.node.pat) { |p| do ast_util::walk_pat(loc.node.pat) { |p|
alt p.node { alt p.node {
pat_ident(path, _) { pat_ident(path, _) {
alt lookup_in_scope(*e, sc, loc.span, path_to_ident(path), alt lookup_in_scope(*e, sc, loc.span, path_to_ident(path),
@ -780,7 +780,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident,
fn lst(my_id: node_id, vis: ~[@view_item]) -> ~[node_id] { fn lst(my_id: node_id, vis: ~[@view_item]) -> ~[node_id] {
let mut imports = ~[], found = false; let mut imports = ~[], found = false;
for vis.each {|vi| for vis.each {|vi|
iter_effective_import_paths(*vi) {|vp| do iter_effective_import_paths(*vi) {|vp|
alt vp.node { alt vp.node {
view_path_simple(_, _, id) view_path_simple(_, _, id)
| view_path_glob(_, id) { | view_path_glob(_, id) {
@ -1180,7 +1180,7 @@ fn lookup_in_ty_params(e: env, name: ident, ty_params: ~[ast::ty_param])
fn lookup_in_pat(e: env, name: ident, pat: @ast::pat) -> option<node_id> { fn lookup_in_pat(e: env, name: ident, pat: @ast::pat) -> option<node_id> {
let mut found = none; let mut found = none;
pat_util::pat_bindings(e.def_map, pat) {|p_id, _sp, n| do pat_util::pat_bindings(e.def_map, pat) {|p_id, _sp, n|
if str::eq(*path_to_ident(n), *name) if str::eq(*path_to_ident(n), *name)
{ found = some(p_id); } { found = some(p_id); }
}; };
@ -1612,7 +1612,7 @@ fn index_view_items(view_items: ~[@ast::view_item],
_ {} _ {}
} }
iter_effective_import_paths(*vi) {|vp| do iter_effective_import_paths(*vi) {|vp|
alt vp.node { alt vp.node {
ast::view_path_simple(ident, _, id) { ast::view_path_simple(ident, _, id) {
add_to_index(index, ident, mie_import_ident(id, vp.span)); add_to_index(index, ident, mie_import_ident(id, vp.span));
@ -1793,7 +1793,7 @@ fn check_item(e: @env, i: @ast::item, &&x: (), v: vt<()>) {
} }
fn check_pat(e: @env, ch: checker, p: @ast::pat) { fn check_pat(e: @env, ch: checker, p: @ast::pat) {
pat_util::pat_bindings(e.def_map, p) {|_i, p_sp, n| do pat_util::pat_bindings(e.def_map, p) {|_i, p_sp, n|
add_name(ch, p_sp, path_to_ident(n)); add_name(ch, p_sp, path_to_ident(n));
}; };
} }
@ -1840,7 +1840,7 @@ fn check_block(e: @env, b: ast::blk, &&x: (), v: vt<()>) {
ast::decl_local(locs) { ast::decl_local(locs) {
let local_values = checker(*e, "value"); let local_values = checker(*e, "value");
for locs.each {|loc| for locs.each {|loc|
pat_util::pat_bindings(e.def_map, loc.node.pat) do pat_util::pat_bindings(e.def_map, loc.node.pat)
{|_i, p_sp, n| {|_i, p_sp, n|
let ident = path_to_ident(n); let ident = path_to_ident(n);
add_name(local_values, p_sp, ident); add_name(local_values, p_sp, ident);
@ -1943,7 +1943,7 @@ fn check_exports(e: @env) {
let ixm = e.mod_map.get(mid.node); let ixm = e.mod_map.get(mid.node);
for ixm.index.each {|ident, mies| for ixm.index.each {|ident, mies|
list::iter(mies) {|mie| do list::iter(mies) {|mie|
alt mie { alt mie {
mie_item(item) { mie_item(item) {
let defs = let defs =
@ -1984,7 +1984,7 @@ fn check_exports(e: @env) {
fn maybe_add_reexport(e: @env, export_id: node_id, def: option<def>) { fn maybe_add_reexport(e: @env, export_id: node_id, def: option<def>) {
option::iter(def) {|def| do option::iter(def) {|def|
add_export(e, export_id, def_id_of_def(def), true); add_export(e, export_id, def_id_of_def(def), true);
} }
} }
@ -2004,7 +2004,7 @@ fn check_exports(e: @env) {
if _mod.index.contains_key(ident) { if _mod.index.contains_key(ident) {
found_something = true; found_something = true;
let xs = _mod.index.get(ident); let xs = _mod.index.get(ident);
list::iter(xs) {|x| do list::iter(xs) {|x|
alt x { alt x {
mie_import_ident(id, _) { mie_import_ident(id, _) {
alt check e.imports.get(id) { alt check e.imports.get(id) {
@ -2045,7 +2045,7 @@ fn check_exports(e: @env) {
e.sess.span_fatal(sp, #fmt("undefined id %s in an export", *id)); e.sess.span_fatal(sp, #fmt("undefined id %s in an export", *id));
} }
some(ms) { some(ms) {
let maybe_id = list_search(ms) {|m| let maybe_id = do list_search(ms) {|m|
alt m { alt m {
mie_item(@{node: item_enum(_, _, _), id, _}) { some(id) } mie_item(@{node: item_enum(_, _, _), id, _}) { some(id) }
_ { none } _ { none }
@ -2069,7 +2069,7 @@ fn check_exports(e: @env) {
let mut found = false; let mut found = false;
alt _mod.index.find(variant_id.node.name) { alt _mod.index.find(variant_id.node.name) {
some(ms) { some(ms) {
list::iter(ms) {|m| do list::iter(ms) {|m|
alt m { alt m {
mie_enum_variant(_, _, actual_parent_id, _) { mie_enum_variant(_, _, actual_parent_id, _) {
found = true; found = true;
@ -2099,7 +2099,7 @@ fn check_exports(e: @env) {
let glob_is_re_exported = int_hash(); let glob_is_re_exported = int_hash();
for m.view_items.each {|vi| for m.view_items.each {|vi|
iter_export_paths(*vi) { |vp| do iter_export_paths(*vi) { |vp|
alt vp.node { alt vp.node {
ast::view_path_simple(ident, _, id) { ast::view_path_simple(ident, _, id) {
check_export(e, ident, _mod, id, vi); check_export(e, ident, _mod, id, vi);
@ -2126,7 +2126,7 @@ fn check_exports(e: @env) {
ast::view_path_glob(_, node_id) { node_id } ast::view_path_glob(_, node_id) { node_id }
}; };
if ! glob_is_re_exported.contains_key(id) { cont; } if ! glob_is_re_exported.contains_key(id) { cont; }
iter_mod(*e, glob.def, do iter_mod(*e, glob.def,
glob.path.span, outside) {|ident, def| glob.path.span, outside) {|ident, def|
vec::push(_mod.globbed_exports, ident); vec::push(_mod.globbed_exports, ident);
maybe_add_reexport(e, id, some(def)); maybe_add_reexport(e, id, some(def));
@ -2177,13 +2177,13 @@ fn find_impls_in_view_item(e: env, vi: @ast::view_item,
} }
} }
iter_effective_import_paths(*vi) { |vp| do iter_effective_import_paths(*vi) { |vp|
alt vp.node { alt vp.node {
ast::view_path_simple(name, pt, id) { ast::view_path_simple(name, pt, id) {
let mut found = ~[]; let mut found = ~[];
if vec::len(pt.idents) == 1u { if vec::len(pt.idents) == 1u {
option::iter(sc) {|sc| do option::iter(sc) {|sc|
list::iter(sc) {|level| do list::iter(sc) {|level|
if vec::len(found) == 0u { if vec::len(found) == 0u {
for vec::each(*level) {|imp| for vec::each(*level) {|imp|
if imp.ident == pt.idents[0] { if imp.ident == pt.idents[0] {
@ -2198,7 +2198,7 @@ fn find_impls_in_view_item(e: env, vi: @ast::view_item,
} }
} }
} else { } else {
lookup_imported_impls(e, id) {|is| do lookup_imported_impls(e, id) {|is|
for vec::each(*is) {|i| for vec::each(*is) {|i|
vec::push(impls, @{ident: name with *i}); vec::push(impls, @{ident: name with *i});
} }
@ -2208,9 +2208,9 @@ fn find_impls_in_view_item(e: env, vi: @ast::view_item,
ast::view_path_list(base, names, _) { ast::view_path_list(base, names, _) {
for names.each {|nm| for names.each {|nm|
lookup_imported_impls(e, nm.node.id) {|is| lookup_imported_impls(e, nm.node.id, {|is|
vec::push_all(impls, *is); vec::push_all(impls, *is);
} })
} }
} }
@ -2256,7 +2256,7 @@ fn find_impls_in_item(e: env, i: @ast::item, &impls: ~[@_impl],
ast::item_class(tps, ifces, items, _, _, _) { ast::item_class(tps, ifces, items, _, _, _) {
let (_, mthds) = ast_util::split_class_items(items); let (_, mthds) = ast_util::split_class_items(items);
let n_tps = tps.len(); let n_tps = tps.len();
vec::iter(ifces) {|p| do vec::iter(ifces) {|p|
// The def_id, in this case, identifies the combination of // The def_id, in this case, identifies the combination of
// class and iface // class and iface
vec::push(impls, @{did: local_def(p.id), vec::push(impls, @{did: local_def(p.id),
@ -2289,7 +2289,7 @@ fn find_impls_in_mod_by_id(e: env, defid: def_id, &impls: ~[@_impl],
for md.items.each {|i| for md.items.each {|i|
find_impls_in_item(e, i, tmp, none, none); find_impls_in_item(e, i, tmp, none, none);
} }
@vec::filter(tmp) {|i| is_exported(e, i.ident, mi)} @vec::filter(tmp, {|i| is_exported(e, i.ident, mi)})
} else { } else {
csearch::get_impls_for_mod(e.sess.cstore, defid, none) csearch::get_impls_for_mod(e.sess.cstore, defid, none)
}; };

View file

@ -153,7 +153,7 @@ fn enter_match(dm: def_map, m: match, col: uint, val: ValueRef,
} }
fn enter_default(dm: def_map, m: match, col: uint, val: ValueRef) -> match { fn enter_default(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
enter_match(dm, m, col, val) {|p| do enter_match(dm, m, col, val) {|p|
alt p.node { alt p.node {
ast::pat_wild | ast::pat_rec(_, _) | ast::pat_tup(_) { some(~[]) } ast::pat_wild | ast::pat_rec(_, _) | ast::pat_tup(_) { some(~[]) }
ast::pat_ident(_, none) if !pat_is_variant(dm, p) { ast::pat_ident(_, none) if !pat_is_variant(dm, p) {
@ -167,7 +167,7 @@ fn enter_default(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
fn enter_opt(tcx: ty::ctxt, m: match, opt: opt, col: uint, fn enter_opt(tcx: ty::ctxt, m: match, opt: opt, col: uint,
variant_size: uint, val: ValueRef) -> match { variant_size: uint, val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
enter_match(tcx.def_map, m, col, val) {|p| do enter_match(tcx.def_map, m, col, val) {|p|
alt p.node { alt p.node {
ast::pat_enum(_, subpats) { ast::pat_enum(_, subpats) {
if opt_eq(tcx, variant_opt(tcx, p.id), opt) { if opt_eq(tcx, variant_opt(tcx, p.id), opt) {
@ -193,7 +193,7 @@ fn enter_opt(tcx: ty::ctxt, m: match, opt: opt, col: uint,
fn enter_rec(dm: def_map, m: match, col: uint, fields: ~[ast::ident], fn enter_rec(dm: def_map, m: match, col: uint, fields: ~[ast::ident],
val: ValueRef) -> match { val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
enter_match(dm, m, col, val) {|p| do enter_match(dm, m, col, val) {|p|
alt p.node { alt p.node {
ast::pat_rec(fpats, _) { ast::pat_rec(fpats, _) {
let mut pats = ~[]; let mut pats = ~[];
@ -214,7 +214,7 @@ fn enter_rec(dm: def_map, m: match, col: uint, fields: ~[ast::ident],
fn enter_tup(dm: def_map, m: match, col: uint, val: ValueRef, fn enter_tup(dm: def_map, m: match, col: uint, val: ValueRef,
n_elts: uint) -> match { n_elts: uint) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
enter_match(dm, m, col, val) {|p| do enter_match(dm, m, col, val) {|p|
alt p.node { alt p.node {
ast::pat_tup(elts) { some(elts) } ast::pat_tup(elts) { some(elts) }
_ { some(vec::from_elem(n_elts, dummy)) } _ { some(vec::from_elem(n_elts, dummy)) }
@ -224,7 +224,7 @@ fn enter_tup(dm: def_map, m: match, col: uint, val: ValueRef,
fn enter_box(dm: def_map, m: match, col: uint, val: ValueRef) -> match { fn enter_box(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
enter_match(dm, m, col, val) {|p| do enter_match(dm, m, col, val) {|p|
alt p.node { alt p.node {
ast::pat_box(sub) { some(~[sub]) } ast::pat_box(sub) { some(~[sub]) }
_ { some(~[dummy]) } _ { some(~[dummy]) }
@ -234,7 +234,7 @@ fn enter_box(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
fn enter_uniq(dm: def_map, m: match, col: uint, val: ValueRef) -> match { fn enter_uniq(dm: def_map, m: match, col: uint, val: ValueRef) -> match {
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
enter_match(dm, m, col, val) {|p| do enter_match(dm, m, col, val) {|p|
alt p.node { alt p.node {
ast::pat_uniq(sub) { some(~[sub]) } ast::pat_uniq(sub) { some(~[sub]) }
_ { some(~[dummy]) } _ { some(~[dummy]) }
@ -285,7 +285,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
} }
let vdefs_tg = vdefs.enm; let vdefs_tg = vdefs.enm;
let vdefs_var = vdefs.var; let vdefs_var = vdefs.var;
let args = vec::from_fn(size) { |i| let args = do vec::from_fn(size) { |i|
GEP_enum(bcx, blobptr, vdefs_tg, vdefs_var, GEP_enum(bcx, blobptr, vdefs_tg, vdefs_var,
enum_ty_substs, i) enum_ty_substs, i)
}; };
@ -398,11 +398,11 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef],
bcx.fcx.lllocals.insert(val, loc); bcx.fcx.lllocals.insert(val, loc);
}; };
let {bcx: guard_cx, val} = { let {bcx: guard_cx, val} = {
with_scope_result(bcx, e.info(), "guard") {|bcx| do with_scope_result(bcx, e.info(), "guard") {|bcx|
trans_temp_expr(bcx, e) trans_temp_expr(bcx, e)
} }
}; };
bcx = with_cond(guard_cx, Not(guard_cx, val)) {|bcx| bcx = do with_cond(guard_cx, Not(guard_cx, val)) {|bcx|
compile_submatch(bcx, vec::tail(m), vals, chk, exits); compile_submatch(bcx, vec::tail(m), vals, chk, exits);
bcx bcx
}; };
@ -553,7 +553,7 @@ fn compile_submatch(bcx: block, m: match, vals: ~[ValueRef],
compare { compare {
let t = node_id_type(bcx, pat_id); let t = node_id_type(bcx, pat_id);
let {bcx: after_cx, val: matches} = { let {bcx: after_cx, val: matches} = {
with_scope_result(bcx, none, "compare_scope") {|bcx| do with_scope_result(bcx, none, "compare_scope") {|bcx|
alt trans_opt(bcx, opt) { alt trans_opt(bcx, opt) {
single_result({bcx, val}) { single_result({bcx, val}) {
trans_compare(bcx, ast::eq, test_val, t, val, t) trans_compare(bcx, ast::eq, test_val, t, val, t)
@ -636,7 +636,7 @@ fn trans_alt(bcx: block,
mode: ast::alt_mode, mode: ast::alt_mode,
dest: dest) -> block { dest: dest) -> block {
let _icx = bcx.insn_ctxt("alt::trans_alt"); let _icx = bcx.insn_ctxt("alt::trans_alt");
with_scope(bcx, alt_expr.info(), "alt") {|bcx| do with_scope(bcx, alt_expr.info(), "alt") {|bcx|
trans_alt_inner(bcx, expr, arms, mode, dest) trans_alt_inner(bcx, expr, arms, mode, dest)
} }
} }
@ -728,7 +728,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
let vdefs = ast_util::variant_def_ids(ccx.tcx.def_map.get(pat.id)); let vdefs = ast_util::variant_def_ids(ccx.tcx.def_map.get(pat.id));
let args = extract_variant_args(bcx, pat.id, vdefs, val); let args = extract_variant_args(bcx, pat.id, vdefs, val);
let mut i = 0; let mut i = 0;
option::iter(sub) {|sub| for vec::each(args.vals) {|argval| do option::iter(sub) {|sub| for vec::each(args.vals) {|argval|
bcx = bind_irrefutable_pat(bcx, sub[i], argval, make_copy); bcx = bind_irrefutable_pat(bcx, sub[i], argval, make_copy);
i += 1; i += 1;
}} }}

View file

@ -733,7 +733,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
} }
ty::ty_class(did,substs) { ty::ty_class(did,substs) {
// Call the dtor if there is one // Call the dtor if there is one
option::map_default(ty::ty_dtor(bcx.tcx(), did), bcx) {|dt_id| do option::map_default(ty::ty_dtor(bcx.tcx(), did), bcx) {|dt_id|
trans_class_drop(bcx, v, dt_id, did, substs) trans_class_drop(bcx, v, dt_id, did, substs)
} }
} }
@ -746,7 +746,7 @@ fn trans_class_drop(bcx: block, v0: ValueRef, dtor_did: ast::def_id,
class_did: ast::def_id, class_did: ast::def_id,
substs: ty::substs) -> block { substs: ty::substs) -> block {
let drop_flag = GEPi(bcx, v0, ~[0u, 0u]); let drop_flag = GEPi(bcx, v0, ~[0u, 0u]);
with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) {|cx| do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) {|cx|
let mut bcx = cx; let mut bcx = cx;
// We have to cast v0 // We have to cast v0
let classptr = GEPi(bcx, v0, ~[0u, 1u]); let classptr = GEPi(bcx, v0, ~[0u, 1u]);
@ -864,12 +864,12 @@ fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block {
let llbox_ty = T_opaque_box_ptr(ccx); let llbox_ty = T_opaque_box_ptr(ccx);
let box_ptr = PointerCast(bcx, box_ptr, llbox_ty); let box_ptr = PointerCast(bcx, box_ptr, llbox_ty);
with_cond(bcx, IsNotNull(bcx, box_ptr)) {|bcx| do with_cond(bcx, IsNotNull(bcx, box_ptr)) {|bcx|
let rc_ptr = GEPi(bcx, box_ptr, ~[0u, abi::box_field_refcnt]); let rc_ptr = GEPi(bcx, box_ptr, ~[0u, abi::box_field_refcnt]);
let rc = Sub(bcx, Load(bcx, rc_ptr), C_int(ccx, 1)); let rc = Sub(bcx, Load(bcx, rc_ptr), C_int(ccx, 1));
Store(bcx, rc, rc_ptr); Store(bcx, rc, rc_ptr);
let zero_test = ICmp(bcx, lib::llvm::IntEQ, C_int(ccx, 0), rc); let zero_test = ICmp(bcx, lib::llvm::IntEQ, C_int(ccx, 0), rc);
with_cond(bcx, zero_test) {|bcx| free_ty(bcx, box_ptr, t)} with_cond(bcx, zero_test, {|bcx| free_ty(bcx, box_ptr, t)})
} }
} }
@ -1354,7 +1354,7 @@ fn copy_val(cx: block, action: copy_action, dst: ValueRef,
let dstcmp = load_if_immediate(cx, dst, t); let dstcmp = load_if_immediate(cx, dst, t);
let cast = PointerCast(cx, dstcmp, val_ty(src)); let cast = PointerCast(cx, dstcmp, val_ty(src));
// Self-copy check // Self-copy check
with_cond(cx, ICmp(cx, lib::llvm::IntNE, cast, src)) {|bcx| do with_cond(cx, ICmp(cx, lib::llvm::IntNE, cast, src)) {|bcx|
copy_val_no_check(bcx, action, dst, src, t) copy_val_no_check(bcx, action, dst, src, t)
} }
} else { } else {
@ -1637,7 +1637,7 @@ fn fail_if_zero(cx: block, span: span, divmod: ast::binop,
ty_to_str(cx.ccx().tcx, rhs_t)); ty_to_str(cx.ccx().tcx, rhs_t));
} }
}; };
with_cond(cx, is_zero) {|bcx| do with_cond(cx, is_zero) {|bcx|
trans_fail(bcx, some(span), text) trans_fail(bcx, some(span), text)
} }
} }
@ -1870,7 +1870,7 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr,
b: @ast::expr, dest: dest) -> block { b: @ast::expr, dest: dest) -> block {
let _icx = bcx.insn_ctxt("trans_lazy_binop"); let _icx = bcx.insn_ctxt("trans_lazy_binop");
let {bcx: past_lhs, val: lhs} = { let {bcx: past_lhs, val: lhs} = {
with_scope_result(bcx, a.info(), "lhs") { |bcx| do with_scope_result(bcx, a.info(), "lhs") { |bcx|
trans_temp_expr(bcx, a) trans_temp_expr(bcx, a)
} }
}; };
@ -1882,7 +1882,7 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr,
lazy_or { CondBr(past_lhs, lhs, join.llbb, before_rhs.llbb); } lazy_or { CondBr(past_lhs, lhs, join.llbb, before_rhs.llbb); }
} }
let {bcx: past_rhs, val: rhs} = { let {bcx: past_rhs, val: rhs} = {
with_scope_result(before_rhs, b.info(), "rhs") { |bcx| do with_scope_result(before_rhs, b.info(), "rhs") { |bcx|
trans_temp_expr(bcx, b) trans_temp_expr(bcx, b)
} }
}; };
@ -2331,7 +2331,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id)
ast::item_enum(_, _, _) { ast::item_enum(_, _, _) {
let vs_here = ty::enum_variants(ccx.tcx, local_def(item.id)); let vs_here = ty::enum_variants(ccx.tcx, local_def(item.id));
let vs_there = ty::enum_variants(ccx.tcx, parent_id); let vs_there = ty::enum_variants(ccx.tcx, parent_id);
vec::iter2(*vs_here, *vs_there) {|here, there| do vec::iter2(*vs_here, *vs_there) {|here, there|
if there.id == fn_id { my_id = here.id.node; } if there.id == fn_id { my_id = here.id.node; }
ccx.external.insert(there.id, some(here.id.node)); ccx.external.insert(there.id, some(here.id.node));
} }
@ -2622,7 +2622,7 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr,
#debug("trans_index: len %s", val_str(bcx.ccx().tn, len)); #debug("trans_index: len %s", val_str(bcx.ccx().tn, len));
let bounds_check = ICmp(bcx, lib::llvm::IntUGE, scaled_ix, len); let bounds_check = ICmp(bcx, lib::llvm::IntUGE, scaled_ix, len);
let bcx = with_cond(bcx, bounds_check) {|bcx| let bcx = do with_cond(bcx, bounds_check) {|bcx|
// fail: bad bounds check. // fail: bad bounds check.
trans_fail(bcx, some(ex.span), "bounds check") trans_fail(bcx, some(ex.span), "bounds check")
}; };
@ -3109,7 +3109,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t,
arg_exprs(es) { arg_exprs(es) {
let llarg_tys = type_of_explicit_args(ccx, arg_tys); let llarg_tys = type_of_explicit_args(ccx, arg_tys);
let last = es.len() - 1u; let last = es.len() - 1u;
vec::iteri(es) {|i, e| do vec::iteri(es) {|i, e|
let r = trans_arg_expr(bcx, arg_tys[i], llarg_tys[i], let r = trans_arg_expr(bcx, arg_tys[i], llarg_tys[i],
e, temp_cleanups, if i == last { ret_flag } e, temp_cleanups, if i == last { ret_flag }
else { none }, 0u); else { none }, 0u);
@ -3125,7 +3125,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t,
// now that all arguments have been successfully built, we can revoke any // now that all arguments have been successfully built, we can revoke any
// temporary cleanups, as they are only needed if argument construction // temporary cleanups, as they are only needed if argument construction
// should fail (for example, cleanup of copy mode args). // should fail (for example, cleanup of copy mode args).
vec::iter(temp_cleanups) {|c| do vec::iter(temp_cleanups) {|c|
revoke_clean(bcx, c) revoke_clean(bcx, c)
} }
@ -3169,7 +3169,7 @@ fn trans_call_inner(
args: call_args, args: call_args,
dest: dest) -> block { dest: dest) -> block {
with_scope(in_cx, call_info, "call") {|cx| do with_scope(in_cx, call_info, "call") {|cx|
let ret_in_loop = alt args { let ret_in_loop = alt args {
arg_exprs(args) { args.len() > 0u && alt vec::last(args).node { arg_exprs(args) { args.len() > 0u && alt vec::last(args).node {
ast::expr_loop_body(@{node: ast::expr_fn_block(_, body, _), _}) { ast::expr_loop_body(@{node: ast::expr_fn_block(_, body, _), _}) {
@ -3237,8 +3237,8 @@ fn trans_call_inner(
if ty::type_is_bot(ret_ty) { if ty::type_is_bot(ret_ty) {
Unreachable(bcx); Unreachable(bcx);
} else if ret_in_loop { } else if ret_in_loop {
bcx = with_cond(bcx, Load(bcx, option::get(ret_flag))) {|bcx| bcx = do with_cond(bcx, Load(bcx, option::get(ret_flag))) {|bcx|
option::iter(copy bcx.fcx.loop_ret) {|lret| do option::iter(copy bcx.fcx.loop_ret) {|lret|
Store(bcx, C_bool(true), lret.flagptr); Store(bcx, C_bool(true), lret.flagptr);
Store(bcx, C_bool(false), bcx.fcx.llretptr); Store(bcx, C_bool(false), bcx.fcx.llretptr);
} }
@ -3297,7 +3297,7 @@ fn need_invoke(bcx: block) -> bool {
fn have_cached_lpad(bcx: block) -> bool { fn have_cached_lpad(bcx: block) -> bool {
let mut res = false; let mut res = false;
in_lpad_scope_cx(bcx) {|inf| do in_lpad_scope_cx(bcx) {|inf|
alt inf.landing_pad { alt inf.landing_pad {
some(_) { res = true; } some(_) { res = true; }
none { res = false; } none { res = false; }
@ -3325,7 +3325,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef {
let _icx = bcx.insn_ctxt("get_landing_pad"); let _icx = bcx.insn_ctxt("get_landing_pad");
let mut cached = none, pad_bcx = bcx; // Guaranteed to be set below let mut cached = none, pad_bcx = bcx; // Guaranteed to be set below
in_lpad_scope_cx(bcx) {|inf| do in_lpad_scope_cx(bcx) {|inf|
// If there is a valid landing pad still around, use it // If there is a valid landing pad still around, use it
alt copy inf.landing_pad { alt copy inf.landing_pad {
some(target) { cached = some(target); } some(target) { cached = some(target); }
@ -3585,7 +3585,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
ret alt::trans_alt(bcx, e, expr, arms, mode, dest); ret alt::trans_alt(bcx, e, expr, arms, mode, dest);
} }
ast::expr_block(blk) { ast::expr_block(blk) {
ret with_scope(bcx, blk.info(), "block-expr body") {|bcx| ret do with_scope(bcx, blk.info(), "block-expr body") {|bcx|
trans_block(bcx, blk, dest) trans_block(bcx, blk, dest)
}; };
} }
@ -3697,7 +3697,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
otherwise. */ otherwise. */
let c = get_extern_const(bcx.ccx().externs, bcx.ccx().llmod, let c = get_extern_const(bcx.ccx().externs, bcx.ccx().llmod,
"check_claims", T_bool()); "check_claims", T_bool());
ret with_cond(bcx, Load(bcx, c)) {|bcx| ret do with_cond(bcx, Load(bcx, c)) {|bcx|
trans_check_expr(bcx, e, a, "Claim") trans_check_expr(bcx, e, a, "Claim")
}; };
} }
@ -3895,13 +3895,14 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr,
}; };
let current_level = Load(bcx, global); let current_level = Load(bcx, global);
let {bcx, val: level} = { let {bcx, val: level} = {
with_scope_result(bcx, lvl.info(), "level") {|bcx| do with_scope_result(bcx, lvl.info(), "level") {|bcx|
trans_temp_expr(bcx, lvl) trans_temp_expr(bcx, lvl)
} }
}; };
with_cond(bcx, ICmp(bcx, lib::llvm::IntUGE, current_level, level)) {|bcx| do with_cond(bcx, ICmp(bcx, lib::llvm::IntUGE, current_level, level)) {
with_scope(bcx, log_ex.info(), "log") {|bcx| |bcx|
do with_scope(bcx, log_ex.info(), "log") {|bcx|
let {bcx, val, _} = trans_temp_expr(bcx, e); let {bcx, val, _} = trans_temp_expr(bcx, e);
let e_ty = expr_ty(bcx, e); let e_ty = expr_ty(bcx, e);
let tydesc = get_tydesc_simple(ccx, e_ty); let tydesc = get_tydesc_simple(ccx, e_ty);
@ -3919,11 +3920,11 @@ fn trans_check_expr(bcx: block, chk_expr: @ast::expr,
let _icx = bcx.insn_ctxt("trans_check_expr"); let _icx = bcx.insn_ctxt("trans_check_expr");
let expr_str = s + " " + expr_to_str(pred_expr) + " failed"; let expr_str = s + " " + expr_to_str(pred_expr) + " failed";
let {bcx, val} = { let {bcx, val} = {
with_scope_result(bcx, chk_expr.info(), "check") {|bcx| do with_scope_result(bcx, chk_expr.info(), "check") {|bcx|
trans_temp_expr(bcx, pred_expr) trans_temp_expr(bcx, pred_expr)
} }
}; };
with_cond(bcx, Not(bcx, val)) {|bcx| do with_cond(bcx, Not(bcx, val)) {|bcx|
trans_fail(bcx, some(pred_expr.span), expr_str) trans_fail(bcx, some(pred_expr.span), expr_str)
} }
} }
@ -4159,7 +4160,7 @@ fn new_block(cx: fn_ctxt, parent: option<block>, +kind: block_kind,
llvm::LLVMAppendBasicBlock(cx.llfn, buf) llvm::LLVMAppendBasicBlock(cx.llfn, buf)
}); });
let bcx = mk_block(llbb, parent, kind, opt_node_info, cx); let bcx = mk_block(llbb, parent, kind, opt_node_info, cx);
option::iter(parent) {|cx| do option::iter(parent) {|cx|
if cx.unreachable { Unreachable(bcx); } if cx.unreachable { Unreachable(bcx); }
}; };
ret bcx; ret bcx;
@ -4223,7 +4224,7 @@ fn trans_block_cleanups_(bcx: block, cleanup_cx: block, is_lpad: bool) ->
alt check cleanup_cx.kind { alt check cleanup_cx.kind {
block_scope({cleanups, _}) { block_scope({cleanups, _}) {
let cleanups = copy cleanups; let cleanups = copy cleanups;
vec::riter(cleanups) {|cu| do vec::riter(cleanups) {|cu|
alt cu { alt cu {
clean(cfn, cleanup_type) | clean_temp(_, cfn, cleanup_type) { clean(cfn, cleanup_type) | clean_temp(_, cfn, cleanup_type) {
// Some types don't need to be cleaned up during // Some types don't need to be cleaned up during
@ -4361,7 +4362,7 @@ fn alloc_local(cx: block, local: @ast::local) -> block {
}; };
let val = alloc_ty(cx, t); let val = alloc_ty(cx, t);
if cx.sess().opts.debuginfo { if cx.sess().opts.debuginfo {
option::iter(simple_name) {|name| do option::iter(simple_name) {|name|
str::as_c_str(*name, {|buf| str::as_c_str(*name, {|buf|
llvm::LLVMSetValueName(val, buf) llvm::LLVMSetValueName(val, buf)
}); });
@ -4375,7 +4376,7 @@ fn trans_block(bcx: block, b: ast::blk, dest: dest)
-> block { -> block {
let _icx = bcx.insn_ctxt("trans_block"); let _icx = bcx.insn_ctxt("trans_block");
let mut bcx = bcx; let mut bcx = bcx;
block_locals(b) {|local| bcx = alloc_local(bcx, local); }; do block_locals(b) {|local| bcx = alloc_local(bcx, local); };
for vec::each(b.node.stmts) {|s| for vec::each(b.node.stmts) {|s|
debuginfo::update_source_pos(bcx, b.span); debuginfo::update_source_pos(bcx, b.span);
bcx = trans_stmt(bcx, *s); bcx = trans_stmt(bcx, *s);
@ -4871,7 +4872,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
/* Look up the parent class's def_id */ /* Look up the parent class's def_id */
let mut class_ty = ty::lookup_item_type(tcx, parent_id).ty; let mut class_ty = ty::lookup_item_type(tcx, parent_id).ty;
/* Substitute in the class type if necessary */ /* Substitute in the class type if necessary */
option::iter(psubsts) {|ss| do option::iter(psubsts) {|ss|
class_ty = ty::subst_tps(tcx, ss.tys, class_ty); class_ty = ty::subst_tps(tcx, ss.tys, class_ty);
} }
@ -4889,7 +4890,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
/* If we're monomorphizing, register the monomorphized decl /* If we're monomorphizing, register the monomorphized decl
for the dtor */ for the dtor */
option::iter(hash_id) {|h_id| do option::iter(hash_id) {|h_id|
ccx.monomorphized.insert(h_id, lldecl); ccx.monomorphized.insert(h_id, lldecl);
} }
/* Translate the dtor body */ /* Translate the dtor body */
@ -4966,7 +4967,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
trans_class_ctor(ccx, *path, ctor.node.dec, ctor.node.body, trans_class_ctor(ccx, *path, ctor.node.dec, ctor.node.body,
get_item_val(ccx, ctor.node.id), psubsts, get_item_val(ccx, ctor.node.id), psubsts,
ctor.node.id, local_def(item.id), ctor.span); ctor.node.id, local_def(item.id), ctor.span);
option::iter(m_dtor) {|dtor| do option::iter(m_dtor) {|dtor|
trans_class_dtor(ccx, *path, dtor.node.body, trans_class_dtor(ccx, *path, dtor.node.body,
dtor.node.id, none, none, local_def(item.id)); dtor.node.id, none, none, local_def(item.id));
}; };

View file

@ -672,7 +672,7 @@ fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
#debug["Call(Fn=%s, Args=%?)", #debug["Call(Fn=%s, Args=%?)",
val_str(cx.ccx().tn, Fn), val_str(cx.ccx().tn, Fn),
Args.map { |arg| val_str(cx.ccx().tn, arg) }]; Args.map({ |arg| val_str(cx.ccx().tn, arg) })];
ret llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), ret llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
Args.len() as c_uint, noname()); Args.len() as c_uint, noname());

View file

@ -233,7 +233,7 @@ fn store_environment(bcx: block,
// Copy expr values into boxed bindings. // Copy expr values into boxed bindings.
let mut bcx = bcx; let mut bcx = bcx;
vec::iteri(bound_values) { |i, bv| do vec::iteri(bound_values) { |i, bv|
#debug["Copy %s into closure", ev_to_str(ccx, bv)]; #debug["Copy %s into closure", ev_to_str(ccx, bv)];
if !ccx.sess.no_asm_comments() { if !ccx.sess.no_asm_comments() {
@ -294,7 +294,7 @@ fn build_closure(bcx0: block,
let ccx = bcx.ccx(), tcx = ccx.tcx; let ccx = bcx.ccx(), tcx = ccx.tcx;
// Package up the captured upvars // Package up the captured upvars
vec::iter(cap_vars) { |cap_var| do vec::iter(cap_vars) { |cap_var|
#debug["Building closure: captured variable %?", cap_var]; #debug["Building closure: captured variable %?", cap_var];
let lv = trans_local_var(bcx, cap_var.def); let lv = trans_local_var(bcx, cap_var.def);
let nid = ast_util::def_id_of_def(cap_var.def).node; let nid = ast_util::def_id_of_def(cap_var.def).node;
@ -323,7 +323,7 @@ fn build_closure(bcx0: block,
} }
} }
} }
option::iter(include_ret_handle) {|flagptr| do option::iter(include_ret_handle) {|flagptr|
let our_ret = alt bcx.fcx.loop_ret { let our_ret = alt bcx.fcx.loop_ret {
some({retptr, _}) { retptr } some({retptr, _}) { retptr }
none { bcx.fcx.llretptr } none { bcx.fcx.llretptr }
@ -354,7 +354,7 @@ fn load_environment(fcx: fn_ctxt,
// Populate the upvars from the environment. // Populate the upvars from the environment.
let mut i = 0u; let mut i = 0u;
vec::iter(cap_vars) { |cap_var| do vec::iter(cap_vars) { |cap_var|
alt cap_var.mode { alt cap_var.mode {
capture::cap_drop { /* ignore */ } capture::cap_drop { /* ignore */ }
_ { _ {
@ -504,7 +504,7 @@ fn make_fn_glue(
let fn_env = fn@(ck: ty::closure_kind) -> block { let fn_env = fn@(ck: ty::closure_kind) -> block {
let box_cell_v = GEPi(cx, v, ~[0u, abi::fn_field_box]); let box_cell_v = GEPi(cx, v, ~[0u, abi::fn_field_box]);
let box_ptr_v = Load(cx, box_cell_v); let box_ptr_v = Load(cx, box_cell_v);
with_cond(cx, IsNotNull(cx, box_ptr_v)) {|bcx| do with_cond(cx, IsNotNull(cx, box_ptr_v)) {|bcx|
let closure_ty = ty::mk_opaque_closure_ptr(tcx, ck); let closure_ty = ty::mk_opaque_closure_ptr(tcx, ck);
glue_fn(bcx, box_cell_v, closure_ty) glue_fn(bcx, box_cell_v, closure_ty)
} }
@ -537,7 +537,7 @@ fn make_opaque_cbox_take_glue(
let ccx = bcx.ccx(), tcx = ccx.tcx; let ccx = bcx.ccx(), tcx = ccx.tcx;
let llopaquecboxty = T_opaque_box_ptr(ccx); let llopaquecboxty = T_opaque_box_ptr(ccx);
let cbox_in = Load(bcx, cboxptr); let cbox_in = Load(bcx, cboxptr);
with_cond(bcx, IsNotNull(bcx, cbox_in)) {|bcx| do with_cond(bcx, IsNotNull(bcx, cbox_in)) {|bcx|
// Load the size from the type descr found in the cbox // Load the size from the type descr found in the cbox
let cbox_in = PointerCast(bcx, cbox_in, llopaquecboxty); let cbox_in = PointerCast(bcx, cbox_in, llopaquecboxty);
let tydescptr = GEPi(bcx, cbox_in, ~[0u, abi::box_field_tydesc]); let tydescptr = GEPi(bcx, cbox_in, ~[0u, abi::box_field_tydesc]);
@ -599,7 +599,7 @@ fn make_opaque_cbox_free_glue(
} }
let ccx = bcx.ccx(); let ccx = bcx.ccx();
with_cond(bcx, IsNotNull(bcx, cbox)) {|bcx| do with_cond(bcx, IsNotNull(bcx, cbox)) {|bcx|
// Load the type descr found in the cbox // Load the type descr found in the cbox
let lltydescty = T_ptr(ccx.tydesc_type); let lltydescty = T_ptr(ccx.tydesc_type);
let cbox = PointerCast(bcx, cbox, T_opaque_cbox_ptr(ccx)); let cbox = PointerCast(bcx, cbox, T_opaque_cbox_ptr(ccx));

View file

@ -251,7 +251,7 @@ fn add_clean(cx: block, val: ValueRef, ty: ty::t) {
cx.to_str(), val_str(cx.ccx().tn, val), cx.to_str(), val_str(cx.ccx().tn, val),
ty_to_str(cx.ccx().tcx, ty)]; ty_to_str(cx.ccx().tcx, ty)];
let cleanup_type = cleanup_type(cx.tcx(), ty); let cleanup_type = cleanup_type(cx.tcx(), ty);
in_scope_cx(cx) {|info| do in_scope_cx(cx) {|info|
vec::push(info.cleanups, clean({|a|base::drop_ty(a, val, ty)}, vec::push(info.cleanups, clean({|a|base::drop_ty(a, val, ty)},
cleanup_type)); cleanup_type));
scope_clean_changed(info); scope_clean_changed(info);
@ -271,7 +271,7 @@ fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) {
ret base::drop_ty(bcx, val, ty); ret base::drop_ty(bcx, val, ty);
} }
} }
in_scope_cx(cx) {|info| do in_scope_cx(cx) {|info|
vec::push(info.cleanups, clean_temp(val, {|a|do_drop(a, val, ty)}, vec::push(info.cleanups, clean_temp(val, {|a|do_drop(a, val, ty)},
cleanup_type)); cleanup_type));
scope_clean_changed(info); scope_clean_changed(info);
@ -283,7 +283,7 @@ fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) {
cx.to_str(), val_str(cx.ccx().tn, val), cx.to_str(), val_str(cx.ccx().tn, val),
ty_to_str(cx.ccx().tcx, ty)]; ty_to_str(cx.ccx().tcx, ty)];
let cleanup_type = cleanup_type(cx.tcx(), ty); let cleanup_type = cleanup_type(cx.tcx(), ty);
in_scope_cx(cx) {|info| do in_scope_cx(cx) {|info|
vec::push(info.cleanups, vec::push(info.cleanups,
clean_temp(val, {|a|base::drop_ty(a, val, ty)}, clean_temp(val, {|a|base::drop_ty(a, val, ty)},
cleanup_type)); cleanup_type));
@ -295,7 +295,7 @@ fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) {
heap_shared { {|a|base::trans_free(a, ptr)} } heap_shared { {|a|base::trans_free(a, ptr)} }
heap_exchange { {|a|base::trans_unique_free(a, ptr)} } heap_exchange { {|a|base::trans_unique_free(a, ptr)} }
}; };
in_scope_cx(cx) {|info| do in_scope_cx(cx) {|info|
vec::push(info.cleanups, clean_temp(ptr, free_fn, vec::push(info.cleanups, clean_temp(ptr, free_fn,
normal_exit_and_unwind)); normal_exit_and_unwind));
scope_clean_changed(info); scope_clean_changed(info);
@ -307,8 +307,8 @@ fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) {
// this will be more involved. For now, we simply zero out the local, and the // this will be more involved. For now, we simply zero out the local, and the
// drop glue checks whether it is zero. // drop glue checks whether it is zero.
fn revoke_clean(cx: block, val: ValueRef) { fn revoke_clean(cx: block, val: ValueRef) {
in_scope_cx(cx) {|info| do in_scope_cx(cx) {|info|
option::iter(vec::position(info.cleanups, {|cu| do option::iter(vec::position(info.cleanups, {|cu|
alt cu { clean_temp(v, _, _) if v == val { true } _ { false } } alt cu { clean_temp(v, _, _) if v == val { true } _ { false } }
})) {|i| })) {|i|
info.cleanups = info.cleanups =
@ -361,7 +361,7 @@ impl node_info for ast::blk {
impl node_info for option<@ast::expr> { impl node_info for option<@ast::expr> {
fn info() -> option<node_info> { fn info() -> option<node_info> {
self.chain { |s| s.info() } self.chain({ |s| s.info() })
} }
} }
@ -840,7 +840,7 @@ fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef {
none { } none { }
} }
let sc = str::as_c_str(s) {|buf| let sc = do str::as_c_str(s) {|buf|
llvm::LLVMConstString(buf, str::len(s) as c_uint, False) llvm::LLVMConstString(buf, str::len(s) as c_uint, False)
}; };
let g = let g =
@ -862,7 +862,7 @@ fn C_estr_slice(cx: @crate_ctxt, s: str) -> ValueRef {
// Returns a Plain Old LLVM String: // Returns a Plain Old LLVM String:
fn C_postr(s: str) -> ValueRef { fn C_postr(s: str) -> ValueRef {
ret str::as_c_str(s) {|buf| ret do str::as_c_str(s) {|buf|
llvm::LLVMConstString(buf, str::len(s) as c_uint, False) llvm::LLVMConstString(buf, str::len(s) as c_uint, False)
}; };
} }
@ -924,7 +924,7 @@ fn hash_mono_id(&&mi: mono_id) -> uint {
h = h * alt param { h = h * alt param {
mono_precise(ty, vts) { mono_precise(ty, vts) {
let mut h = ty::type_id(ty); let mut h = ty::type_id(ty);
option::iter(vts) {|vts| do option::iter(vts) {|vts|
for vec::each(vts) {|vt| h += hash_mono_id(vt); } for vec::each(vts) {|vt| h += hash_mono_id(vt); }
} }
h h
@ -980,7 +980,7 @@ fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] {
let params = ty::node_id_to_type_params(tcx, id); let params = ty::node_id_to_type_params(tcx, id);
alt bcx.fcx.param_substs { alt bcx.fcx.param_substs {
some(substs) { some(substs) {
vec::map(params) {|t| ty::subst_tps(tcx, substs.tys, t) } vec::map(params, {|t| ty::subst_tps(tcx, substs.tys, t) })
} }
_ { params } _ { params }
} }

View file

@ -67,7 +67,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
fn struct_tys(ty: TypeRef) -> ~[TypeRef] { fn struct_tys(ty: TypeRef) -> ~[TypeRef] {
let n = llvm::LLVMCountStructElementTypes(ty); let n = llvm::LLVMCountStructElementTypes(ty);
let elts = vec::from_elem(n as uint, ptr::null()); let elts = vec::from_elem(n as uint, ptr::null());
vec::as_buf(elts) {|buf| do vec::as_buf(elts) {|buf|
llvm::LLVMGetStructElementTypes(ty, buf); llvm::LLVMGetStructElementTypes(ty, buf);
} }
ret elts; ret elts;
@ -82,7 +82,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
2 /* float */ { 4u } 2 /* float */ { 4u }
3 /* double */ { 8u } 3 /* double */ { 8u }
10 /* struct */ { 10 /* struct */ {
vec::foldl(0u, struct_tys(ty)) {|a, t| do vec::foldl(0u, struct_tys(ty)) {|a, t|
uint::max(a, ty_align(t)) uint::max(a, ty_align(t))
} }
} }
@ -105,7 +105,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
2 /* float */ { 4u } 2 /* float */ { 4u }
3 /* double */ { 8u } 3 /* double */ { 8u }
10 /* struct */ { 10 /* struct */ {
vec::foldl(0u, struct_tys(ty)) {|s, t| do vec::foldl(0u, struct_tys(ty)) {|s, t|
s + ty_size(t) s + ty_size(t)
} }
} }
@ -404,12 +404,12 @@ fn x86_64_tys(atys: ~[TypeRef],
fn decl_x86_64_fn(tys: x86_64_tys, fn decl_x86_64_fn(tys: x86_64_tys,
decl: fn(fnty: TypeRef) -> ValueRef) -> ValueRef { decl: fn(fnty: TypeRef) -> ValueRef) -> ValueRef {
let atys = vec::map(tys.arg_tys) {|t| t.ty }; let atys = vec::map(tys.arg_tys, {|t| t.ty });
let rty = tys.ret_ty.ty; let rty = tys.ret_ty.ty;
let fnty = T_fn(atys, rty); let fnty = T_fn(atys, rty);
let llfn = decl(fnty); let llfn = decl(fnty);
vec::iteri(tys.attrs) {|i, a| do vec::iteri(tys.attrs) {|i, a|
alt a { alt a {
option::some(attr) { option::some(attr) {
let llarg = get_param(llfn, i); let llarg = get_param(llfn, i);
@ -640,7 +640,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
let _icx = bcx.insn_ctxt("foreign::shim::build_ret"); let _icx = bcx.insn_ctxt("foreign::shim::build_ret");
alt tys.x86_64_tys { alt tys.x86_64_tys {
some(x86_64) { some(x86_64) {
vec::iteri(x86_64.attrs) {|i, a| do vec::iteri(x86_64.attrs) {|i, a|
alt a { alt a {
some(attr) { some(attr) {
llvm::LLVMAddInstrAttribute( llvm::LLVMAddInstrAttribute(
@ -691,7 +691,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
// Declare the "prototype" for the base function F: // Declare the "prototype" for the base function F:
alt tys.x86_64_tys { alt tys.x86_64_tys {
some(x86_64) { some(x86_64) {
decl_x86_64_fn(x86_64) {|fnty| do decl_x86_64_fn(x86_64) {|fnty|
decl_fn(ccx.llmod, lname, cc, fnty) decl_fn(ccx.llmod, lname, cc, fnty)
} }
} }
@ -1153,7 +1153,7 @@ fn register_extern_fn(ccx: @crate_ctxt, sp: span,
ret if ccx.sess.targ_cfg.arch == arch_x86_64 { ret if ccx.sess.targ_cfg.arch == arch_x86_64 {
let ret_def = !ty::type_is_bot(ret_ty) && !ty::type_is_nil(ret_ty); let ret_def = !ty::type_is_bot(ret_ty) && !ty::type_is_nil(ret_ty);
let x86_64 = x86_64_tys(llargtys, llretty, ret_def); let x86_64 = x86_64_tys(llargtys, llretty, ret_def);
decl_x86_64_fn(x86_64) {|fnty| do decl_x86_64_fn(x86_64) {|fnty|
register_fn_fuller(ccx, sp, path, node_id, register_fn_fuller(ccx, sp, path, node_id,
t, lib::llvm::CCallConv, fnty) t, lib::llvm::CCallConv, fnty)
} }

View file

@ -260,7 +260,7 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t],
impl_id))), impl_id))),
{|| "make_impl_vtable: non-iface-type implemented"}); {|| "make_impl_vtable: non-iface-type implemented"});
let has_tps = (*ty::lookup_item_type(ccx.tcx, impl_id).bounds).len() > 0u; let has_tps = (*ty::lookup_item_type(ccx.tcx, impl_id).bounds).len() > 0u;
make_vtable(ccx, vec::map(*ty::iface_methods(tcx, ifce_id)) {|im| make_vtable(ccx, vec::map(*ty::iface_methods(tcx, ifce_id), {|im|
let fty = ty::subst_tps(tcx, substs, ty::mk_fn(tcx, im.fty)); let fty = ty::subst_tps(tcx, substs, ty::mk_fn(tcx, im.fty));
if (*im.tps).len() > 0u || ty::type_has_self(fty) { if (*im.tps).len() > 0u || ty::type_has_self(fty) {
C_null(T_ptr(T_nil())) C_null(T_ptr(T_nil()))
@ -279,7 +279,7 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t],
trans_external_path(ccx, m_id, fty) trans_external_path(ccx, m_id, fty)
} }
} }
}) }))
} }
fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest) fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest)

View file

@ -53,7 +53,7 @@ fn traverse_exports(cx: ctx, vis: ~[@view_item]) -> bool {
} }
fn traverse_export(cx: ctx, exp_id: node_id) { fn traverse_export(cx: ctx, exp_id: node_id) {
option::iter(cx.exp_map.find(exp_id)) {|defs| do option::iter(cx.exp_map.find(exp_id)) {|defs|
for vec::each(defs) {|def| traverse_def_id(cx, def.id); } for vec::each(defs) {|def| traverse_def_id(cx, def.id); }
} }
} }
@ -111,7 +111,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
} }
item_class(tps, _ifaces, items, ctor, m_dtor, _) { item_class(tps, _ifaces, items, ctor, m_dtor, _) {
cx.rmap.insert(ctor.node.id, ()); cx.rmap.insert(ctor.node.id, ());
option::iter(m_dtor) {|dtor| do option::iter(m_dtor) {|dtor|
cx.rmap.insert(dtor.node.id, ()); cx.rmap.insert(dtor.node.id, ());
// dtors don't have attrs // dtors don't have attrs
if tps.len() > 0u { if tps.len() > 0u {

View file

@ -129,12 +129,12 @@ impl methods for reflector {
ty::ty_vec(mt) { self.bracketed_mt("vec", mt, ~[]) } ty::ty_vec(mt) { self.bracketed_mt("vec", mt, ~[]) }
ty::ty_estr(vst) { ty::ty_estr(vst) {
self.vstore_name_and_extra(t, vst) {|name, extra| do self.vstore_name_and_extra(t, vst) {|name, extra|
self.visit("estr_" + name, extra) self.visit("estr_" + name, extra)
} }
} }
ty::ty_evec(mt, vst) { ty::ty_evec(mt, vst) {
self.vstore_name_and_extra(t, vst) {|name, extra| do self.vstore_name_and_extra(t, vst) {|name, extra|
self.bracketed_mt("evec_" + name, mt, extra) self.bracketed_mt("evec_" + name, mt, extra)
} }
} }

View file

@ -28,7 +28,7 @@ type nominal_id = @{did: ast::def_id, parent_id: option<ast::def_id>,
fn mk_nominal_id(tcx: ty::ctxt, did: ast::def_id, fn mk_nominal_id(tcx: ty::ctxt, did: ast::def_id,
parent_id: option<ast::def_id>, parent_id: option<ast::def_id>,
tps: ~[ty::t]) -> nominal_id { tps: ~[ty::t]) -> nominal_id {
let tps_norm = tps.map { |t| ty::normalize_ty(tcx, t) }; let tps_norm = tps.map({ |t| ty::normalize_ty(tcx, t) });
@{did: did, parent_id: parent_id, tps: tps_norm} @{did: did, parent_id: parent_id, tps: tps_norm}
} }
@ -49,7 +49,7 @@ fn eq_nominal_id(&&mi: nominal_id, &&ni: nominal_id) -> bool {
if mi.did != ni.did { if mi.did != ni.did {
false false
} else { } else {
vec::all2(mi.tps, ni.tps) { |m_tp, n_tp| do vec::all2(mi.tps, ni.tps) { |m_tp, n_tp|
ty::type_id(m_tp) == ty::type_id(n_tp) ty::type_id(m_tp) == ty::type_id(n_tp)
} }
} }
@ -137,7 +137,7 @@ enum enum_kind {
fn enum_kind(ccx: @crate_ctxt, did: ast::def_id) -> enum_kind { fn enum_kind(ccx: @crate_ctxt, did: ast::def_id) -> enum_kind {
let variants = ty::enum_variants(ccx.tcx, did); let variants = ty::enum_variants(ccx.tcx, did);
if vec::any(*variants) {|v| vec::len(v.args) > 0u} { if vec::any(*variants, {|v| vec::len(v.args) > 0u}) {
if vec::len(*variants) == 1u { tk_newtype } if vec::len(*variants) == 1u { tk_newtype }
else { tk_complex } else { tk_complex }
} else { } else {
@ -338,7 +338,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
~[shape_res] ~[shape_res]
} }
else { ~[shape_struct] }, sub = ~[]; else { ~[shape_struct] }, sub = ~[];
option::iter(m_dtor_did) {|dtor_did| do option::iter(m_dtor_did) {|dtor_did|
let ri = @{did: dtor_did, parent_id: some(did), tps: tps}; let ri = @{did: dtor_did, parent_id: some(did), tps: tps};
let id = interner::intern(ccx.shape_cx.resources, ri); let id = interner::intern(ccx.shape_cx.resources, ri);
add_u16(s, id as u16); add_u16(s, id as u16);
@ -391,7 +391,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
while i < ccx.shape_cx.tag_order.len() { while i < ccx.shape_cx.tag_order.len() {
let {did, substs} = ccx.shape_cx.tag_order[i]; let {did, substs} = ccx.shape_cx.tag_order[i];
let variants = @ty::substd_enum_variants(ccx.tcx, did, substs); let variants = @ty::substd_enum_variants(ccx.tcx, did, substs);
vec::iter(*variants) {|v| do vec::iter(*variants) {|v|
offsets += ~[vec::len(data) as u16]; offsets += ~[vec::len(data) as u16];
let variant_shape = shape_of_variant(ccx, v); let variant_shape = shape_of_variant(ccx, v);
@ -583,7 +583,7 @@ fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef {
for uint::range(0u, len) {|i| for uint::range(0u, len) {|i|
let ri = interner::get(ccx.shape_cx.resources, i); let ri = interner::get(ccx.shape_cx.resources, i);
for ri.tps.each() {|s| assert !ty::type_has_params(s); } for ri.tps.each() {|s| assert !ty::type_has_params(s); }
option::iter(ri.parent_id) {|id| do option::iter(ri.parent_id) {|id|
dtors += ~[trans::base::get_res_dtor(ccx, ri.did, id, ri.tps)]; dtors += ~[trans::base::get_res_dtor(ccx, ri.did, id, ri.tps)];
} }
} }
@ -742,7 +742,7 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
ty::mk_u8(tcx), ty::mk_u8(tcx),
mutbl: ast::m_mutbl}}] } mutbl: ast::m_mutbl}}] }
else { ~[] }) + else { ~[] }) +
ty::lookup_class_fields(tcx, did).map {|f| do ty::lookup_class_fields(tcx, did).map {|f|
let t = ty::lookup_field_type(tcx, did, f.id, substs); let t = ty::lookup_field_type(tcx, did, f.id, substs);
{ident: f.ident, {ident: f.ident,
mt: {ty: simplify_type(tcx, t), mutbl: ast::m_const}} mt: {ty: simplify_type(tcx, t), mutbl: ast::m_const}}
@ -752,5 +752,5 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
_ { typ } _ { typ }
} }
} }
ty::fold_ty(tcx, typ) {|t| simplifier(tcx, t) } ty::fold_ty(tcx, typ, {|t| simplifier(tcx, t) })
} }

View file

@ -360,7 +360,7 @@ fn trans_append_literal(bcx: block, vptrptr: ValueRef, vec_ty: ty::t,
let new_fill = Add(bcx, old_fill, elt_sz); let new_fill = Add(bcx, old_fill, elt_sz);
let do_grow = ICmp(bcx, lib::llvm::IntUGT, new_fill, let do_grow = ICmp(bcx, lib::llvm::IntUGT, new_fill,
get_alloc(bcx, vptr)); get_alloc(bcx, vptr));
bcx = base::with_cond(bcx, do_grow) {|bcx| bcx = do base::with_cond(bcx, do_grow) {|bcx|
let pt = PointerCast(bcx, vptrptr, let pt = PointerCast(bcx, vptrptr,
T_ptr(T_ptr(T_i8()))); T_ptr(T_ptr(T_i8())));
Call(bcx, ccx.upcalls.vec_grow, ~[pt, new_fill]); Call(bcx, ccx.upcalls.vec_grow, ~[pt, new_fill]);

View file

@ -16,7 +16,7 @@ export type_of_non_gc_box;
fn type_of_explicit_args(cx: @crate_ctxt, fn type_of_explicit_args(cx: @crate_ctxt,
inputs: ~[ty::arg]) -> ~[TypeRef] { inputs: ~[ty::arg]) -> ~[TypeRef] {
vec::map(inputs) {|arg| do vec::map(inputs) {|arg|
let arg_ty = arg.ty; let arg_ty = arg.ty;
let llty = type_of(cx, arg_ty); let llty = type_of(cx, arg_ty);
alt ty::resolved_mode(cx.tcx, arg.mode) { alt ty::resolved_mode(cx.tcx, arg.mode) {
@ -175,7 +175,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
ty::ty_class(did, ts) { ty::ty_class(did, ts) {
// Only instance vars are record fields at runtime. // Only instance vars are record fields at runtime.
let fields = lookup_class_fields(cx.tcx, did); let fields = lookup_class_fields(cx.tcx, did);
let mut tys = vec::map(fields) {|f| let mut tys = do vec::map(fields) {|f|
let t = ty::lookup_field_type(cx.tcx, did, f.id, ts); let t = ty::lookup_field_type(cx.tcx, did, f.id, ts);
type_of(cx, t) type_of(cx, t)
}; };

View file

@ -114,7 +114,7 @@ fn type_needs(cx: ctx, use: uint, ty: ty::t) {
fn type_needs_inner(cx: ctx, use: uint, ty: ty::t, fn type_needs_inner(cx: ctx, use: uint, ty: ty::t,
enums_seen: @list<def_id>) { enums_seen: @list<def_id>) {
ty::maybe_walk_ty(ty) {|ty| do ty::maybe_walk_ty(ty) {|ty|
if ty::type_has_params(ty) { if ty::type_has_params(ty) {
alt ty::get(ty).struct { alt ty::get(ty).struct {
/* /*
@ -181,11 +181,11 @@ fn mark_for_expr(cx: ctx, e: @expr) {
} }
} }
expr_path(_) { expr_path(_) {
cx.ccx.tcx.node_type_substs.find(e.id).iter {|ts| do cx.ccx.tcx.node_type_substs.find(e.id).iter {|ts|
let id = ast_util::def_id_of_def(cx.ccx.tcx.def_map.get(e.id)); let id = ast_util::def_id_of_def(cx.ccx.tcx.def_map.get(e.id));
vec::iter2(type_uses_for(cx.ccx, id, ts.len()), ts) {|uses, subst| vec::iter2(type_uses_for(cx.ccx, id, ts.len()), ts, {|uses, subst|
type_needs(cx, uses, subst) type_needs(cx, uses, subst)
} })
} }
} }
expr_fn(*) | expr_fn_block(*) { expr_fn(*) | expr_fn_block(*) {
@ -209,11 +209,11 @@ fn mark_for_expr(cx: ctx, e: @expr) {
let base_ty = ty::node_id_to_type(cx.ccx.tcx, base.id); let base_ty = ty::node_id_to_type(cx.ccx.tcx, base.id);
type_needs(cx, use_repr, ty::type_autoderef(cx.ccx.tcx, base_ty)); type_needs(cx, use_repr, ty::type_autoderef(cx.ccx.tcx, base_ty));
option::iter(cx.ccx.maps.method_map.find(e.id)) {|mth| do option::iter(cx.ccx.maps.method_map.find(e.id)) {|mth|
alt mth.origin { alt mth.origin {
typeck::method_static(did) { typeck::method_static(did) {
option::iter(cx.ccx.tcx.node_type_substs.find(e.id)) {|ts| do option::iter(cx.ccx.tcx.node_type_substs.find(e.id)) {|ts|
vec::iter2(type_uses_for(cx.ccx, did, ts.len()), ts) do vec::iter2(type_uses_for(cx.ccx, did, ts.len()), ts)
{|uses, subst| type_needs(cx, uses, subst)} {|uses, subst| type_needs(cx, uses, subst)}
} }
} }
@ -231,14 +231,14 @@ fn mark_for_expr(cx: ctx, e: @expr) {
node_type_needs(cx, use_repr, v.id); node_type_needs(cx, use_repr, v.id);
} }
expr_call(f, _, _) { expr_call(f, _, _) {
vec::iter(ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id))) {|a| vec::iter(ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id)), {|a|
alt a.mode { alt a.mode {
expl(by_move) | expl(by_copy) | expl(by_val) { expl(by_move) | expl(by_copy) | expl(by_val) {
type_needs(cx, use_repr, a.ty); type_needs(cx, use_repr, a.ty);
} }
_ {} _ {}
} }
} })
} }
expr_alt(_, _, _) | expr_block(_) | expr_if(_, _, _) | expr_alt(_, _, _) | expr_block(_) | expr_if(_, _, _) |
expr_while(_, _) | expr_fail(_) | expr_break | expr_cont | expr_while(_, _) | expr_fail(_) | expr_break | expr_cont |
@ -265,7 +265,7 @@ fn handle_body(cx: ctx, body: blk) {
}, },
visit_block: {|b, cx, v| visit_block: {|b, cx, v|
visit::visit_block(b, cx, v); visit::visit_block(b, cx, v);
option::iter(b.node.expr) {|e| do option::iter(b.node.expr) {|e|
node_type_needs(cx, use_repr, e.id); node_type_needs(cx, use_repr, e.id);
} }
}, },

View file

@ -10,7 +10,7 @@ export make_free_glue, autoderef, duplicate;
fn make_free_glue(bcx: block, vptr: ValueRef, t: ty::t) fn make_free_glue(bcx: block, vptr: ValueRef, t: ty::t)
-> block { -> block {
let _icx = bcx.insn_ctxt("uniq::make_free_glue"); let _icx = bcx.insn_ctxt("uniq::make_free_glue");
with_cond(bcx, IsNotNull(bcx, vptr)) {|bcx| do with_cond(bcx, IsNotNull(bcx, vptr)) {|bcx|
let content_ty = content_ty(t); let content_ty = content_ty(t);
let body_ptr = opaque_box_body(bcx, content_ty, vptr); let body_ptr = opaque_box_body(bcx, content_ty, vptr);
let bcx = drop_ty(bcx, body_ptr, content_ty); let bcx = drop_ty(bcx, body_ptr, content_ty);

View file

@ -661,7 +661,7 @@ fn find_instances(_fcx: fn_ctxt, subst: subst,
if vec::len(subst) == 0u { ret ~[]; } if vec::len(subst) == 0u { ret ~[]; }
let mut res = ~[]; let mut res = ~[];
(*c.descs).swap { |v| do (*c.descs).swap { |v|
let v <- vec::from_mut(v); let v <- vec::from_mut(v);
for v.each { |d| for v.each { |d|
if args_mention(d.node.args, find_in_subst_bool, subst) { if args_mention(d.node.args, find_in_subst_bool, subst) {
@ -821,8 +821,8 @@ fn forget_in_postcond(fcx: fn_ctxt, parent_exp: node_id, dead_v: node_id) {
// In the postcondition given by parent_exp, clear the bits // In the postcondition given by parent_exp, clear the bits
// for any constraints mentioning dead_v // for any constraints mentioning dead_v
let d = local_node_id_to_local_def_id(fcx, dead_v); let d = local_node_id_to_local_def_id(fcx, dead_v);
option::iter(d) {|d_id| do option::iter(d) {|d_id|
for_constraints_mentioning(fcx, d_id) {|c| do for_constraints_mentioning(fcx, d_id) {|c|
#debug("clearing constraint %u %s", #debug("clearing constraint %u %s",
c.bit_num, c.bit_num,
constraint_to_str(fcx.ccx.tcx, c.c)); constraint_to_str(fcx.ccx.tcx, c.c));
@ -838,8 +838,8 @@ fn forget_in_poststate(fcx: fn_ctxt, p: poststate, dead_v: node_id) -> bool {
// for any constraints mentioning dead_v // for any constraints mentioning dead_v
let d = local_node_id_to_local_def_id(fcx, dead_v); let d = local_node_id_to_local_def_id(fcx, dead_v);
let mut changed = false; let mut changed = false;
option::iter(d) {|d_id| do option::iter(d) {|d_id|
for_constraints_mentioning(fcx, d_id) {|c| do for_constraints_mentioning(fcx, d_id) {|c|
changed |= clear_in_poststate_(c.bit_num, p); changed |= clear_in_poststate_(c.bit_num, p);
} }
} }
@ -926,7 +926,7 @@ type binding = {lhs: ~[dest], rhs: option<initializer>};
fn local_to_bindings(tcx: ty::ctxt, loc: @local) -> binding { fn local_to_bindings(tcx: ty::ctxt, loc: @local) -> binding {
let mut lhs = ~[]; let mut lhs = ~[];
pat_bindings(tcx.def_map, loc.node.pat) {|p_id, _s, name| do pat_bindings(tcx.def_map, loc.node.pat) {|p_id, _s, name|
vec::push(lhs, local_dest({ident: path_to_ident(name), node: p_id})); vec::push(lhs, local_dest({ident: path_to_ident(name), node: p_id}));
}; };
{lhs: lhs, rhs: loc.node.init} {lhs: lhs, rhs: loc.node.init}
@ -956,7 +956,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] {
} }
fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> ~[init_op] { fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> ~[init_op] {
vec::map(callee_modes(fcx, callee)) {|m| do vec::map(callee_modes(fcx, callee)) {|m|
alt ty::resolved_mode(fcx.ccx.tcx, m) { alt ty::resolved_mode(fcx.ccx.tcx, m) {
by_move { init_move } by_move { init_move }
by_copy | by_ref | by_val | by_mutbl_ref { init_assign } by_copy | by_ref | by_val | by_mutbl_ref { init_assign }

View file

@ -49,7 +49,7 @@ fn seq_postconds(fcx: fn_ctxt, ps: ~[postcond]) -> postcond {
let sz = vec::len(ps); let sz = vec::len(ps);
if sz >= 1u { if sz >= 1u {
let prev = tritv_clone(ps[0]); let prev = tritv_clone(ps[0]);
vec::iter_between(ps, 1u, sz) {|p| seq_tritv(prev, p); } vec::iter_between(ps, 1u, sz, {|p| seq_tritv(prev, p); });
ret prev; ret prev;
} else { ret ann::empty_poststate(num_constraints(fcx.enclosing)); } } else { ret ann::empty_poststate(num_constraints(fcx.enclosing)); }
} }

Some files were not shown because too many files have changed in this diff Show more