]> git.lizzy.rs Git - rust.git/commitdiff
test: Remove non-procedure uses of `do` from compiletest, libstd tests,
authorPatrick Walton <pcwalton@mimiga.net>
Fri, 22 Nov 2013 01:23:21 +0000 (17:23 -0800)
committerPatrick Walton <pcwalton@mimiga.net>
Tue, 26 Nov 2013 16:25:27 +0000 (08:25 -0800)
compile-fail tests, run-fail tests, and run-pass tests.

128 files changed:
src/compiletest/compiletest.rs
src/compiletest/header.rs
src/compiletest/procsrv.rs
src/compiletest/runtest.rs
src/libstd/at_vec.rs
src/libstd/bool.rs
src/libstd/cell.rs
src/libstd/char.rs
src/libstd/condition.rs
src/libstd/io/buffered.rs
src/libstd/io/extensions.rs
src/libstd/io/mem.rs
src/libstd/io/net/tcp.rs
src/libstd/io/net/udp.rs
src/libstd/io/net/unix.rs
src/libstd/io/option.rs
src/libstd/iter.rs
src/libstd/local_data.rs
src/libstd/num/strconv.rs
src/libstd/num/uint.rs
src/libstd/option.rs
src/libstd/path/posix.rs
src/libstd/path/windows.rs
src/libstd/ptr.rs
src/libstd/rand/distributions/gamma.rs
src/libstd/rand/distributions/mod.rs
src/libstd/rand/mod.rs
src/libstd/result.rs
src/libstd/rt/comm.rs
src/libstd/rt/crate_map.rs
src/libstd/rt/global_heap.rs
src/libstd/rt/local.rs
src/libstd/rt/local_heap.rs
src/libstd/rt/sched.rs
src/libstd/rt/tube.rs
src/libstd/select.rs
src/libstd/str.rs
src/libstd/task/mod.rs
src/libstd/unstable/finally.rs
src/libstd/util.rs
src/libstd/vec.rs
src/test/auxiliary/xc_conditions_3.rs
src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs
src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs
src/test/compile-fail/arc-rw-state-shouldnt-escape.rs
src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs
src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs
src/test/compile-fail/block-arg-as-stmt-with-value.rs [deleted file]
src/test/compile-fail/borrowck-assign-comp-idx.rs
src/test/compile-fail/borrowck-autoref-3261.rs
src/test/compile-fail/borrowck-insert-during-each.rs
src/test/compile-fail/borrowck-lend-flow-loop.rs
src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs
src/test/compile-fail/borrowck-loan-rcvr.rs
src/test/compile-fail/borrowck-loan-vec-content.rs
src/test/compile-fail/break-outside-loop.rs
src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs
src/test/compile-fail/do2.rs
src/test/compile-fail/lint-unused-mut-variables.rs
src/test/compile-fail/lint-unused-unsafe.rs
src/test/compile-fail/moves-based-on-type-block-bad.rs
src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs
src/test/compile-fail/mutex-arc-nested.rs
src/test/compile-fail/once-cant-call-twice-on-stack.rs
src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs
src/test/compile-fail/regions-freevar.rs
src/test/compile-fail/regions-infer-call-3.rs
src/test/compile-fail/sync-cond-shouldnt-escape.rs
src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs
src/test/compile-fail/sync-rwlock-read-mode-shouldnt-escape.rs
src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs
src/test/compile-fail/sync-rwlock-write-mode-shouldnt-escape.rs
src/test/run-fail/bug-2470-bounds-check-overflow.rs
src/test/run-pass/assignability-trait.rs
src/test/run-pass/bitv-perf-test.rs
src/test/run-pass/block-arg-can-be-followed-by-binop.rs
src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs
src/test/run-pass/block-arg-can-be-followed-by-call.rs
src/test/run-pass/block-arg-in-parentheses.rs
src/test/run-pass/block-arg-used-as-any.rs
src/test/run-pass/block-arg.rs
src/test/run-pass/borrowck-borrow-from-expr-block.rs
src/test/run-pass/borrowck-mut-uniq.rs
src/test/run-pass/borrowck-preserve-box-in-field.rs
src/test/run-pass/borrowck-preserve-box-in-uniq.rs
src/test/run-pass/borrowck-preserve-box.rs
src/test/run-pass/borrowck-preserve-expl-deref.rs
src/test/run-pass/cci_impl_exe.rs
src/test/run-pass/cci_iter_exe.rs
src/test/run-pass/cci_no_inline_exe.rs
src/test/run-pass/core-run-destroy.rs
src/test/run-pass/deriving-encodable-decodable.rs
src/test/run-pass/deriving-rand.rs
src/test/run-pass/do-empty-args.rs
src/test/run-pass/do-no-args.rs
src/test/run-pass/do-pure.rs [deleted file]
src/test/run-pass/do-stack.rs [deleted file]
src/test/run-pass/do1.rs
src/test/run-pass/do2.rs
src/test/run-pass/do3.rs
src/test/run-pass/extern-stress.rs
src/test/run-pass/extern-yield.rs
src/test/run-pass/foreach-nested.rs
src/test/run-pass/foreach-put-structured.rs
src/test/run-pass/foreach-simple-outer-slot.rs
src/test/run-pass/foreign-fn-linkname.rs
src/test/run-pass/issue-1458.rs [deleted file]
src/test/run-pass/issue-2487-a.rs
src/test/run-pass/issue-2804.rs
src/test/run-pass/issue-3211.rs
src/test/run-pass/issue-3563-3.rs
src/test/run-pass/issue-4401.rs
src/test/run-pass/issue-5321-immediates-with-bare-self.rs
src/test/run-pass/issue-6153.rs
src/test/run-pass/match-ref-binding-in-guard-3256.rs
src/test/run-pass/newlambdas.rs
src/test/run-pass/once-move-out-on-stack.rs
src/test/run-pass/reflect-visit-data.rs
src/test/run-pass/regions-infer-call-2.rs
src/test/run-pass/rename-directory.rs
src/test/run-pass/trait-bounds-in-arc.rs
src/test/run-pass/type-params-in-for-each.rs
src/test/run-pass/variadic-ffi.rs
src/test/run-pass/writealias.rs
src/test/run-pass/xc_conditions_client.rs
src/test/run-pass/xc_conditions_client_2.rs
src/test/run-pass/xc_conditions_client_4.rs
src/test/run-pass/xcrate-static-addresses.rs

index 9c8fdafe9ad106acb26fa1fc05c70dd1871c6a68..65f733cf1dec3d9f08c1cf298ffd2d0d5f7d14f6 100644 (file)
@@ -266,12 +266,12 @@ pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
         let file = file.clone();
         debug!("inspecting file {}", file.display());
         if is_test(config, &file) {
-            let t = do make_test(config, &file) {
+            let t = make_test(config, &file, || {
                 match config.mode {
                     mode_codegen => make_metrics_test_closure(config, &file),
                     _ => make_test_closure(config, &file)
                 }
-            };
+            });
             tests.push(t)
         }
     }
index f722f873d5e675eb2b6c3ad5dab2fa45ebc6db80..1966701dbdedda584910ab7d685458c09f122650 100644 (file)
@@ -39,7 +39,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
     let mut pp_exact = None;
     let mut debugger_cmds = ~[];
     let mut check_lines = ~[];
-    do iter_header(testfile) |ln| {
+    iter_header(testfile, |ln| {
         match parse_error_pattern(ln) {
           Some(ep) => error_patterns.push(ep),
           None => ()
@@ -74,7 +74,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
         };
 
         true
-    };
+    });
     return TestProps {
         error_patterns: error_patterns,
         compile_flags: compile_flags,
@@ -91,13 +91,13 @@ fn xfail_target(config: &config) -> ~str {
         ~"xfail-" + util::get_os(config.target)
     }
 
-    let val = do iter_header(testfile) |ln| {
+    let val = iter_header(testfile, |ln| {
         if parse_name_directive(ln, "xfail-test") { false }
         else if parse_name_directive(ln, xfail_target(config)) { false }
         else if config.mode == common::mode_pretty &&
             parse_name_directive(ln, "xfail-pretty") { false }
         else { true }
-    };
+    });
 
     !val
 }
@@ -143,7 +143,7 @@ fn parse_check_line(line: &str) -> Option<~str> {
 }
 
 fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
-    do parse_name_value_directive(line, ~"exec-env").map |nv| {
+    parse_name_value_directive(line, ~"exec-env").map(|nv| {
         // nv is either FOO or FOO=BAR
         let mut strs: ~[~str] = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
 
@@ -155,7 +155,7 @@ fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
           }
           n => fail!("Expected 1 or 2 strings, not {}", n)
         }
-    }
+    })
 }
 
 fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
index e107c53018def877537133aa788db673c66ca74b..012d57da123cfe16acbc9fbb00fdb147bf1effe4 100644 (file)
@@ -22,11 +22,11 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
     assert!(prog.ends_with(".exe"));
     let aux_path = prog.slice(0u, prog.len() - 4u).to_owned() + ".libaux";
 
-    env = do env.map() |pair| {
+    env = env.map(|pair| {
         let (k,v) = (*pair).clone();
         if k == ~"PATH" { (~"PATH", v + ";" + lib_path + ";" + aux_path) }
         else { (k,v) }
-    };
+    });
     if prog.ends_with("rustc.exe") {
         env.push((~"RUST_THREADS", ~"1"));
     }
index 7104a506fccc5df3c76b5da272c0d9a029f33427..4c7b212304cebe1cc3c72a773cca458d6e634ada 100644 (file)
@@ -427,9 +427,9 @@ fn check_error_patterns(props: &TestProps,
                         testfile: &Path,
                         ProcRes: &ProcRes) {
     if props.error_patterns.is_empty() {
-        do testfile.display().with_str |s| {
+        testfile.display().with_str(|s| {
             fatal(~"no error pattern specified in " + s);
-        }
+        })
     }
 
     if ProcRes.status.success() {
index 4405d5be3886b2db733adaf9668d984206134fa3..2b105a3fa7d2375bf593740beeedecd7f2ba0f6d 100644 (file)
@@ -333,47 +333,57 @@ fn test_to_managed() {
     #[bench]
     fn bench_capacity(b: &mut bh) {
         let x = @[1, 2, 3];
-        b.iter(|| capacity(x));
+        b.iter(|| {
+            let _ = capacity(x);
+        });
     }
 
     #[bench]
     fn bench_build_sized(b: &mut bh) {
         let len = 64;
-        do b.iter {
+        b.iter(|| {
             build(Some(len), |push| for i in range(0, 1024) { push(i) });
-        }
+        });
     }
 
     #[bench]
     fn bench_build(b: &mut bh) {
-        do b.iter {
+        b.iter(|| {
             for i in range(0, 95) {
                 build(None, |push| push(i));
             }
-        }
+        });
     }
 
     #[bench]
     fn bench_append(b: &mut bh) {
         let lhs = @[7, ..128];
         let rhs = range(0, 256).to_owned_vec();
-        b.iter(|| append(lhs, rhs))
+        b.iter(|| {
+            let _ = append(lhs, rhs);
+        })
     }
 
     #[bench]
     fn bench_map(b: &mut bh) {
         let elts = range(0, 256).to_owned_vec();
-        b.iter(|| map(elts, |x| x*2))
+        b.iter(|| {
+            let _ = map(elts, |x| x*2);
+        })
     }
 
     #[bench]
     fn bench_from_fn(b: &mut bh) {
-        b.iter(|| from_fn(1024, |x| x));
+        b.iter(|| {
+            let _ = from_fn(1024, |x| x);
+        });
     }
 
     #[bench]
     fn bench_from_elem(b: &mut bh) {
-        b.iter(|| from_elem(1024, 0u64));
+        b.iter(|| {
+            let _ = from_elem(1024, 0u64);
+        });
     }
 
     #[bench]
@@ -387,12 +397,16 @@ fn bench_to_managed_move(b: &mut bh) {
     #[bench]
     fn bench_to_managed(b: &mut bh) {
         let elts = range(0, 1024).to_owned_vec();
-        b.iter(|| to_managed(elts));
+        b.iter(|| {
+            let _ = to_managed(elts);
+        });
     }
 
     #[bench]
     fn bench_clone(b: &mut bh) {
         let elts = to_managed(range(0, 1024).to_owned_vec());
-        b.iter(|| elts.clone());
+        b.iter(|| {
+            let _ = elts.clone();
+        });
     }
 }
index ce0a66965962369c14a2c143e14da5eb4e7a95d0..29c304f9ac539a3d12bb63c93bba8764d0028c60 100644 (file)
@@ -53,9 +53,9 @@
 /// # Examples
 ///
 /// ```
-/// do std::bool::all_values |x: bool| {
+/// std::bool::all_values(|x: bool| {
 ///     println(x.to_str());
-/// }
+/// })
 /// ```
 #[inline]
 pub fn all_values(blk: |v: bool|) {
@@ -396,9 +396,9 @@ fn test_bool() {
 
     #[test]
     fn test_bool_from_str() {
-        do all_values |v| {
+        all_values(|v| {
             assert!(Some(v) == FromStr::from_str(v.to_str()))
-        }
+        });
     }
 
     #[test]
@@ -409,11 +409,11 @@ fn test_bool_to_str() {
 
     #[test]
     fn test_bool_to_bit() {
-        do all_values |v| {
+        all_values(|v| {
             assert_eq!(v.to_bit::<u8>(), if v { 1u8 } else { 0u8 });
             assert_eq!(v.to_bit::<uint>(), if v { 1u } else { 0u });
             assert_eq!(v.to_bit::<int>(), if v { 1i } else { 0i });
-        }
+        });
     }
 
     #[test]
index 634558b9b971dcc769b653016330bf62fb4d21c8..e49cf3e5303b3c585cae0c3865417900a747a1e3 100644 (file)
@@ -82,7 +82,6 @@ pub struct RefCell<T> {
     priv nc: NonCopyable
 }
 
-<<<<<<< HEAD
 // Values [1, MAX-1] represent the number of `Ref` active
 // (will not outgrow its range since `uint` is the size of the address space)
 type BorrowFlag = uint;
index c5a4dd1631df99b6b40dc7868992634c0cb2d260..b372993e3e50665d6040b63d66c964c2aae2e434 100644 (file)
@@ -532,7 +532,7 @@ fn test_is_digit() {
 fn test_escape_default() {
     fn string(c: char) -> ~str {
         let mut result = ~"";
-        do escape_default(c) |c| { result.push_char(c); }
+        escape_default(c, |c| { result.push_char(c); });
         return result;
     }
     assert_eq!(string('\n'), ~"\\n");
@@ -554,7 +554,7 @@ fn string(c: char) -> ~str {
 fn test_escape_unicode() {
     fn string(c: char) -> ~str {
         let mut result = ~"";
-        do escape_unicode(c) |c| { result.push_char(c); }
+        escape_unicode(c, |c| { result.push_char(c); });
         return result;
     }
     assert_eq!(string('\x00'), ~"\\x00");
index 03994043dcf0cea95f6e0ecb2ca25ccc448a8c24..80ff104e8303ec467f1df97ebf42f6109b12115d 100644 (file)
@@ -224,14 +224,14 @@ fn trouble(i: int) {
     fn nested_trap_test_inner() {
         let mut inner_trapped = false;
 
-        do sadness::cond.trap(|_j| {
+        sadness::cond.trap(|_j| {
             debug!("nested_trap_test_inner: in handler");
             inner_trapped = true;
             0
-        }).inside {
+        }).inside(|| {
             debug!("nested_trap_test_inner: in protected block");
             trouble(1);
-        }
+        });
 
         assert!(inner_trapped);
     }
@@ -240,14 +240,14 @@ fn nested_trap_test_inner() {
     fn nested_trap_test_outer() {
         let mut outer_trapped = false;
 
-        do sadness::cond.trap(|_j| {
+        sadness::cond.trap(|_j| {
             debug!("nested_trap_test_outer: in handler");
             outer_trapped = true; 0
-        }).inside {
+        }).inside(|| {
             debug!("nested_guard_test_outer: in protected block");
             nested_trap_test_inner();
             trouble(1);
-        }
+        });
 
         assert!(outer_trapped);
     }
@@ -255,16 +255,16 @@ fn nested_trap_test_outer() {
     fn nested_reraise_trap_test_inner() {
         let mut inner_trapped = false;
 
-        do sadness::cond.trap(|_j| {
+        sadness::cond.trap(|_j| {
             debug!("nested_reraise_trap_test_inner: in handler");
             inner_trapped = true;
             let i = 10;
             debug!("nested_reraise_trap_test_inner: handler re-raising");
             sadness::cond.raise(i)
-        }).inside {
+        }).inside(|| {
             debug!("nested_reraise_trap_test_inner: in protected block");
             trouble(1);
-        }
+        });
 
         assert!(inner_trapped);
     }
@@ -273,13 +273,13 @@ fn nested_reraise_trap_test_inner() {
     fn nested_reraise_trap_test_outer() {
         let mut outer_trapped = false;
 
-        do sadness::cond.trap(|_j| {
+        sadness::cond.trap(|_j| {
             debug!("nested_reraise_trap_test_outer: in handler");
             outer_trapped = true; 0
-        }).inside {
+        }).inside(|| {
             debug!("nested_reraise_trap_test_outer: in protected block");
             nested_reraise_trap_test_inner();
-        }
+        });
 
         assert!(outer_trapped);
     }
@@ -288,13 +288,13 @@ fn nested_reraise_trap_test_outer() {
     fn test_default() {
         let mut trapped = false;
 
-        do sadness::cond.trap(|j| {
+        sadness::cond.trap(|j| {
             debug!("test_default: in handler");
             sadness::cond.raise_default(j, || { trapped=true; 5 })
-        }).inside {
+        }).inside(|| {
             debug!("test_default: in protected block");
             trouble(1);
-        }
+        });
 
         assert!(trapped);
     }
@@ -312,12 +312,12 @@ mod n {
             #[test]
             fn test_conditions_are_public() {
                 let mut trapped = false;
-                do sadness::cond.trap(|_| {
+                sadness::cond.trap(|_| {
                     trapped = true;
                     0
-                }).inside {
+                }).inside(|| {
                     sadness::cond.raise(0);
-                }
+                });
                 assert!(trapped);
             }
         }
index d74acb5f59baa0a705d0bd01cb5a5df74be19e03..8c1897339cbef9d7e11d977407bd24e6907fc2a4 100644 (file)
@@ -438,22 +438,22 @@ fn test_line_buffer() {
 
     #[bench]
     fn bench_buffered_reader(bh: &mut Harness) {
-        do bh.iter {
+        bh.iter(|| {
             BufferedReader::new(NullStream);
-        }
+        });
     }
 
     #[bench]
     fn bench_buffered_writer(bh: &mut Harness) {
-        do bh.iter {
+        bh.iter(|| {
             BufferedWriter::new(NullStream);
-        }
+        });
     }
 
     #[bench]
     fn bench_buffered_stream(bh: &mut Harness) {
-        do bh.iter {
+        bh.iter(|| {
             BufferedStream::new(NullStream);
-        }
+        });
     }
 }
index 5eb2e72e96b21efc03965f7191fae965a13f31e3..564e664027f73ec32f1e5a9ae6e3812273cdf5cb 100644 (file)
@@ -276,11 +276,11 @@ fn read_byte_eof() {
     #[test]
     fn read_byte_error() {
         let mut reader = ErroringReader;
-        do io_error::cond.trap(|_| {
-        }).inside {
+        io_error::cond.trap(|_| {
+        }).inside(|| {
             let byte = reader.read_byte();
             assert!(byte == None);
-        }
+        });
     }
 
     #[test]
@@ -303,10 +303,10 @@ fn bytes_eof() {
     fn bytes_error() {
         let reader = ErroringReader;
         let mut it = reader.bytes();
-        do io_error::cond.trap(|_| ()).inside {
+        io_error::cond.trap(|_| ()).inside(|| {
             let byte = it.next();
             assert!(byte == None);
-        }
+        })
     }
 
     #[test]
@@ -328,10 +328,10 @@ fn read_bytes_partial() {
     #[test]
     fn read_bytes_eof() {
         let mut reader = MemReader::new(~[10, 11]);
-        do io_error::cond.trap(|_| {
-        }).inside {
+        io_error::cond.trap(|_| {
+        }).inside(|| {
             assert!(reader.read_bytes(4) == ~[10, 11]);
-        }
+        })
     }
 
     #[test]
@@ -356,11 +356,11 @@ fn push_bytes_partial() {
     fn push_bytes_eof() {
         let mut reader = MemReader::new(~[10, 11]);
         let mut buf = ~[8, 9];
-        do io_error::cond.trap(|_| {
-        }).inside {
+        io_error::cond.trap(|_| {
+        }).inside(|| {
             reader.push_bytes(&mut buf, 4);
             assert!(buf == ~[8, 9, 10, 11]);
-        }
+        })
     }
 
     #[test]
@@ -369,9 +369,9 @@ fn push_bytes_error() {
             count: 0,
         };
         let mut buf = ~[8, 9];
-        do io_error::cond.trap(|_| { } ).inside {
+        io_error::cond.trap(|_| { } ).inside(|| {
             reader.push_bytes(&mut buf, 4);
-        }
+        });
         assert!(buf == ~[8, 9, 10]);
     }
 
@@ -384,13 +384,13 @@ fn push_bytes_fail_reset_len() {
             count: 0,
         };
         let buf = @mut ~[8, 9];
-        do (|| {
+        (|| {
             reader.push_bytes(&mut *buf, 4);
-        }).finally {
+        }).finally(|| {
             // NB: Using rtassert here to trigger abort on failure since this is a should_fail test
             // FIXME: #7049 This fails because buf is still borrowed
             //rtassert!(*buf == ~[8, 9, 10]);
-        }
+        })
     }
 
     #[test]
index decdfb60bfbe51f40883bdfefda279d0694ea0e8..b08f4af9a54c6c3db981e1801ab8fecbb355429d 100644 (file)
@@ -331,12 +331,12 @@ fn test_buf_writer_error() {
         writer.write([0]);
 
         let mut called = false;
-        do io_error::cond.trap(|err| {
+        io_error::cond.trap(|err| {
             assert_eq!(err.kind, OtherIoError);
             called = true;
-        }).inside {
+        }).inside(|| {
             writer.write([0, 0]);
-        }
+        });
         assert!(called);
     }
 
index ac099e67f795fee5feeafb1dbb1da45730efb364..aa7a64d2210748d65d66ac3181e4b914daee1a0d 100644 (file)
@@ -157,14 +157,14 @@ mod test {
     fn bind_error() {
         do run_in_mt_newsched_task {
             let mut called = false;
-            do io_error::cond.trap(|e| {
+            io_error::cond.trap(|e| {
                 assert!(e.kind == PermissionDenied);
                 called = true;
-            }).inside {
+            }).inside(|| {
                 let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 };
                 let listener = TcpListener::bind(addr);
                 assert!(listener.is_none());
-            }
+            });
             assert!(called);
         }
     }
@@ -173,7 +173,7 @@ fn bind_error() {
     fn connect_error() {
         do run_in_mt_newsched_task {
             let mut called = false;
-            do io_error::cond.trap(|e| {
+            io_error::cond.trap(|e| {
                 let expected_error = if cfg!(unix) {
                     ConnectionRefused
                 } else {
@@ -182,11 +182,11 @@ fn connect_error() {
                 };
                 assert_eq!(e.kind, expected_error);
                 called = true;
-            }).inside {
+            }).inside(|| {
                 let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 };
                 let stream = TcpStream::connect(addr);
                 assert!(stream.is_none());
-            }
+            });
             assert!(called);
         }
     }
@@ -306,16 +306,16 @@ fn read_eof_twice_ip4() {
                 let mut buf = [0];
                 let nread = stream.read(buf);
                 assert!(nread.is_none());
-                do io_error::cond.trap(|e| {
+                io_error::cond.trap(|e| {
                     if cfg!(windows) {
                         assert_eq!(e.kind, NotConnected);
                     } else {
                         fail!();
                     }
-                }).inside {
+                }).inside(|| {
                     let nread = stream.read(buf);
                     assert!(nread.is_none());
-                }
+                })
             }
 
             do spawntask {
@@ -341,16 +341,16 @@ fn read_eof_twice_ip6() {
                 let mut buf = [0];
                 let nread = stream.read(buf);
                 assert!(nread.is_none());
-                do io_error::cond.trap(|e| {
+                io_error::cond.trap(|e| {
                     if cfg!(windows) {
                         assert_eq!(e.kind, NotConnected);
                     } else {
                         fail!();
                     }
-                }).inside {
+                }).inside(|| {
                     let nread = stream.read(buf);
                     assert!(nread.is_none());
-                }
+                })
             }
 
             do spawntask {
@@ -376,7 +376,7 @@ fn write_close_ip4() {
                 let buf = [0];
                 loop {
                     let mut stop = false;
-                    do io_error::cond.trap(|e| {
+                    io_error::cond.trap(|e| {
                         // NB: ECONNRESET on linux, EPIPE on mac, ECONNABORTED
                         //     on windows
                         assert!(e.kind == ConnectionReset ||
@@ -384,9 +384,9 @@ fn write_close_ip4() {
                                 e.kind == ConnectionAborted,
                                 "unknown error: {:?}", e);
                         stop = true;
-                    }).inside {
+                    }).inside(|| {
                         stream.write(buf);
-                    }
+                    });
                     if stop { break }
                 }
             }
@@ -414,7 +414,7 @@ fn write_close_ip6() {
                 let buf = [0];
                 loop {
                     let mut stop = false;
-                    do io_error::cond.trap(|e| {
+                    io_error::cond.trap(|e| {
                         // NB: ECONNRESET on linux, EPIPE on mac, ECONNABORTED
                         //     on windows
                         assert!(e.kind == ConnectionReset ||
@@ -422,9 +422,9 @@ fn write_close_ip6() {
                                 e.kind == ConnectionAborted,
                                 "unknown error: {:?}", e);
                         stop = true;
-                    }).inside {
+                    }).inside(|| {
                         stream.write(buf);
-                    }
+                    });
                     if stop { break }
                 }
             }
@@ -458,10 +458,10 @@ fn multiple_connect_serial_ip4() {
 
             do spawntask {
                 port.take().recv();
-                do max.times {
+                max.times(|| {
                     let mut stream = TcpStream::connect(addr);
                     stream.write([99]);
-                }
+                });
             }
         }
     }
@@ -487,10 +487,10 @@ fn multiple_connect_serial_ip6() {
 
             do spawntask {
                 port.take().recv();
-                do max.times {
+                max.times(|| {
                     let mut stream = TcpStream::connect(addr);
                     stream.write([99]);
-                }
+                });
             }
         }
     }
index 38def44d9d0e9a5419dfc561e1e75e89b6403cac..f02fc1ae4471cc856da94218bc9c733c335e899b 100644 (file)
@@ -116,14 +116,14 @@ mod test {
     fn bind_error() {
         do run_in_mt_newsched_task {
             let mut called = false;
-            do io_error::cond.trap(|e| {
+            io_error::cond.trap(|e| {
                 assert!(e.kind == PermissionDenied);
                 called = true;
-            }).inside {
+            }).inside(|| {
                 let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 };
                 let socket = UdpSocket::bind(addr);
                 assert!(socket.is_none());
-            }
+            });
             assert!(called);
         }
     }
index eb86f0ef97fe3bd06c2705ebfa0747191fcb1ae1..809473d64c68eecbbea2b0190cc61e6171b9897d 100644 (file)
@@ -186,13 +186,13 @@ fn smalltest(server: proc(UnixStream), client: proc(UnixStream)) {
     fn bind_error() {
         do run_in_mt_newsched_task {
             let mut called = false;
-            do io_error::cond.trap(|e| {
+            io_error::cond.trap(|e| {
                 assert!(e.kind == PermissionDenied);
                 called = true;
-            }).inside {
+            }).inside(|| {
                 let listener = UnixListener::bind(&("path/to/nowhere"));
                 assert!(listener.is_none());
-            }
+            });
             assert!(called);
         }
     }
@@ -201,13 +201,13 @@ fn bind_error() {
     fn connect_error() {
         do run_in_mt_newsched_task {
             let mut called = false;
-            do io_error::cond.trap(|e| {
+            io_error::cond.trap(|e| {
                 assert_eq!(e.kind, OtherIoError);
                 called = true;
-            }).inside {
+            }).inside(|| {
                 let stream = UnixStream::connect(&("path/to/nowhere"));
                 assert!(stream.is_none());
-            }
+            });
             assert!(called);
         }
     }
@@ -240,13 +240,13 @@ fn write_begone() {
             let buf = [0];
             let mut stop = false;
             while !stop{
-                do io_error::cond.trap(|e| {
+                io_error::cond.trap(|e| {
                     assert!(e.kind == BrokenPipe || e.kind == NotConnected,
                             "unknown error {:?}", e);
                     stop = true;
-                }).inside {
+                }).inside(|| {
                     server.write(buf);
-                }
+                })
             }
         }, |_client| {
             // drop the client
@@ -266,20 +266,20 @@ fn accept_lots() {
             do spawntask {
                 let mut acceptor = UnixListener::bind(&path1).listen();
                 chan.take().send(());
-                do times.times {
+                times.times(|| {
                     let mut client = acceptor.accept();
                     let mut buf = [0];
                     client.read(buf);
                     assert_eq!(buf[0], 100);
-                }
+                })
             }
 
             do spawntask {
                 port.take().recv();
-                do times.times {
+                times.times(|| {
                     let mut stream = UnixStream::connect(&path2);
                     stream.write([100]);
-                }
+                })
             }
         }
     }
index 5938252571f515927f18123e335806c7ad93c2c5..61c5411f3602fa611759a702009c2632ba792951 100644 (file)
@@ -125,21 +125,21 @@ fn test_option_writer_error() {
             let mut writer: Option<MemWriter> = None;
 
             let mut called = false;
-            do io_error::cond.trap(|err| {
+            io_error::cond.trap(|err| {
                 assert_eq!(err.kind, PreviousIoError);
                 called = true;
-            }).inside {
+            }).inside(|| {
                 writer.write([0, 0, 0]);
-            }
+            });
             assert!(called);
 
             let mut called = false;
-            do io_error::cond.trap(|err| {
+            io_error::cond.trap(|err| {
                 assert_eq!(err.kind, PreviousIoError);
                 called = true;
-            }).inside {
+            }).inside(|| {
                 writer.flush();
-            }
+            });
             assert!(called);
         }
     }
@@ -161,21 +161,21 @@ fn test_option_reader_error() {
         let mut buf = [];
 
         let mut called = false;
-        do io_error::cond.trap(|err| {
+        io_error::cond.trap(|err| {
             assert_eq!(err.kind, PreviousIoError);
             called = true;
-        }).inside {
+        }).inside(|| {
             reader.read(buf);
-        }
+        });
         assert!(called);
 
         let mut called = false;
-        do io_error::cond.trap(|err| {
+        io_error::cond.trap(|err| {
             assert_eq!(err.kind, PreviousIoError);
             called = true;
-        }).inside {
+        }).inside(|| {
             assert!(reader.eof());
-        }
+        });
         assert!(called);
     }
 }
index b1958bde60d2a7b1d25d8157c246d73482daf416..75a7d5db1321e392845d7ef31643108bf539a7e7 100644 (file)
@@ -2674,13 +2674,13 @@ fn test_rposition() {
     fn test_rposition_fail() {
         let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
         let mut i = 0;
-        do v.iter().rposition |_elt| {
+        v.iter().rposition(|_elt| {
             if i == 2 {
                 fail!()
             }
             i += 1;
             false
-        };
+        });
     }
 
 
index 89907c7434cdf554f175b9dc145477856697acfc..335bbc8b1da30d519b1a36d9e1238413c6113fe9 100644 (file)
@@ -479,19 +479,19 @@ fn test_owned() {
         static key: Key<~int> = &Key;
         set(key, ~1);
 
-        do get(key) |v| {
-            do get(key) |v| {
-                do get(key) |v| {
+        get(key, |v| {
+            get(key, |v| {
+                get(key, |v| {
                     assert_eq!(**v.unwrap(), 1);
-                }
+                });
                 assert_eq!(**v.unwrap(), 1);
-            }
+            });
             assert_eq!(**v.unwrap(), 1);
-        }
+        });
         set(key, ~2);
-        do get(key) |v| {
+        get(key, |v| {
             assert_eq!(**v.unwrap(), 2);
-        }
+        })
     }
 
     #[test]
@@ -499,13 +499,13 @@ fn test_get_mut() {
         static key: Key<int> = &Key;
         set(key, 1);
 
-        do get_mut(key) |v| {
+        get_mut(key, |v| {
             *v.unwrap() = 2;
-        }
+        });
 
-        do get(key) |v| {
+        get(key, |v| {
             assert_eq!(*v.unwrap(), 2);
-        }
+        })
     }
 
     #[test]
@@ -533,9 +533,9 @@ fn test_same_key_type() {
     fn test_nested_get_set1() {
         static key: Key<int> = &Key;
         set(key, 4);
-        do get(key) |_| {
+        get(key, |_| {
             set(key, 4);
-        }
+        })
     }
 
     #[test]
@@ -543,9 +543,9 @@ fn test_nested_get_set1() {
     fn test_nested_get_mut2() {
         static key: Key<int> = &Key;
         set(key, 4);
-        do get(key) |_| {
+        get(key, |_| {
             get_mut(key, |_| {})
-        }
+        })
     }
 
     #[test]
@@ -553,9 +553,9 @@ fn test_nested_get_mut2() {
     fn test_nested_get_mut3() {
         static key: Key<int> = &Key;
         set(key, 4);
-        do get_mut(key) |_| {
+        get_mut(key, |_| {
             get(key, |_| {})
-        }
+        })
     }
 
     #[test]
@@ -563,8 +563,8 @@ fn test_nested_get_mut3() {
     fn test_nested_get_mut4() {
         static key: Key<int> = &Key;
         set(key, 4);
-        do get_mut(key) |_| {
+        get_mut(key, |_| {
             get_mut(key, |_| {})
-        }
+        })
     }
 }
index 5d713f1a622cc7e51179e7266f3ba14637ef5b9d..1028cef9dc6475754703644e1ee8bd7a040bcc88 100644 (file)
@@ -750,16 +750,16 @@ mod bench {
     #[bench]
     fn uint_to_str_rand(bh: &mut BenchHarness) {
         let mut rng = XorShiftRng::new();
-        do bh.iter {
+        bh.iter(|| {
             rng.gen::<uint>().to_str();
-        }
+        })
     }
 
     #[bench]
     fn float_to_str_rand(bh: &mut BenchHarness) {
         let mut rng = XorShiftRng::new();
-        do bh.iter {
+        bh.iter(|| {
             f64::to_str(rng.gen());
-        }
+        })
     }
 }
index 1cc0c19150137caf7f6b48fee8dcbe6f2b5e23ca..cf7047bd068a0a567815e6860d846e1993d58b81 100644 (file)
@@ -244,6 +244,6 @@ pub fn test_times() {
     use num::Times;
     let ten = 10 as uint;
     let mut accum = 0;
-    do ten.times { accum += 1; }
+    ten.times(|| { accum += 1; });
     assert!((accum == 10));
 }
index c5a10c75640ec364f327b0367db471d50f87987d..715072653a7ab616fce00e4e6ad2afbbb235f915 100644 (file)
@@ -612,14 +612,14 @@ fn test_or_else() {
     #[test]
     fn test_option_while_some() {
         let mut i = 0;
-        do Some(10).while_some |j| {
+        Some(10).while_some(|j| {
             i += 1;
             if (j > 0) {
                 Some(j-1)
             } else {
                 None
             }
-        }
+        });
         assert_eq!(i, 11);
     }
 
index dcd0829533174b2f6c8e3208e84d02d08174bf2b..ddfb43ed56f8707f252b28a03e5e73570d773e20 100644 (file)
@@ -523,35 +523,35 @@ fn test_null_byte() {
         use path::null_byte::cond;
 
         let mut handled = false;
-        let mut p = do cond.trap(|v| {
+        let mut p = cond.trap(|v| {
             handled = true;
             assert_eq!(v.as_slice(), b!("foo/bar", 0));
             (b!("/bar").to_owned())
-        }).inside {
+        }).inside(|| {
             Path::new(b!("foo/bar", 0))
-        };
+        });
         assert!(handled);
         assert_eq!(p.as_vec(), b!("/bar"));
 
         handled = false;
-        do cond.trap(|v| {
+        cond.trap(|v| {
             handled = true;
             assert_eq!(v.as_slice(), b!("f", 0, "o"));
             (b!("foo").to_owned())
-        }).inside {
+        }).inside(|| {
             p.set_filename(b!("f", 0, "o"))
-        };
+        });
         assert!(handled);
         assert_eq!(p.as_vec(), b!("/foo"));
 
         handled = false;
-        do cond.trap(|v| {
+        cond.trap(|v| {
             handled = true;
             assert_eq!(v.as_slice(), b!("f", 0, "o"));
             (b!("foo").to_owned())
-        }).inside {
+        }).inside(|| {
             p.push(b!("f", 0, "o"));
-        };
+        });
         assert!(handled);
         assert_eq!(p.as_vec(), b!("/foo/foo"));
     }
@@ -573,29 +573,29 @@ macro_rules! t(
         )
 
         t!(~"new() w/nul" => {
-            do cond.trap(|_| {
+            cond.trap(|_| {
                 (b!("null", 0).to_owned())
-            }).inside {
+            }).inside(|| {
                 Path::new(b!("foo/bar", 0))
-            };
+            });
         })
 
         t!(~"set_filename w/nul" => {
             let mut p = Path::new(b!("foo/bar"));
-            do cond.trap(|_| {
+            cond.trap(|_| {
                 (b!("null", 0).to_owned())
-            }).inside {
+            }).inside(|| {
                 p.set_filename(b!("foo", 0))
-            };
+            });
         })
 
         t!(~"push w/nul" => {
             let mut p = Path::new(b!("foo/bar"));
-            do cond.trap(|_| {
+            cond.trap(|_| {
                 (b!("null", 0).to_owned())
-            }).inside {
+            }).inside(|| {
                 p.push(b!("foo", 0))
-            };
+            });
         })
     }
 
@@ -621,10 +621,10 @@ macro_rules! t(
                 {
                     let mut called = false;
                     let path = Path::new($path);
-                    do path.display().with_str |s| {
+                    path.display().with_str(|s| {
                         assert_eq!(s, $exp);
                         called = true;
-                    };
+                    });
                     assert!(called);
                 }
             );
@@ -632,11 +632,10 @@ macro_rules! t(
                 {
                     let mut called = false;
                     let path = Path::new($path);
-                    do path.filename_display().with_str |s| {
+                    path.filename_display().with_str(|s| {
                         assert_eq!(s, $exp);
                         called = true;
-
-                    };
+                    });
                     assert!(called);
                 }
             )
index 4e736458fd8f27eeadf59822bd441ff6c6d3cd31..cc2af54fd105c62fe2db9cf35d30f1f1a3964767 100644 (file)
@@ -1248,35 +1248,35 @@ fn test_null_byte() {
         use path::null_byte::cond;
 
         let mut handled = false;
-        let mut p = do cond.trap(|v| {
+        let mut p = cond.trap(|v| {
             handled = true;
             assert_eq!(v.as_slice(), b!("foo\\bar", 0));
             (b!("\\bar").to_owned())
-        }).inside {
+        }).inside(|| {
             Path::new(b!("foo\\bar", 0))
-        };
+        });
         assert!(handled);
         assert_eq!(p.as_vec(), b!("\\bar"));
 
         handled = false;
-        do cond.trap(|v| {
+        cond.trap(|v| {
             handled = true;
             assert_eq!(v.as_slice(), b!("f", 0, "o"));
             (b!("foo").to_owned())
-        }).inside {
+        }).inside(|| {
             p.set_filename(b!("f", 0, "o"))
-        };
+        });
         assert!(handled);
         assert_eq!(p.as_vec(), b!("\\foo"));
 
         handled = false;
-        do cond.trap(|v| {
+        cond.trap(|v| {
             handled = true;
             assert_eq!(v.as_slice(), b!("f", 0, "o"));
             (b!("foo").to_owned())
-        }).inside {
+        }).inside(|| {
             p.push(b!("f", 0, "o"));
-        };
+        });
         assert!(handled);
         assert_eq!(p.as_vec(), b!("\\foo\\foo"));
     }
@@ -1298,29 +1298,29 @@ macro_rules! t(
         )
 
         t!(~"from_vec() w\\nul" => {
-            do cond.trap(|_| {
+            cond.trap(|_| {
                 (b!("null", 0).to_owned())
-            }).inside {
+            }).inside(|| {
                 Path::new(b!("foo\\bar", 0))
-            };
+            });
         })
 
         t!(~"set_filename w\\nul" => {
             let mut p = Path::new(b!("foo\\bar"));
-            do cond.trap(|_| {
+            cond.trap(|_| {
                 (b!("null", 0).to_owned())
-            }).inside {
+            }).inside(|| {
                 p.set_filename(b!("foo", 0))
-            };
+            });
         })
 
         t!(~"push w\\nul" => {
             let mut p = Path::new(b!("foo\\bar"));
-            do cond.trap(|_| {
+            cond.trap(|_| {
                 (b!("null", 0).to_owned())
-            }).inside {
+            }).inside(|| {
                 p.push(b!("foo", 0))
-            };
+            });
         })
     }
 
@@ -1339,17 +1339,17 @@ fn test_display_str() {
 
         let mut called = false;
         let path = Path::new("foo");
-        do path.display().with_str |s| {
+        path.display().with_str(|s| {
             assert_eq!(s, "foo");
             called = true;
-        };
+        });
         assert!(called);
         called = false;
         let path = Path::new(b!("\\"));
-        do path.filename_display().with_str |s| {
+        path.filename_display().with_str(|s| {
             assert_eq!(s, "");
             called = true;
-        }
+        });
         assert!(called);
     }
 
index 9f60c3a32b266717b6c0162643c974a44fe8efb2..9b9636af901f241c6b52662d55c7b68fb8ec3071 100644 (file)
@@ -492,28 +492,28 @@ struct Pair {
     fn test_position() {
         use libc::c_char;
 
-        do "hello".with_c_str |p| {
+        "hello".with_c_str(|p| {
             unsafe {
                 assert!(2u == position(p, |c| *c == 'l' as c_char));
                 assert!(4u == position(p, |c| *c == 'o' as c_char));
                 assert!(5u == position(p, |c| *c == 0 as c_char));
             }
-        }
+        })
     }
 
     #[test]
     fn test_buf_len() {
-        do "hello".with_c_str |p0| {
-            do "there".with_c_str |p1| {
-                do "thing".with_c_str |p2| {
+        "hello".with_c_str(|p0| {
+            "there".with_c_str(|p1| {
+                "thing".with_c_str(|p2| {
                     let v = ~[p0, p1, p2, null()];
-                    do v.as_imm_buf |vp, len| {
+                    v.as_imm_buf(|vp, len| {
                         assert_eq!(unsafe { buf_len(vp) }, 3u);
                         assert_eq!(len, 4u);
-                    }
-                }
-            }
-        }
+                    })
+                })
+            })
+        })
     }
 
     #[test]
@@ -621,23 +621,23 @@ fn test_ptr_array_each_with_len() {
                 one, two, three
             ];
 
-            do arr.as_imm_buf |arr_ptr, arr_len| {
+            arr.as_imm_buf(|arr_ptr, arr_len| {
                 let mut ctr = 0;
                 let mut iteration_count = 0;
-                do array_each_with_len(arr_ptr, arr_len) |e| {
+                array_each_with_len(arr_ptr, arr_len, |e| {
                      let actual = str::raw::from_c_str(e);
-                     let expected = do expected_arr[ctr].with_ref |buf| {
+                     let expected = expected_arr[ctr].with_ref(|buf| {
                          str::raw::from_c_str(buf)
-                     };
+                     });
                      debug!(
                          "test_ptr_array_each_with_len e: {}, a: {}",
                          expected, actual);
                      assert_eq!(actual, expected);
                      ctr += 1;
                      iteration_count += 1;
-                 }
+                });
                 assert_eq!(iteration_count, 3u);
-            }
+            })
         }
     }
 
@@ -658,23 +658,23 @@ fn test_ptr_array_each() {
                 one, two, three
             ];
 
-            do arr.as_imm_buf |arr_ptr, _| {
+            arr.as_imm_buf(|arr_ptr, _| {
                 let mut ctr = 0;
                 let mut iteration_count = 0;
-                do array_each(arr_ptr) |e| {
+                array_each(arr_ptr, |e| {
                      let actual = str::raw::from_c_str(e);
-                     let expected = do expected_arr[ctr].with_ref |buf| {
+                     let expected = expected_arr[ctr].with_ref(|buf| {
                          str::raw::from_c_str(buf)
-                     };
+                     });
                      debug!(
                          "test_ptr_array_each e: {}, a: {}",
                          expected, actual);
                      assert_eq!(actual, expected);
                      ctr += 1;
                      iteration_count += 1;
-                 }
+                });
                 assert_eq!(iteration_count, 3);
-            }
+            })
         }
     }
 
index 7e8c193cb777e7472e7271c6714dbe05288d488a..e042874245967af31fed9e5fa2f944571db63b14 100644 (file)
@@ -184,11 +184,11 @@ fn bench_gamma_large_shape(bh: &mut BenchHarness) {
         let gamma = Gamma::new(10., 1.0);
         let mut rng = StdRng::new();
 
-        do bh.iter {
+        bh.iter(|| {
             for _ in range(0, RAND_BENCH_N) {
                 gamma.ind_sample(&mut rng);
             }
-        }
+        });
         bh.bytes = size_of::<f64>() as u64 * RAND_BENCH_N;
     }
 
@@ -197,11 +197,11 @@ fn bench_gamma_small_shape(bh: &mut BenchHarness) {
         let gamma = Gamma::new(0.1, 1.0);
         let mut rng = StdRng::new();
 
-        do bh.iter {
+        bh.iter(|| {
             for _ in range(0, RAND_BENCH_N) {
                 gamma.ind_sample(&mut rng);
             }
-        }
+        });
         bh.bytes = size_of::<f64>() as u64 * RAND_BENCH_N;
     }
 }
index 247a7824a4465c7eb296fc00bef231e5630ba7c9..4778e81f95169510e2ff019e9935afe3815de16d 100644 (file)
@@ -571,11 +571,11 @@ fn rand_normal(bh: &mut BenchHarness) {
         let mut rng = XorShiftRng::new();
         let mut normal = Normal::new(-2.71828, 3.14159);
 
-        do bh.iter {
+        bh.iter(|| {
             for _ in range(0, RAND_BENCH_N) {
                 normal.sample(&mut rng);
             }
-        }
+        });
         bh.bytes = size_of::<f64>() as u64 * RAND_BENCH_N;
     }
     #[bench]
@@ -583,11 +583,11 @@ fn rand_exp(bh: &mut BenchHarness) {
         let mut rng = XorShiftRng::new();
         let mut exp = Exp::new(2.71828 * 3.14159);
 
-        do bh.iter {
+        bh.iter(|| {
             for _ in range(0, RAND_BENCH_N) {
                 exp.sample(&mut rng);
             }
-        }
+        });
         bh.bytes = size_of::<f64>() as u64 * RAND_BENCH_N;
     }
 }
index 39b4cca20635837c3d2d682f2e89b85baf6d02da..ae53ef8b7c0b15ace73bdf2f66c32bfbb2270dfa 100644 (file)
@@ -899,44 +899,44 @@ mod bench {
     #[bench]
     fn rand_xorshift(bh: &mut BenchHarness) {
         let mut rng = XorShiftRng::new();
-        do bh.iter {
+        bh.iter(|| {
             for _ in range(0, RAND_BENCH_N) {
                 rng.gen::<uint>();
             }
-        }
+        });
         bh.bytes = size_of::<uint>() as u64 * RAND_BENCH_N;
     }
 
     #[bench]
     fn rand_isaac(bh: &mut BenchHarness) {
         let mut rng = IsaacRng::new();
-        do bh.iter {
+        bh.iter(|| {
             for _ in range(0, RAND_BENCH_N) {
                 rng.gen::<uint>();
             }
-        }
+        });
         bh.bytes = size_of::<uint>() as u64 * RAND_BENCH_N;
     }
 
     #[bench]
     fn rand_isaac64(bh: &mut BenchHarness) {
         let mut rng = Isaac64Rng::new();
-        do bh.iter {
+        bh.iter(|| {
             for _ in range(0, RAND_BENCH_N) {
                 rng.gen::<uint>();
             }
-        }
+        });
         bh.bytes = size_of::<uint>() as u64 * RAND_BENCH_N;
     }
 
     #[bench]
     fn rand_std(bh: &mut BenchHarness) {
         let mut rng = StdRng::new();
-        do bh.iter {
+        bh.iter(|| {
             for _ in range(0, RAND_BENCH_N) {
                 rng.gen::<uint>();
             }
-        }
+        });
         bh.bytes = size_of::<uint>() as u64 * RAND_BENCH_N;
     }
 
@@ -944,8 +944,8 @@ fn rand_std(bh: &mut BenchHarness) {
     fn rand_shuffle_100(bh: &mut BenchHarness) {
         let mut rng = XorShiftRng::new();
         let x : &mut[uint] = [1,..100];
-        do bh.iter {
+        bh.iter(|| {
             rng.shuffle_mut(x);
-        }
+        })
     }
 }
index 97daf8d7e60df5dca24ad7cdd1f9df56bbaaa1db..ff425a8a73b2598ba5cf1f86537b7a30cc7e5648 100644 (file)
@@ -139,9 +139,9 @@ pub fn unwrap_err(self) -> E {
     ///
     /// Example:
     ///
-    ///     let res = do read_file(file).map |buf| {
+    ///     let res = read_file(file).map(|buf| {
     ///         parse_bytes(buf)
-    ///     }
+    ///     })
     #[inline]
     pub fn map<U>(self, op: |T| -> U) -> Result<U,E> {
         match self {
@@ -462,11 +462,11 @@ pub fn test_or_else() {
     pub fn test_impl_iter() {
         let mut valid = false;
         let okval = Ok::<~str, ~str>(~"a");
-        do okval.iter().next().map |_| { valid = true; };
+        okval.iter().next().map(|_| { valid = true; });
         assert!(valid);
 
         let errval = Err::<~str, ~str>(~"b");
-        do errval.iter().next().map |_| { valid = false; };
+        errval.iter().next().map(|_| { valid = false; });
         assert!(valid);
     }
 
@@ -474,12 +474,12 @@ pub fn test_impl_iter() {
     pub fn test_impl_iter_err() {
         let mut valid = true;
         let okval = Ok::<~str, ~str>(~"a");
-        do okval.iter_err().next().map |_| { valid = false };
+        okval.iter_err().next().map(|_| { valid = false });
         assert!(valid);
 
         valid = false;
         let errval = Err::<~str, ~str>(~"b");
-        do errval.iter_err().next().map |_| { valid = true };
+        errval.iter_err().next().map(|_| { valid = true });
         assert!(valid);
     }
 
index e3e425f620bd1f6ef38554ad283082481e1a9965..52a6d67cb05fb01ed499f6961d17ab3e428d9397 100644 (file)
@@ -1013,7 +1013,7 @@ fn shared_chan_stress() {
 
             total.times(|| {
                 port.recv();
-            })
+            });
         }
     }
 
@@ -1041,7 +1041,7 @@ fn shared_port_stress() {
 
             total.times(|| {
                 end_port.recv();
-            })
+            });
         }
     }
 
@@ -1071,7 +1071,7 @@ fn shared_port_close() {
                     do spawntask_random {
                         chan_clone.send(());
                     }
-                })
+                });
             }
             let end_chan_clone = end_chan.clone();
             do spawntask_random {
@@ -1082,7 +1082,7 @@ fn shared_port_close() {
                         let recvd = port_clone.try_recv().is_some();
                         end_chan_clone.send(recvd);
                     }
-                })
+                });
             }
 
             let mut recvd = 0;
@@ -1112,12 +1112,12 @@ fn megapipe_stress() {
                 let pipe_clone = pipe.clone();
                 let end_chan_clone = end_chan.clone();
                 do spawntask_random {
-                    do msgs.times {
+                    msgs.times(|| {
                         pipe_clone.send(());
-                    }
-                    do msgs.times {
+                    });
+                    msgs.times(|| {
                         pipe_clone.recv();
-                    }
+                    });
                 }
 
                 end_chan_clone.send(());
@@ -1125,7 +1125,7 @@ fn megapipe_stress() {
 
             total.times(|| {
                 end_port.recv();
-            })
+            });
         }
     }
 
index 76ccacb331fe768622066373fb54c7978d4ef5bb..6dcbd4a129e5c62ef7d227ca2e9c3f163fe7f366 100644 (file)
@@ -61,9 +61,9 @@ pub fn get_crate_map() -> Option<&'static CrateMap<'static>> {
         } else {
             "_rust_crate_map_toplevel"
         };
-        let sym = do rust_crate_map_toplevel.with_c_str |buf| {
+        let sym = rust_crate_map_toplevel.with_c_str(|buf| {
             dl::symbol(module, buf)
-        };
+        });
         dl::close(module);
         sym
     };
@@ -141,10 +141,10 @@ fn iter_crate_map_duplicates() {
 
         let mut cnt = 0;
         unsafe {
-            do iter_crate_map(&root_crate) |entry| {
+            iter_crate_map(&root_crate, |entry| {
                 assert!(*entry.log_level == 3);
                 cnt += 1;
-            }
+            });
             assert!(cnt == 1);
         }
     }
@@ -183,10 +183,10 @@ fn iter_crate_map_follow_children() {
 
         let mut cnt = 0;
         unsafe {
-            do iter_crate_map(&root_crate) |entry| {
+            iter_crate_map(&root_crate, |entry| {
                 assert!(*entry.log_level == cnt);
                 cnt += 1;
-            }
+            });
             assert!(cnt == 4);
         }
     }
index 08d111da351554620bfe6403bd13429a729422d4..3147e3c8a078e18e6196a10043f10598908c7638 100644 (file)
@@ -103,15 +103,15 @@ mod bench {
 
     #[bench]
     fn alloc_owned_small(bh: &mut BenchHarness) {
-        do bh.iter {
+        bh.iter(|| {
             ~10;
-        }
+        })
     }
 
     #[bench]
     fn alloc_owned_big(bh: &mut BenchHarness) {
-        do bh.iter {
+        bh.iter(|| {
             ~[10, ..1000];
-        }
+        })
     }
 }
index 23345926543c094b921da596e90e17bbd8dcd7e1..d5b0e384ca2914273447b1b42cdf8553908c78e3 100644 (file)
@@ -182,9 +182,9 @@ fn borrow_with_return() {
             let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
             Local::put(task);
 
-            let res = do Local::borrow |_task: &mut Task| {
+            let res = Local::borrow(|_task: &mut Task| {
                 true
-            };
+            });
             assert!(res)
                 let task: ~Task = Local::take();
             cleanup_task(task);
index a7805a9f55925bff4a84b42f9be054b522dce1a2..c98a66453eb158bd0a74eb918e6a5ebd562b231d 100644 (file)
@@ -311,11 +311,11 @@ mod bench {
 
     #[bench]
     fn alloc_managed_small(bh: &mut BenchHarness) {
-        bh.iter(|| @10);
+        bh.iter(|| { @10; });
     }
 
     #[bench]
     fn alloc_managed_big(bh: &mut BenchHarness) {
-        bh.iter(|| @[10, ..1000]);
+        bh.iter(|| { @[10, ..1000]; });
     }
 }
index 519274bb131cf70f8056b82cdc4abf9d5eb8762b..ccc786242e6ebb07c69a4be5b88e630da66bfa02 100644 (file)
@@ -1176,7 +1176,7 @@ fn no_missed_messages() {
         use util;
 
         do run_in_bare_thread {
-            do stress_factor().times {
+            stress_factor().times(|| {
                 let sleepers = SleeperList::new();
                 let queue = WorkQueue::new();
                 let queues = ~[queue.clone()];
@@ -1205,7 +1205,7 @@ fn no_missed_messages() {
                 util::ignore(handle);
 
                 thread.join();
-            }
+            })
         }
     }
 
@@ -1218,14 +1218,14 @@ fn multithreading() {
 
         do run_in_mt_newsched_task {
             let mut ports = ~[];
-            do 10.times {
+            10.times(|| {
                 let (port, chan) = oneshot();
                 let chan_cell = Cell::new(chan);
                 do spawntask_later {
                     chan_cell.take().send(());
                 }
                 ports.push(port);
-            }
+            });
 
             while !ports.is_empty() {
                 ports.pop().recv();
@@ -1315,7 +1315,7 @@ fn drop(&mut self) {
     fn dont_starve_1() {
         use rt::comm::oneshot;
 
-        do stress_factor().times {
+        stress_factor().times(|| {
             do run_in_mt_newsched_task {
                 let (port, chan) = oneshot();
 
@@ -1327,14 +1327,14 @@ fn dont_starve_1() {
 
                 chan.send(());
             }
-        }
+        })
     }
 
     #[test]
     fn dont_starve_2() {
         use rt::comm::oneshot;
 
-        do stress_factor().times {
+        stress_factor().times(|| {
             do run_in_newsched_task {
                 let (port, chan) = oneshot();
                 let (_port2, chan2) = stream();
@@ -1349,7 +1349,7 @@ fn dont_starve_2() {
 
                 chan.send(());
             }
-        }
+        })
     }
 
     // Regression test for a logic bug that would cause single-threaded schedulers
@@ -1360,7 +1360,7 @@ fn single_threaded_yield() {
         use num::Times;
 
         do spawn_sched(SingleThreaded) {
-            do 5.times { deschedule(); }
+            5.times(|| { deschedule(); })
         }
         do spawn { }
         do spawn { }
index 360764daf156c4fc9d30b08e471ac30506f121f4..0d4171d5a643ca1c70a44b25cfe68631ee201e8b 100644 (file)
@@ -103,11 +103,11 @@ fn simple_test() {
             let tube_clone = tube.clone();
             let tube_clone_cell = Cell::new(tube_clone);
             let sched: ~Scheduler = Local::take();
-            do sched.deschedule_running_task_and_then |sched, task| {
+            sched.deschedule_running_task_and_then(|sched, task| {
                 let mut tube_clone = tube_clone_cell.take();
                 tube_clone.send(1);
                 sched.enqueue_blocked_task(task);
-            }
+            });
 
             assert!(tube.recv() == 1);
         }
@@ -120,7 +120,7 @@ fn blocking_test() {
             let tube_clone = tube.clone();
             let tube_clone = Cell::new(tube_clone);
             let sched: ~Scheduler = Local::take();
-            do sched.deschedule_running_task_and_then |sched, task| {
+            sched.deschedule_running_task_and_then(|sched, task| {
                 let tube_clone = Cell::new(tube_clone.take());
                 do sched.event_loop.callback {
                     let mut tube_clone = tube_clone.take();
@@ -129,7 +129,7 @@ fn blocking_test() {
                     tube_clone.send(1);
                 }
                 sched.enqueue_blocked_task(task);
-            }
+            });
 
             assert!(tube.recv() == 1);
         }
@@ -144,14 +144,14 @@ fn many_blocking_test() {
             let tube_clone = tube.clone();
             let tube_clone = Cell::new(tube_clone);
             let sched: ~Scheduler = Local::take();
-            do sched.deschedule_running_task_and_then |sched, task| {
+            sched.deschedule_running_task_and_then(|sched, task| {
                 callback_send(tube_clone.take(), 0);
 
                 fn callback_send(tube: Tube<int>, i: int) {
                     if i == 100 { return; }
 
                     let tube = Cell::new(Cell::new(tube));
-                    do Local::borrow |sched: &mut Scheduler| {
+                    Local::borrow(|sched: &mut Scheduler| {
                         let tube = tube.take();
                         do sched.event_loop.callback {
                             let mut tube = tube.take();
@@ -160,11 +160,11 @@ fn callback_send(tube: Tube<int>, i: int) {
                             tube.send(i);
                             callback_send(tube, i + 1);
                         }
-                    }
+                    })
                 }
 
                 sched.enqueue_blocked_task(task);
-            }
+            });
 
             for i in range(0, MAX) {
                 let j = tube.recv();
index b619085e201809b1ddfac57d0cfd8f6e9873c3f1..9b83c493065d2fcfb98f4e870246f6f790923e5d 100644 (file)
@@ -211,7 +211,7 @@ fn select_stream() {
         do run_in_uv_task {
             let (ports, _) = unzip(range(0u, 10).map(|_| stream::<int>()));
             let (port, chan) = stream();
-            do 10.times { chan.send(31337); }
+            10.times(|| { chan.send(31337); });
             let mut ports = ports;
             let mut port = Some(port);
             let order = [5u,0,4,3,2,6,9,8,7,1];
@@ -276,7 +276,7 @@ fn select_racing_senders_helper(send_on_chans: ~[uint]) {
 
             do run_in_uv_task {
                 // A bit of stress, since ordinarily this is just smoke and mirrors.
-                do 4.times {
+                4.times(|| {
                     let send_on_chans = send_on_chans.clone();
                     do task::spawn {
                         let mut ports = ~[];
@@ -294,7 +294,7 @@ fn select_racing_senders_helper(send_on_chans: ~[uint]) {
                         // nondeterministic result, but should succeed
                         select(ports);
                     }
-                }
+                })
             }
         }
     }
index b2ded6ab7541e28a5fd07e36d75cb7ff311c8218..f65ec6971aba7af47d466c835014c4dc2a58a72a 100644 (file)
@@ -3966,19 +3966,25 @@ fn is_utf8_100_ascii(bh: &mut BenchHarness) {
                         Lorem ipsum dolor sit amet, consectetur. ");
 
         assert_eq!(100, s.len());
-        bh.iter(|| is_utf8(s));
+        bh.iter(|| {
+            let _ = is_utf8(s);
+        });
     }
 
     #[bench]
     fn is_utf8_100_multibyte(bh: &mut BenchHarness) {
         let s = bytes!("𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰");
         assert_eq!(100, s.len());
-        bh.iter(|| is_utf8(s));
+        bh.iter(|| {
+            let _ = is_utf8(s);
+        });
     }
 
     #[bench]
     fn bench_with_capacity(bh: &mut BenchHarness) {
-        bh.iter(|| with_capacity(100));
+        bh.iter(|| {
+            let _ = with_capacity(100);
+        });
     }
 
     #[bench]
index 85f66d4ada827bdafd3f64e4d6fbe5cda7c517c5..189f1436d42d7beb2098f952464c73c68dcb119e 100644 (file)
@@ -477,9 +477,9 @@ fn test_unnamed_task() {
 
     do run_in_uv_task {
         do spawn {
-            do with_task_name |name| {
+            with_task_name(|name| {
                 assert!(name.is_none());
-            }
+            })
         }
     }
 }
@@ -492,9 +492,9 @@ fn test_owned_named_task() {
         let mut t = task();
         t.name(~"ada lovelace");
         do t.spawn {
-            do with_task_name |name| {
+            with_task_name(|name| {
                 assert!(name.unwrap() == "ada lovelace");
-            }
+            })
         }
     }
 }
@@ -507,9 +507,9 @@ fn test_static_named_task() {
         let mut t = task();
         t.name("ada lovelace");
         do t.spawn {
-            do with_task_name |name| {
+            with_task_name(|name| {
                 assert!(name.unwrap() == "ada lovelace");
-            }
+            })
         }
     }
 }
@@ -522,9 +522,9 @@ fn test_send_named_task() {
         let mut t = task();
         t.name("ada lovelace".into_send_str());
         do t.spawn {
-            do with_task_name |name| {
+            with_task_name(|name| {
                 assert!(name.unwrap() == "ada lovelace");
-            }
+            })
         }
     }
 }
@@ -606,9 +606,9 @@ fn test_try_fail() {
 
 #[cfg(test)]
 fn get_sched_id() -> int {
-    do Local::borrow |sched: &mut ::rt::sched::Scheduler| {
+    Local::borrow(|sched: &mut ::rt::sched::Scheduler| {
         sched.sched_id() as int
-    }
+    })
 }
 
 #[test]
@@ -666,7 +666,7 @@ fn test_spawn_sched_blocking() {
 
         // Testing that a task in one scheduler can block in foreign code
         // without affecting other schedulers
-        do 20u.times {
+        20u.times(|| {
             let (start_po, start_ch) = stream();
             let (fin_po, fin_ch) = stream();
 
@@ -713,7 +713,7 @@ fn pingpong(po: &Port<int>, ch: &Chan<int>) {
             lock.unlock();
             fin_po.recv();
             lock.destroy();
-        }
+        })
     }
 }
 
@@ -740,21 +740,21 @@ fn test_avoid_copying_the_body_spawn() {
 
 #[test]
 fn test_avoid_copying_the_body_task_spawn() {
-    do avoid_copying_the_body |f| {
+    avoid_copying_the_body(|f| {
         let builder = task();
         do builder.spawn || {
             f();
         }
-    }
+    })
 }
 
 #[test]
 fn test_avoid_copying_the_body_try() {
-    do avoid_copying_the_body |f| {
+    avoid_copying_the_body(|f| {
         do try || {
             f()
         };
-    }
+    })
 }
 
 #[test]
index 226ce9ef6f2e631c4491cdbafa41a8a945c82db9..57aff6031bafd7940e4c92344cbd76eb28a918c4 100644 (file)
 # Example
 
  ```
-do || {
+(|| {
     ...
-}.finally {
+}).finally(|| {
     always_run_this();
-}
+})
  ```
 */
 
@@ -70,13 +70,13 @@ fn drop(&mut self) {
 #[test]
 fn test_success() {
     let mut i = 0;
-    do (|| {
+    (|| {
         i = 10;
-    }).finally {
+    }).finally(|| {
         assert!(!failing());
         assert_eq!(i, 10);
         i = 20;
-    }
+    });
     assert_eq!(i, 20);
 }
 
@@ -84,19 +84,19 @@ fn test_success() {
 #[should_fail]
 fn test_fail() {
     let mut i = 0;
-    do (|| {
+    (|| {
         i = 10;
         fail!();
-    }).finally {
+    }).finally(|| {
         assert!(failing());
         assert_eq!(i, 10);
-    }
+    })
 }
 
 #[test]
 fn test_retval() {
     let closure: || -> int = || 10;
-    let i = do closure.finally { };
+    let i = closure.finally(|| { });
     assert_eq!(i, 10);
 }
 
index 8e939caf756902a1a511f948e113463e9eeff5b9..ddcf408189ed261845b9177b1dadc514eedd80d1 100644 (file)
@@ -178,17 +178,17 @@ fn method(&self) -> int {
     fn trait_vtable_method_call(bh: &mut BenchHarness) {
         let s = Struct { field: 10 };
         let t = &s as &Trait;
-        do bh.iter {
+        bh.iter(|| {
             t.method();
-        }
+        });
     }
 
     #[bench]
     fn trait_static_method_call(bh: &mut BenchHarness) {
         let s = Struct { field: 10 };
-        do bh.iter {
+        bh.iter(|| {
             s.method();
-        }
+        });
     }
 
     // Overhead of various match forms
@@ -196,22 +196,22 @@ fn trait_static_method_call(bh: &mut BenchHarness) {
     #[bench]
     fn match_option_some(bh: &mut BenchHarness) {
         let x = Some(10);
-        do bh.iter {
+        bh.iter(|| {
             let _q = match x {
                 Some(y) => y,
                 None => 11
             };
-        }
+        });
     }
 
     #[bench]
     fn match_vec_pattern(bh: &mut BenchHarness) {
         let x = [1,2,3,4,5,6];
-        do bh.iter {
+        bh.iter(|| {
             let _q = match x {
                 [1,2,3,.._] => 10,
                 _ => 11
             };
-        }
+        });
     }
 }
index 30627327d732755988e8c8da4375187cb469862a..9dc4f6ae3771c81d70a6b9c4edc8096512c5c2a0 100644 (file)
@@ -3878,13 +3878,17 @@ fn add(bh: &mut BenchHarness) {
     #[bench]
     fn concat(bh: &mut BenchHarness) {
         let xss: &[~[uint]] = vec::from_fn(100, |i| range(0, i).collect());
-        bh.iter(|| xss.concat_vec());
+        bh.iter(|| {
+            let _ = xss.concat_vec();
+        });
     }
 
     #[bench]
     fn connect(bh: &mut BenchHarness) {
         let xss: &[~[uint]] = vec::from_fn(100, |i| range(0, i).collect());
-        bh.iter(|| xss.connect_vec(&0));
+        bh.iter(|| {
+            let _ = xss.connect_vec(&0);
+        });
     }
 
     #[bench]
index d5ce63e7e9bc0939bdf20bfecfbd3d5f5f3d7914..afe9de7abb969f86d2cd9abaf47682ee3493e736 100644 (file)
@@ -15,7 +15,7 @@
 }
 
 pub fn guard(k: extern fn() -> int, x: int) -> int {
-    do oops::cond.trap(|i| i*x).inside {
+    oops::cond.trap(|i| i*x).inside(|| {
         k()
-    }
+    })
 }
index f8a3c5c573a0d3e8dac740ef9b78eea23f332258..c31a7bb244c72d5305a0f9f53a05a93bbfdba3ca 100644 (file)
@@ -14,8 +14,6 @@
 fn main() {
     let x = ~arc::RWArc::new(1);
     let mut y = None;
-    do x.write_cond |_one, cond| {
-        y = Some(cond);
-    }
+    x.write_cond(|_one, cond| y = Some(cond));
     y.unwrap().wait();
 }
index cb6290686816d74054a3e9923c9f4a862d628bd7..2fe2095ca879efd22bad0529c5d3dfbf97c57267 100644 (file)
 fn main() {
     let x = ~arc::RWArc::new(1);
     let mut y = None;
-    do x.write_downgrade |write_mode| {
+    x.write_downgrade(|write_mode| {
         y = Some(x.downgrade(write_mode));
         //~^ ERROR cannot infer an appropriate lifetime
-    }
+    });
     y.unwrap();
     // Adding this line causes a method unification failure instead
     // do (&option::unwrap(y)).read |state| { assert!(*state == 1); }
index 44657dfd0efe61baa803cced381bd7778bd37926..7c129ae0dcaad33e0eeeeea78e3bc610563bb0ef 100644 (file)
@@ -13,9 +13,7 @@
 fn main() {
     let x = ~arc::RWArc::new(1);
     let mut y = None; //~ ERROR lifetime of variable does not enclose its declaration
-    do x.write |one| {
-        y = Some(one);
-    }
+    x.write(|one| y = Some(one));
     *y.unwrap() = 2;
     //~^ ERROR lifetime of return value does not outlive the function call
     //~^^ ERROR dereference of reference outside its lifetime
index 44ac0e722d38af9d4deb25c2bbc35a4674837b40..674cd5708889c4dfeeb54c81f6079b49f1189801 100644 (file)
 fn main() {
     let x = ~arc::RWArc::new(1);
     let mut y = None;
-    do x.write_downgrade |write_mode| {
-        do (&write_mode).write_cond |_one, cond| {
+    x.write_downgrade(|write_mode| {
+        (&write_mode).write_cond(|_one, cond| {
             y = Some(cond);
-        }
-    }
+        })
+    });
     y.unwrap().wait();
 }
index 75e1989aff01a5ad7faf55da8087bf89bda910cb..d9247ab4fc170d16c31a592be1e35132bb7ed5c6 100644 (file)
@@ -14,9 +14,7 @@
 fn main() {
     let x = ~arc::RWArc::new(1);
     let mut y = None;
-    do x.write_downgrade |write_mode| {
-        y = Some(write_mode);
-    }
+    x.write_downgrade(|write_mode| y = Some(write_mode));
     y.unwrap();
     // Adding this line causes a method unification failure instead
     // do (&option::unwrap(y)).write |state| { assert!(*state == 1); }
diff --git a/src/test/compile-fail/block-arg-as-stmt-with-value.rs b/src/test/compile-fail/block-arg-as-stmt-with-value.rs
deleted file mode 100644 (file)
index 7637ebd..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn compute1() -> f64 {
-    let v = ~[0f64, 1.0, 2.0, 3.0];
-
-    do v.iter().fold(0.0) |x, y| { x + *y } - 10.0
-    //~^ ERROR mismatched types: expected `()`
-}
-
-fn main() {
-    let x = compute1();
-    info!("{:?}", x);
-    assert_eq!(x, -4f64);
-}
index 55ef70ad8520fe37eb6eeae99cd9792428b3f35f..b50a657eae79a93e2dd3d86c32de888055599f9c 100644 (file)
@@ -32,9 +32,9 @@ fn b() {
 
     let mut p = ~[1];
 
-    do borrow(p) {
+    borrow(p, || {
         p[0] = 5; //~ ERROR cannot assign to
-    }
+    });
 }
 
 fn c() {
index f834642eb3cc5874b7c170f35aef19dfb06e5b0c..5c7e328969bb5cbcd1dea2afe2253fb5cde3b31d 100644 (file)
@@ -18,7 +18,7 @@ pub fn with(&self, blk: |x: &Either<(uint,uint),extern fn()>|) {
 
 fn main() {
     let mut x = X(Right(main));
-    do (&mut x).with |opt| {
+    (&mut x).with(|opt| {
         match opt {
             &Right(ref f) => {
                 x = X(Left((0,0))); //~ ERROR cannot assign to `x`
@@ -26,5 +26,5 @@ fn main() {
             },
             _ => fail!()
         }
-    }
+    })
 }
index 358305aee08fbfa65a12621aa0e3f5ea26ee0d4f..94ed47b01e1ee65f7bd06256e2dd083cfd0fdfc1 100644 (file)
@@ -23,9 +23,9 @@ pub fn foo(&mut self, fun: |&int|) {
 }
 
 fn bar(f: &mut Foo) {
-  do f.foo |a| {
+  f.foo(|a| {
     f.n.insert(*a); //~ ERROR cannot borrow
-  }
+  })
 }
 
 fn main() {
index 14994c0245da99b1bbc9742c58898503250c5e92..c25f39a9d4329ec77f8c03f29627dfe6d5b4081a 100644 (file)
@@ -39,9 +39,9 @@ fn block_overarching_alias_mut() {
 
     let mut v = ~3;
     let mut x = &mut v;
-    do 3.times {
+    3.times(|| {
         borrow(v); //~ ERROR cannot borrow
-    }
+    });
     *x = ~5;
 }
 
index 417330b6864a7658480420416076bddda9b6a3ea..a54476abb26d691c55f5f533f0f878a9f786df6b 100644 (file)
@@ -14,11 +14,11 @@ fn borrow(v: &int, f: |x: &int|) {
 
 fn box_imm() {
     let mut v = ~3;
-    do borrow(v) |w| {
+    borrow(v, |w| {
         v = ~4; //~ ERROR cannot assign to `v` because it is borrowed
         assert_eq!(*v, 3);
         assert_eq!(*w, 4);
-    }
+    })
 }
 
 fn main() {
index e04eaa4d7af6ad256dcbd704351e19b734f37a9f..c2ed3378bf97ced26ea100144227e4b589871350 100644 (file)
@@ -30,9 +30,9 @@ fn a() {
     p.impurem();
 
     // But in this case we do not honor the loan:
-    do p.blockm {
+    p.blockm(|| {
         p.x = 10; //~ ERROR cannot assign
-    }
+    })
 }
 
 fn b() {
@@ -52,9 +52,9 @@ fn c() {
     q.impurem();
 
     // ...but we still detect errors statically when we can.
-    do q.blockm {
+    q.blockm(|| {
         q.x = 10; //~ ERROR cannot assign
-    }
+    })
 }
 
 fn main() {
index 0617d1991911461483e77a37521974912123ae91..6527ddfa2ecf67999fe385f3dc60dd8098a48622 100644 (file)
@@ -18,15 +18,14 @@ fn takes_imm_elt(_v: &int, f: ||) {
 
 fn has_mut_vec_and_does_not_try_to_change_it() {
     let mut v = ~[1, 2, 3];
-    do takes_imm_elt(&v[0]) {
-    }
+    takes_imm_elt(&v[0], || {})
 }
 
 fn has_mut_vec_but_tries_to_change_it() {
     let mut v = ~[1, 2, 3];
-    do takes_imm_elt(&v[0]) {
+    takes_imm_elt(&v[0], || {
         v[1] = 4; //~ ERROR cannot assign
-    }
+    })
 }
 
 fn main() {
index 06281a5e2884b1de0855ca2cd64f492865ff0da7..4633ca662897f004c503927570b73a982eba8587 100644 (file)
@@ -23,10 +23,10 @@ fn main() {
     while cond() {
         if cond() { break }
         if cond() { continue }
-        do foo {
+        foo(|| {
             if cond() { break } //~ ERROR: `break` inside of a closure
             if cond() { continue } //~ ERROR: `continue` inside of a closure
-        }
+        })
     }
 
     let rs: Foo = Foo{t: pth};
index 8fb64ee6dacec413e40ca847578dfe3c90e066b3..1c6d65ba541671d1bcee8a969424f28dd15e7edd 100644 (file)
@@ -12,9 +12,9 @@ fn bar(blk: ||:'static) {
 }
 
 fn foo(x: &()) {
-    do bar {
+    bar(|| {
         let _ = x; //~ ERROR does not fulfill `'static`
-    }
+    })
 }
 
 fn main() {
index ffb779da354f8c590f1d5c30ca62cbede95a2aad..309abe218f6f1bc55712130446824d7fcf6e7ef5 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f(f: |int| -> bool) -> bool { f(10i) }
+fn f(f: proc(int) -> bool) -> bool { f(10i) }
 
 fn main() {
     assert!(do f() |i| { i == 10i } == 10i);
index d73f0e6ab1e68f2f52624194cd57fad91b75e3fb..798c1194af8723cf61ad7598868c7d452f5b4b05 100644 (file)
@@ -35,9 +35,9 @@ fn what(mut foo: int) {} //~ ERROR: variable does not need to be mutable
     let mut a = ~[];
     a.push(3);
     let mut a = ~[];
-    do callback {
+    callback(|| {
         a.push(3);
-    }
+    });
     let (mut a, b) = (1, 2);
     a = 34;
 
index 253459be85a82df3279f82a37d50a868c18dd4a1..f28322d3bf76321b4fae5dd14637043a77d65b7f 100644 (file)
@@ -24,7 +24,7 @@ unsafe fn unsf() {}
 fn bad1() { unsafe {} }                  //~ ERROR: unnecessary `unsafe` block
 fn bad2() { unsafe { bad1() } }          //~ ERROR: unnecessary `unsafe` block
 unsafe fn bad3() { unsafe {} }           //~ ERROR: unnecessary `unsafe` block
-fn bad4() { unsafe { do callback {} } }  //~ ERROR: unnecessary `unsafe` block
+fn bad4() { unsafe { callback(||{}) } }  //~ ERROR: unnecessary `unsafe` block
 unsafe fn bad5() { unsafe { unsf() } }   //~ ERROR: unnecessary `unsafe` block
 fn bad6() {
     unsafe {                             // don't put the warning here
@@ -50,9 +50,9 @@ fn good2() {
     unsafe {
         unsafe fn what() -> ~[~str] { fail!() }
 
-        do callback {
+        callback(|| {
             what();
-        }
+        });
     }
 }
 
index 355305b6c630c6a3f5901b9c5edf8bf4a3483ffb..690c778183c60b1cc68e6d2f61689a8b1d89c500 100644 (file)
@@ -15,12 +15,12 @@ fn f(s: &S, g: |&S|) {
 fn main() {
     let s = S { x: ~Bar(~42) };
     loop {
-        do f(&s) |hellothere| {
+        f(&s, |hellothere| {
             match hellothere.x {
                 ~Foo(_) => {}
                 ~Bar(x) => println(x.to_str()), //~ ERROR cannot move out
                 ~Baz => {}
             }
-        }
+        })
     }
 }
index bf7383f9c72b8c40aed227b6ea9a3c28f14d3c7a..260d5a5dd4475c01aa7c4d2167763aa996177a06 100644 (file)
@@ -21,7 +21,7 @@ struct R<'self> {
 
 fn innocent_looking_victim() {
     let mut x = Some(~"hello");
-    do conspirator |f, writer| {
+    conspirator(|f, writer| {
         if writer {
             x = None;
         } else {
@@ -33,7 +33,7 @@ fn innocent_looking_victim() {
                 None => fail!("oops"),
             }
         }
-    }
+    })
 }
 
 fn conspirator(f: |&R, bool|) {
index bac17dec8ecbcbdefeecca1c03e24181dbc7d4cc..476b890efcd6b8618aef8963dfd8dcf544be7952 100644 (file)
@@ -18,8 +18,8 @@ fn test_mutex_arc_nested() {
     let arc2 = ~MutexArc::new(*arc);
 
     do task::spawn || {
-        do (*arc2).access |mutex| { //~ ERROR instantiating a type parameter with an incompatible type
-        }
+        (*arc2).access(|mutex| { //~ ERROR instantiating a type parameter with an incompatible type
+        })
     };
 }
 
index 9cc69228c56f5e83a303f6e5b5c1c08af60260d6..98362baef2c34a6e4a1726bc0ccb86616c6fb616 100644 (file)
@@ -23,8 +23,8 @@ fn foo(blk: once ||) {
 
 fn main() {
     let x = arc::Arc::new(true);
-    do foo {
+    foo(|| {
         assert!(*x.get());
         util::ignore(x);
-    }
+    })
 }
index 4927acde48d8740bbaf4a28dc0d241370f16434b..60d1b9c1c34fd0ea6660fd6350ab055fc96e8497 100644 (file)
@@ -22,8 +22,8 @@ fn foo(blk: ||) {
 
 fn main() {
     let x = arc::Arc::new(true);
-    do foo {
+    foo(|| {
         assert!(*x.get());
         util::ignore(x); //~ ERROR cannot move out of captured outer variable
-    }
+    })
 }
index 7e5abe8e2f7e44f3382a06425d2a6cd77dd5549d..493b9c466bd3ba2b00f4d2fe33e93db80c0703d9 100644 (file)
@@ -12,7 +12,7 @@ fn wants_static_fn(_x: 'static ||) {}
 
 fn main() {
     let i = 3;
-    do wants_static_fn { //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
+    wants_static_fn(|| { //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
         info!("i={}", i);
-    }
+    })
 }
index 8002f8bcc50d2db1ae4a12a7a55b32acf2c2872e..bb7c487005faa961cc981ef6666f50beac05c01b 100644 (file)
@@ -15,7 +15,7 @@ fn with<T>(f: |x: &int| -> T) -> T {
 }
 
 fn manip<'a>(x: &'a int) -> int {
-    let z = do with |y| { select(x, y) };
+    let z = with(|y| { select(x, y) });
     //~^ ERROR cannot infer an appropriate lifetime
     *z
 }
index 928953de39088f8fb4eee4c0112bc228d44d4674..4df08b28eb896e125db87b54608cead6cee92bef 100644 (file)
@@ -15,8 +15,8 @@
 fn main() {
     let m = ~sync::Mutex::new();
     let mut cond = None;
-    do m.lock_cond |c| {
+    m.lock_cond(|c| {
         cond = Some(c);
-    }
+    });
     cond.unwrap().signal();
 }
index 03779b3ffe3d1e90bae38b2201f34e4c8dc2a40c..d59eaf62abf84fa3196e06fe519c176454cd7f15 100644 (file)
@@ -14,8 +14,8 @@
 fn main() {
     let x = ~sync::RWLock::new();
     let mut y = None;
-    do x.write_cond |cond| {
+    x.write_cond(|cond| {
         y = Some(cond);
-    }
+    });
     y.unwrap().wait();
 }
index 6ce3869bab224ad00ea3d2d3ffcfb8b94a3c833a..e71dfc588161fbcf7404c8d3062f85f7c50ba112 100644 (file)
@@ -14,9 +14,9 @@
 fn main() {
     let x = ~sync::RWLock::new();
     let mut y = None;
-    do x.write_downgrade |write_mode| {
+    x.write_downgrade(|write_mode| {
         y = Some(x.downgrade(write_mode));
-    }
+    })
     // Adding this line causes a method unification failure instead
     // do (&option::unwrap(y)).read { }
 }
index fab16894a655a9ffd3f9ada73ef694c7d6f457a6..cbe5181d46f24762d61588083b48e12d90887db0 100644 (file)
 fn main() {
     let x = ~sync::RWLock::new();
     let mut y = None;
-    do x.write_downgrade |write_mode| {
-        do (&write_mode).write_cond |cond| {
+    x.write_downgrade(|write_mode| {
+        (&write_mode).write_cond(|cond| {
             y = Some(cond);
-        }
-    }
+        })
+    });
     y.unwrap().wait();
 }
index 7210fbf37b424a582cd2f06ebbc70d13d18d89fa..af0149182aeba1b8b5a81fe8fe973ce380773a3c 100644 (file)
@@ -14,9 +14,9 @@
 fn main() {
     let x = ~sync::RWLock::new();
     let mut y = None;
-    do x.write_downgrade |write_mode| {
+    x.write_downgrade(|write_mode| {
         y = Some(write_mode);
-    }
+    });
     // Adding this line causes a method unification failure instead
     // do (&option::unwrap(y)).write { }
 }
index 36f05a0a73cd1777f9272130633cec9bb4dc0679..a476a9727b3609414fe7e8b063075151c9b424eb 100644 (file)
@@ -21,7 +21,7 @@ fn main() {
     // huge).
 
     let x = ~[1u,2u,3u];
-    do x.as_imm_buf |p, _len| {
+    x.as_imm_buf(|p, _len| {
         let base = p as uint;
         let idx = base / mem::size_of::<uint>();
         error!("ov1 base = 0x{:x}", base);
@@ -32,5 +32,5 @@ fn main() {
 
         // This should fail.
         error!("ov1 0x{:x}",  x[idx]);
-    }
+    })
 }
index 1da5023dce023f92432eb46515eab05c9c9bdab5..c5142897b1d9ca8ad55a90e333694140d704f431 100644 (file)
@@ -30,14 +30,17 @@ fn iterate(&self, f: |x: &A| -> bool) -> bool {
 
 fn length<A, T: iterable<A>>(x: T) -> uint {
     let mut len = 0;
-    do x.iterate() |_y| { len += 1; true };
+    x.iterate(|_y| {
+        len += 1;
+        true
+    });
     return len;
 }
 
 pub fn main() {
     let x = ~[0,1,2,3];
     // Call a method
-    do x.iterate() |y| { assert!(x[*y] == *y); true };
+    x.iterate(|y| { assert!(x[*y] == *y); true });
     // Call a parameterized function
     assert_eq!(length(x.clone()), x.len());
     // Call a parameterized function, with type arguments that require
@@ -47,7 +50,7 @@ pub fn main() {
     // Now try it with a type that *needs* to be borrowed
     let z = [0,1,2,3];
     // Call a method
-    do z.iterate() |y| { assert!(z[*y] == *y); true };
+    z.iterate(|y| { assert!(z[*y] == *y); true });
     // Call a parameterized function
     assert_eq!(length::<int, &[int]>(z), z.len());
 }
index dcdab0edc3aaea1fb58dc323809b6532aad6e9f2..dca0efd94fab53931a406bcfc468c7a119346eda 100644 (file)
@@ -20,5 +20,5 @@ fn bitv_test() {
 }
 
 pub fn main() {
-    do 10000.times || {bitv_test()};
+    10000.times(|| bitv_test());
 }
index e65116f214743cd9798eb6ec1a60d297a7f80013..f2149e23210ccb256cbf5af0a46eddbbbf83ff1c 100644 (file)
@@ -8,11 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-pub fn main() {
-    let v = ~[-1.0, 0.0, 1.0, 2.0, 3.0];
+fn add(x: proc(f64) -> f64) -> f64 {
+    x(10.0)
+}
 
+pub fn main() {
     // Trailing expressions don't require parentheses:
-    let y = do v.iter().fold(0.0) |x, y| { x + *y } + 10.0;
+    let y = do add |x| { x + 10.0 } + 10.0;
 
-    assert_eq!(y, 15.0);
+    assert_eq!(y, 30.0);
 }
index 0d82e294caf22bd035c631ae36d28f82085b840d..2cdf0a1ffe1f1e0dcc05ff7861d8552d1a73af2f 100644 (file)
@@ -8,9 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+fn f(_: proc()) -> proc(proc() -> uint) {
+    proc(_: proc() -> uint) {}
+}
+
 pub fn main() {
-    fn f(i: || -> uint) -> uint { i() }
-    let v = ~[-1.0, 0.0, 1.0, 2.0, 3.0];
-    let z = do do v.iter().fold(f) |x, _y| { x } { 22u };
-    assert_eq!(z, 22u);
+    do do f {} { 20 };
 }
index 1bb16f6041eec6b267f5aee866e185d3dd861390..544367bdfa9d5c9b9333750f63fe10ea45c8709e 100644 (file)
@@ -8,9 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+fn f(_: proc()) -> proc(uint) -> uint {
+    proc(x: uint) { x }
+}
+
 pub fn main() {
-    fn f(i: uint) -> uint { i }
-    let v = ~[-1.0, 0.0, 1.0, 2.0, 3.0];
-    let z = do v.iter().fold(f) |x, _y| { x } (22u);
+    let z = do f {} (22u);
     assert_eq!(z, 22u);
 }
index fcd6a8d7c85e5fd1b6403e597a41d8fa7986b206..083217132de1125e70b21a2d2ab2baeac2b6ecb5 100644 (file)
@@ -8,28 +8,31 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn w_semi(v: ~[int]) -> int {
+fn f(_: proc(int, int) -> int) -> int {
+    10
+}
+
+fn w_semi() {
     // the semicolon causes compiler not to
     // complain about the ignored return value:
-    do v.iter().fold(0) |x,y| { x+*y };
-    -10
+    do f |x, y| { x+y };
 }
 
-fn w_paren1(v: ~[int]) -> int {
-    (do v.iter().fold(0) |x,y| { x+*y }) - 10
+fn w_paren1() -> int {
+    (do f |x, y| { x+y }) - 10
 }
 
-fn w_paren2(v: ~[int]) -> int {
-    (do v.iter().fold(0) |x,y| { x+*y} - 10)
+fn w_paren2() -> int {
+    (do f |x, y| { x+y } - 10)
 }
 
-fn w_ret(v: ~[int]) -> int {
-    return do v.iter().fold(0) |x,y| { x+*y } - 10;
+fn w_ret() -> int {
+    return do f |x, y| { x+y } - 10;
 }
 
 pub fn main() {
-    assert_eq!(w_semi(~[0, 1, 2, 3]), -10);
-    assert_eq!(w_paren1(~[0, 1, 2, 3]), -4);
-    assert_eq!(w_paren2(~[0, 1, 2, 3]), -4);
-    assert_eq!(w_ret(~[0, 1, 2, 3]), -4);
+    w_semi();
+    w_paren1();
+    w_paren2();
+    w_ret();
 }
index f05eb8e30b17cd2f5c8748976c96e4150a18a5e8..87a6cbd6fc2f33aa4de1b742b920e4ebf0e6e51d 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn call_any(f: || -> uint) -> uint {
+fn call_any(f: proc() -> uint) -> uint {
     return f();
 }
 
index 0608285db1e8ecb3f1052fe5fa31aa3ccf1a9fe1..afe7747457a8cc320a5ef7ebc8fe2c88b4e19883 100644 (file)
@@ -8,6 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+fn inty(fun: proc(int) -> int) -> int {
+    fun(100)
+}
+
+fn booly(fun: proc(bool) -> bool) -> bool {
+    fun(true)
+}
+
 // Check usage and precedence of block arguments in expressions:
 pub fn main() {
     let v = ~[-1.0f64, 0.0, 1.0, 2.0, 3.0];
@@ -18,28 +26,27 @@ pub fn main() {
     }
 
     // Usable at all:
-    let mut any_negative = do v.iter().any |e| { e.is_negative() };
-    assert!(any_negative);
+    do inty |x| { x };
 
     // Higher precedence than assignments:
-    any_negative = do v.iter().any |e| { e.is_negative() };
-    assert!(any_negative);
+    let result = do inty |e| { e };
+    assert_eq!(result, 100);
 
     // Higher precedence than unary operations:
-    let abs_v = do v.iter().map |e| { e.abs() }.collect::<~[f64]>();
-    assert!(do abs_v.iter().all |e| { e.is_positive() });
-    assert!(!do abs_v.iter().any |e| { e.is_negative() });
+    let stringy = do inty |e| { e }.to_str();
+    assert!(do booly |_| { true });
+    assert!(!do booly |_| { false });
 
     // Usable in funny statement-like forms:
-    if !do v.iter().any |e| { e.is_positive() } {
+    if !do booly |_| { true } {
         assert!(false);
     }
-    match do v.iter().all |e| { e.is_negative() } {
+    match do booly |_| { false } {
         true => { fail!("incorrect answer."); }
         false => { }
     }
     match 3 {
-      _ if do v.iter().any |e| { e.is_negative() } => {
+      _ if do booly |_| { true } => {
       }
       _ => {
         fail!("wrong answer.");
@@ -48,15 +55,19 @@ pub fn main() {
 
 
     // Lower precedence than binary operations:
-    let w = do v.iter().fold(0.0) |x, y| { x + *y } + 10.0;
-    let y = do v.iter().fold(0.0) |x, y| { x + *y } + 10.0;
-    let z = 10.0 + do v.iter().fold(0.0) |x, y| { x + *y };
+    let w = do inty |_| { 10 } + 10;
+    let y = do inty |_| { 10 } + 10;
+    let z = 10 + do inty |_| { 10 };
     assert_eq!(w, y);
     assert_eq!(y, z);
 
     // In the tail of a block
-    let w =
-        if true { do abs_v.iter().any |e| { e.is_positive() } }
-      else { false };
+    let w = if true {
+        do booly |_| {
+            true
+        }
+    } else {
+        false
+    };
     assert!(w);
 }
index dae10ed6d3917d634d71b308b8c9559d96e47e7c..f108d6cad6fbe9f0d08ff16c0870a213d6554bd3 100644 (file)
@@ -18,11 +18,11 @@ fn borrow(x: &int, f: |x: &int|) {
 }
 
 fn test1(x: @~int) {
-    do borrow(&*(*x).clone()) |p| {
+    borrow(&*(*x).clone(), |p| {
         let x_a = ptr::to_unsafe_ptr(&**x);
         assert!((x_a as uint) != borrow::to_uint(p));
         assert_eq!(unsafe{*x_a}, *p);
-    }
+    })
 }
 
 pub fn main() {
index 7b4c4247a353bc7dfaff0f9788ec47c3fe5f4b35..542a8251f712c6a8b0fa2f0d91d2c04802b93623 100644 (file)
@@ -30,10 +30,10 @@ pub fn main() {
     add_int(ints, 22);
     add_int(ints, 44);
 
-    do iter_ints(ints) |i| {
+    iter_ints(ints, |i| {
         error!("int = {}", *i);
         true
-    };
+    });
 
     error!("ints={:?}", ints);
 }
index bc8eeb5cd41784f036867660152008840ea40ddf..506d777013cd25bb57dee4d95bd706b689a886c2 100644 (file)
@@ -23,7 +23,7 @@ struct F { f: ~int }
 
 pub fn main() {
     let mut x = @F {f: ~3};
-    do borrow(x.f) |b_x| {
+    borrow(x.f, |b_x| {
         assert_eq!(*b_x, 3);
         assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
         x = @F {f: ~4};
@@ -32,5 +32,5 @@ pub fn main() {
                ptr::to_unsafe_ptr(&(*b_x)) as uint);
         assert_eq!(*b_x, 3);
         assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
-    }
+    })
 }
index 3ff30192efed897fa79a8974fdb6952d267fe28a..d7f7a8e47a2309619cb5176d3336da19c2372150 100644 (file)
@@ -23,7 +23,7 @@ struct F { f: ~int }
 
 pub fn main() {
     let mut x = ~@F{f: ~3};
-    do borrow(x.f) |b_x| {
+    borrow(x.f, |b_x| {
         assert_eq!(*b_x, 3);
         assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
         *x = @F{f: ~4};
@@ -32,5 +32,5 @@ pub fn main() {
                ptr::to_unsafe_ptr(&(*b_x)) as uint);
         assert_eq!(*b_x, 3);
         assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
-    }
+    })
 }
index e83621d6bb280b8fb395211864488e6410c2a71b..feea06cd69a189733608aab1980878b683c73876 100644 (file)
@@ -21,7 +21,7 @@ fn borrow(x: &int, f: |x: &int|) {
 
 pub fn main() {
     let mut x = @3;
-    do borrow(x) |b_x| {
+    borrow(x, |b_x| {
         assert_eq!(*b_x, 3);
         assert_eq!(ptr::to_unsafe_ptr(&(*x)), ptr::to_unsafe_ptr(&(*b_x)));
         x = @22;
@@ -30,5 +30,5 @@ pub fn main() {
                ptr::to_unsafe_ptr(&(*b_x)) as uint);
         assert_eq!(*b_x, 3);
         assert!(ptr::to_unsafe_ptr(&(*x)) != ptr::to_unsafe_ptr(&(*b_x)));
-    }
+    })
 }
index 6041fa977f5c37441eb35b3d095b48c728a313af..d131a529f1a360124a8c55f547c6f55de00328f9 100644 (file)
@@ -23,7 +23,7 @@ struct F { f: ~int }
 
 pub fn main() {
     let mut x = @F {f: ~3};
-    do borrow((*x).f) |b_x| {
+    borrow((*x).f, |b_x| {
         assert_eq!(*b_x, 3);
         assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
         x = @F {f: ~4};
@@ -32,5 +32,5 @@ pub fn main() {
                ptr::to_unsafe_ptr(&(*b_x)) as uint);
         assert_eq!(*b_x, 3);
         assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
-    }
+    })
 }
index b85d53991eafee8be38ec5abd33af57641766ecb..fd24b7cfe953a606e2502a5363559573cc366499 100644 (file)
@@ -18,11 +18,11 @@ pub fn main() {
     //let bt0 = sys::frame_address();
     //info!("%?", bt0);
 
-    do 3u.to(10u) |i| {
+    3u.to(10u, |i| {
         println!("{}", i);
 
         //let bt1 = sys::frame_address();
         //info!("%?", bt1);
         //assert!(bt0 == bt1);
-    }
+    })
 }
index ea313a48bb3ca70740885f5b2776df94c2e42e13..938956a18b61f95ba210932a734c0424f0ed52df 100644 (file)
@@ -16,8 +16,8 @@
 pub fn main() {
     //let bt0 = sys::rusti::frame_address(1u32);
     //info!("%?", bt0);
-    do cci_iter_lib::iter([1, 2, 3]) |i| {
+    cci_iter_lib::iter([1, 2, 3], |i| {
         println!("{}", *i);
         //assert!(bt0 == sys::rusti::frame_address(2u32));
-    }
+    })
 }
index 53c67e4802be1fa42762916251afaa96c34e1541..e2532667560ef1b9b02a7a7a25641df9ef6cac2e 100644 (file)
@@ -22,12 +22,12 @@ pub fn main() {
     // actually working.
     //let bt0 = sys::frame_address();
     //info!("%?", bt0);
-    do iter(~[1u, 2u, 3u]) |i| {
+    iter(~[1u, 2u, 3u], |i| {
         println!("{}", i);
 
         //let bt1 = sys::frame_address();
         //info!("%?", bt1);
 
         //assert!(bt0 != bt1);
-    }
+    })
 }
index a24d11a89b0566805b5ba90007599a9bcdd7267f..07d9fb95dcb55ddcf0fb929958d01776d483fe26 100644 (file)
@@ -40,9 +40,9 @@ fn test_destroy_twice() {
 
     let mut p = run::Process::new(PROG, [], run::ProcessOptions::new());
     p.destroy(); // this shouldnt crash...
-    do io::io_error::cond.trap(|_| {}).inside {
+    io::io_error::cond.trap(|_| {}).inside(|| {
         p.destroy(); // ...and nor should this (and nor should the destructor)
-    }
+    })
 }
 
 fn test_destroy_actually_kills(force: bool) {
index 5812800259b860bc8c5d9c30a678b6d0131f2dce..5f3cebed66777011786d2186e46bfd00ee978d32 100644 (file)
@@ -71,9 +71,9 @@ pub fn main() {
     roundtrip::<C>();
     roundtrip::<D>();
 
-    do 20.times {
+    20.times(|| {
         roundtrip::<E>();
         roundtrip::<F>();
         roundtrip::<G<int>>();
-    }
+    })
 }
index 39a86c0ae3fd629c38d4a66b7b6a88ab8948cb42..9a28ed7008827d0509e66081013509002eac5b15 100644 (file)
@@ -34,10 +34,10 @@ enum D {
 
 fn main() {
     // check there's no segfaults
-    do 20.times {
+    20.times(|| {
         rand::random::<A>();
         rand::random::<B>();
         rand::random::<C>();
         rand::random::<D>();
-    }
+    })
 }
index 0078294eb89d58e92906bf1f979199f3d0d424f9..56ba2ffddbb4bd9959c53101b1a7bad2399bd0c4 100644 (file)
@@ -11,7 +11,7 @@
 // no-reformat
 // Testing various forms of `do` with empty arg lists
 
-fn f(_f: || -> bool) -> bool {
+fn f(_f: proc() -> bool) -> bool {
     true
 }
 
index eb6a4a3db542150e56007ced3bc7b8fba3ace8b9..0df5c82ab077f33aa81f3bff4466cfdd6a7bde45 100644 (file)
@@ -10,9 +10,9 @@
 
 // Testing that we can drop the || in do exprs
 
-fn f(_f: || -> bool) -> bool { true }
+fn f(_f: proc() -> bool) -> bool { true }
 
-fn d(_f: ||) { }
+fn d(_f: proc()) { }
 
 pub fn main() {
     do d { }
diff --git a/src/test/run-pass/do-pure.rs b/src/test/run-pass/do-pure.rs
deleted file mode 100644 (file)
index 85bb84c..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn f(_f: ||) {
-}
-
-fn g() {
-    // `f || { }` is considered pure, so `do f { }` should be too
-    do f { }
-}
-
-pub fn main() {
-}
diff --git a/src/test/run-pass/do-stack.rs b/src/test/run-pass/do-stack.rs
deleted file mode 100644 (file)
index fddf3b1..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn f(f: |int|) { f(10) }
-
-pub fn main() {
-    do f() |i| { assert!(i == 10) }
-}
index fddf3b15c78da4ec5bf8af7a1bc904b718a659f0..bdbad74b32095ce721a3ecbb6b516a00c175b56d 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f(f: |int|) { f(10) }
+fn f(f: proc(int)) { f(10) }
 
 pub fn main() {
     do f() |i| { assert!(i == 10) }
index 1bfb10a9f7568771ca224947e9f2addadc166e05..f509f7b454d35afeba0d2bb30dd63fc808af84e3 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f(f: |int| -> int) -> int { f(10) }
+fn f(f: proc(int) -> int) -> int { f(10) }
 
 pub fn main() {
     assert_eq!(do f() |i| { i }, 10);
index c08842a45ce7743151e8f903673bcd76e0445722..cdba14f1deda4a182c0d306a0826b60a10bfff99 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f(f: |int| -> int) -> int { f(10) }
+fn f(f: proc(int) -> int) -> int { f(10) }
 
 pub fn main() {
     assert_eq!(do f |i| { i }, 10);
index 21706848c81cf8328a5d9495bf123a510f5fd928..6ef196ccd41fc2bd0142ffb5e9cddbf00a3eb8ed 100644 (file)
@@ -40,9 +40,9 @@ fn count(n: uint) -> uint {
 }
 
 pub fn main() {
-    do 100u.times {
+    100u.times(|| {
         do task::spawn {
             assert_eq!(count(5u), 16u);
         };
-    }
+    })
 }
index 45841e22896d77da1ef7859e34fbdd25f2945210..1d2f52d8c2eb606d9eb66fef686f469e5e6090d7 100644 (file)
@@ -37,11 +37,11 @@ fn count(n: uint) -> uint {
 }
 
 pub fn main() {
-    do 10u.times {
+    10u.times(|| {
         do task::spawn {
             let result = count(5u);
             info!("result = {}", result);
             assert_eq!(result, 16u);
         };
-    }
+    })
 }
index 1f63bd68d34f7b1fe8dc4d3c2884de16d1be0c2b..9646c6b6eb79d0418a8e4d8ee3f95c22d7bdab3e 100644 (file)
@@ -16,9 +16,9 @@
 pub fn main() {
     let mut a: ~[int] = ~[-1, -1, -1, -1];
     let mut p: int = 0;
-    do two |i| {
-        do two |j| { a[p] = 10 * i + j; p += 1; }
-    }
+    two(|i| {
+        two(|j| { a[p] = 10 * i + j; p += 1; })
+    });
     assert_eq!(a[0], 0);
     assert_eq!(a[1], 1);
     assert_eq!(a[2], 10);
index 91468841e092355acd98797433c70de615cb0fbc..7011088fa5d44f69582e55040a02cef3eb7b7174 100644 (file)
@@ -19,13 +19,13 @@ fn pairs(it: |(int, int)|) {
 pub fn main() {
     let mut i: int = 10;
     let mut j: int = 0;
-    do pairs() |p| {
+    pairs(|p| {
         let (_0, _1) = p;
         info!("{}", _0);
         info!("{}", _1);
         assert_eq!(_0 + 10, i);
         i += 1;
         j = _1;
-    };
+    });
     assert_eq!(j, 45);
 }
index 34b131893269a3d081a95f195870d0d123f46be2..81e9ac1b80876b97c39768d84d9d5708c0eb1958 100644 (file)
@@ -13,7 +13,7 @@
 
 pub fn main() {
     let mut sum: int = 0;
-    do first_ten |i| { info!("main"); info!("{}", i); sum = sum + i; }
+    first_ten(|i| { info!("main"); info!("{}", i); sum = sum + i; });
     info!("sum");
     info!("{}", sum);
     assert_eq!(sum, 45);
index d05680651f7dde5663daf7f2e8a3ce896893cc5e..aeba5c0ec97e139143c37aebed9d1d95e301fcd0 100644 (file)
@@ -22,11 +22,11 @@ mod libc {
 
 fn strlen(str: ~str) -> uint {
     // C string is terminated with a zero
-    do str.with_c_str |buf| {
+    str.with_c_str(|buf| {
         unsafe {
             libc::my_strlen(buf) as uint
         }
-    }
+    })
 }
 
 pub fn main() {
diff --git a/src/test/run-pass/issue-1458.rs b/src/test/run-pass/issue-1458.rs
deleted file mode 100644 (file)
index ce5c932..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn plus_one(f: || -> int) -> int {
-  return f() + 1;
-}
-
-fn ret_plus_one() -> extern fn(|| -> int) -> int {
-  return plus_one;
-}
-
-pub fn main() {
-    let z = do (ret_plus_one()) || { 2 };
-    assert_eq!(z, 3);
-}
index 110bceced82a1085772eedae9e5ae7b4c0a31c5d..d8c12d8511c32d65ec20a56eda6ac2815709463e 100644 (file)
@@ -19,9 +19,7 @@ fn drop(&mut self) {}
 
 impl socket {
     pub fn set_identity(&self)  {
-        do closure {
-            setsockopt_bytes(self.sock.clone())
-        }
+        closure(|| setsockopt_bytes(self.sock.clone()))
     }
 }
 
index 2d590f25af1d1e613a0ad7acfb3d4e5edc976371..f3c74cd929596d9bdd0e0faeb3c50bb54425ad36 100644 (file)
@@ -59,9 +59,9 @@ fn add_interfaces(store: int, managed_ip: ~str, device: HashMap<~str, extra::jso
     {
         &extra::json::List(ref interfaces) =>
         {
-          do interfaces.map |interface| {
+          interfaces.map(|interface| {
                 add_interface(store, managed_ip.clone(), (*interface).clone())
-          }
+          })
         }
         _ =>
         {
index 5e89cb2dd367623514551938856a6aec0a8e6749..3d8300010d9d5e586f73f774bf6a8f9b480c10f0 100644 (file)
@@ -1,8 +1,6 @@
 pub fn main() {
     let mut x = 0;
-    do 4096.times {
-        x += 1;
-    }
+    4096.times(|| x += 1);
     assert_eq!(x, 4096);
     println!("x = {}", x);
 }
index 50d6a3ae6b8db4b209cd3328ebe6325a12b9f669..4bb89e2cf1711b726ecf5a018d8b27478b2fa5b0 100644 (file)
@@ -64,11 +64,9 @@ fn drop(&mut self) {}
 fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt {
     // Use an anonymous function to build a vector of vectors containing
     // blank characters for each position in our canvas.
-    let lines = do vec::build(Some(height)) |push| {
-            do height.times {
-                push(vec::from_elem(width, '.'));
-            }
-        };
+    let lines = vec::build(Some(height), |push| {
+        height.times(|| push(vec::from_elem(width, '.')))
+    });
 
     // Rust code often returns values by omitting the trailing semi-colon
     // instead of using an explicit return statement.
@@ -101,7 +99,7 @@ fn add_pt(&mut self, x: int, y: int) {
 impl ToStr for AsciiArt {
     fn to_str(&self) -> ~str {
         // Convert each line into a string.
-        let lines = do self.lines.map |line| {str::from_chars(*line)};
+        let lines = self.lines.map(|line| str::from_chars(*line));
 
         // Concatenate the lines together using a new-line.
         lines.connect("\n")
index ab38d7650dad34e16aceabd9e95c18e4b483e285..a6041c79eac1bc3ab92b67e1ead25bb33c26146d 100644 (file)
@@ -1,8 +1,6 @@
 pub fn main() {
     let mut count = 0;
-    do 999_999.times() {
-        count += 1;
-    }
+    999_999.times(|| count += 1);
     assert_eq!(count, 999_999);
     println!("{}", count);
 }
index 3f1dc2f6986f60c5c2af348072d35e8be9b3b6a7..4a0236b2da8d0dea252e45f18c63df0f40f3e235 100644 (file)
@@ -14,9 +14,7 @@ trait Fooable {
 
 impl Fooable for uint {
     fn yes(self) {
-        do self.times {
-            println("yes");
-        }
+        self.times(|| println("yes"));
     }
 }
 
index f7d0316880a4d3d196c38b59c560d5838c3032a1..989a8e5f9c2c493ff00b54065b2cd6edeebb6520 100644 (file)
@@ -15,6 +15,6 @@ fn swap(f: |~[int]| -> ~[int]) -> ~[int] {
 
 pub fn main() {
     let v = swap(|mut x| { x.push(4); x });
-    let w = do swap |mut x| { x.push(4); x };
+    let w = swap(|mut x| { x.push(4); x });
     assert_eq!(v, w);
 }
index e1d2f0e1c4847365aecd9bbdefb05188bde7fe3f..de4da6e3b06d7aca0a707cf3447f3508ca2374fd 100644 (file)
@@ -15,7 +15,7 @@ pub fn main() {
         let x = Some(unstable::sync::Exclusive::new(true));
         match x {
             Some(ref z) if z.with(|b| *b) => {
-                do z.with |b| { assert!(*b); }
+                z.with(|b| assert!(*b));
             },
             _ => fail!()
         }
index 1835514c0d1fe8766e9de233f1b7997a80d50f23..043136fdad9956a3028a890b8672a1dd048ef60b 100644 (file)
@@ -17,6 +17,6 @@ fn g(_g: ||) { }
 pub fn main() {
     assert_eq!(f(10, |a| a), 10);
     g(||());
-    assert_eq!(do f(10) |a| { a }, 10);
-    do g() { }
+    assert_eq!(f(10, |a| a), 10);
+    g(||{});
 }
index 645948f1426253053afa2cb964c7dc9db19941bb..9995edf5998e41e2304b6186dfd93316d639854e 100644 (file)
@@ -23,8 +23,8 @@ fn foo(blk: once ||) {
 
 fn main() {
     let x = arc::Arc::new(true);
-    do foo {
+    foo(|| {
         assert!(*x.get());
         util::ignore(x);
-    }
+    })
 }
index 96081d30275fb32be75273c5d3bffa8cba895aea..6e5aa1aaf8b69fdcb204f30142920fb4b1f7d439 100644 (file)
@@ -37,16 +37,12 @@ impl<V:TyVisitor + movable_ptr> ptr_visit_adaptor<V> {
 
     #[inline(always)]
     pub fn bump(&mut self, sz: uint) {
-      do self.inner.move_ptr() |p| {
-            ((p as uint) + sz) as *c_void
-      };
+      self.inner.move_ptr(|p| ((p as uint) + sz) as *c_void)
     }
 
     #[inline(always)]
     pub fn align(&mut self, a: uint) {
-      do self.inner.move_ptr() |p| {
-            align(p as uint, a) as *c_void
-      };
+      self.inner.move_ptr(|p| align(p as uint, a) as *c_void)
     }
 
     #[inline(always)]
@@ -501,15 +497,11 @@ impl TyVisitor for my_visitor {
     fn visit_bot(&mut self) -> bool { true }
     fn visit_nil(&mut self) -> bool { true }
     fn visit_bool(&mut self) -> bool {
-        do self.get::<bool>() |b| {
-            self.vals.push(b.to_str());
-        };
+        self.get::<bool>(|b| self.vals.push(b.to_str()));
         true
     }
     fn visit_int(&mut self) -> bool {
-        do self.get::<int>() |i| {
-            self.vals.push(i.to_str());
-        };
+        self.get::<int>(|i| self.vals.push(i.to_str()));
         true
     }
     fn visit_i8(&mut self) -> bool { true }
index 061f27972871fe334f6fa322808ff806dfb9a3ee..3350c3b65d09071f8bdc631f3ab140cb29ff80e6 100644 (file)
@@ -15,7 +15,7 @@ fn with<T>(f: |x: &int| -> T) -> T {
 }
 
 fn has_one<'a>(x: &'a int) -> int {
-    do with |y| { takes_two(x, y) }
+    with(|y| takes_two(x, y))
 }
 
 pub fn main() {
index d20f2bfef3bad4e420ea4dede3b5876f1eb7ac5f..fa4321451db91850be06938a39843b3b5f16f512 100644 (file)
@@ -31,20 +31,20 @@ fn rename_directory() {
         let test_file = &old_path.join("temp.txt");
 
         /* Write the temp input file */
-        let ostream = do test_file.with_c_str |fromp| {
-            do "w+b".with_c_str |modebuf| {
+        let ostream = test_file.with_c_str(|fromp| {
+            "w+b".with_c_str(|modebuf| {
                 libc::fopen(fromp, modebuf)
-            }
-        };
+            })
+        });
         assert!((ostream as uint != 0u));
         let s = ~"hello";
-        do "hello".with_c_str |buf| {
+        "hello".with_c_str(|buf| {
             let write_len = libc::fwrite(buf as *libc::c_void,
                                          1u as libc::size_t,
                                          (s.len() + 1u) as libc::size_t,
                                          ostream);
             assert_eq!(write_len, (s.len() + 1) as libc::size_t)
-        }
+        });
         assert_eq!(libc::fclose(ostream), (0u as libc::c_int));
 
         let new_path = tmpdir.join_many(["quux", "blat"]);
index 7b331c43568075c88f021bff1e3633b7f2c4f34c..1b7c3a1f52ecc9587408592b7edcb6d9944e361b 100644 (file)
@@ -93,9 +93,9 @@ fn check_legs(arc: arc::Arc<~[~Pet:Freeze+Send]>) {
 }
 fn check_names(arc: arc::Arc<~[~Pet:Freeze+Send]>) {
     for pet in arc.get().iter() {
-        do pet.name |name| {
+        pet.name(|name| {
             assert!(name[0] == 'a' as u8 && name[1] == 'l' as u8);
-        }
+        })
     }
 }
 fn check_pedigree(arc: arc::Arc<~[~Pet:Freeze+Send]>) {
index 042b5e96bbc08a1ab60077ecc859cf59ef287fbb..ff7ffb6dc6f00bc6e8214feb717e791b88523b59 100644 (file)
@@ -19,9 +19,9 @@ fn range_(lo: uint, hi: uint, it: |uint|) {
 }
 
 fn create_index<T>(_index: ~[S<T>], _hash_fn: extern fn(T) -> uint) {
-    do range_(0u, 256u) |_i| {
+    range_(0u, 256u, |_i| {
         let _bucket: ~[T] = ~[];
-    }
+    })
 }
 
 pub fn main() { }
index 06026d58f6005f124d1463af87bac6892b702ecc..9cb2f22d38e940a0da368fac248e73dfeccabe97 100644 (file)
@@ -26,16 +26,16 @@ pub fn main() {
 
     unsafe {
         // Call with just the named parameter
-        do "Hello World\n".with_c_str |c| {
+        "Hello World\n".with_c_str(|c| {
             check("Hello World\n", |s| sprintf(s, c));
-        }
+        });
 
         // Call with variable number of arguments
-        do "%d %f %c %s\n".with_c_str |c| {
-            do check("42 42.500000 a %d %f %c %s\n\n") |s| {
+        "%d %f %c %s\n".with_c_str(|c| {
+            check("42 42.500000 a %d %f %c %s\n\n", |s| {
                 sprintf(s, c, 42i, 42.5f64, 'a' as c_int, c);
-            }
-        }
+            })
+        });
 
         // Make a function pointer
         let x: extern "C" unsafe fn(*mut c_char, *c_char, ...) -> c_int = sprintf;
@@ -43,16 +43,16 @@ pub fn main() {
         // A function that takes a function pointer
         unsafe fn call(p: extern "C" unsafe fn(*mut c_char, *c_char, ...) -> c_int) {
             // Call with just the named parameter via fn pointer
-            do "Hello World\n".with_c_str |c| {
+            "Hello World\n".with_c_str(|c| {
                 check("Hello World\n", |s| p(s, c));
-            }
+            });
 
             // Call with variable number of arguments
-            do "%d %f %c %s\n".with_c_str |c| {
-                do check("42 42.500000 a %d %f %c %s\n\n") |s| {
+            "%d %f %c %s\n".with_c_str(|c| {
+                check("42 42.500000 a %d %f %c %s\n\n", |s| {
                     p(s, c, 42i, 42.5f64, 'a' as c_int, c);
-                }
-            }
+                })
+            });
         }
 
         // Pass sprintf directly
index 2db954d27c10b292d56d06f9210480c991e0415a..8142cafd89e9195b177d3beaee93fcd7b9f484c4 100644 (file)
@@ -20,7 +20,7 @@ pub fn main() {
         let x = Some(unstable::sync::Exclusive::new(true));
         match x {
             Some(ref z) if z.with(|b| *b) => {
-                do z.with |b| { assert!(*b); }
+                z.with(|b| assert!(*b));
             },
             _ => fail!()
         }
index 730ed18fbbd4540397cee745af724703daa56467..99df4b771c5ee5a24c9d9bf515648cd5f4eb2491 100644 (file)
@@ -33,8 +33,8 @@
 // there's no cross-crate-ness to test in that case.
 
 pub fn main() {
-    do oops::cond.trap(|_i| 12345).inside {
+    oops::cond.trap(|_i| 12345).inside(|| {
         let x = trouble();
         assert_eq!(x,12345);
-    }
+    })
 }
index 9666c037449f1a4a049a2a0ff79232af7a65b799..b3164f1f0aa5daba0333bd0ee11832616cc3fd74 100644 (file)
@@ -15,7 +15,5 @@
 use xcc = xc_conditions_2;
 
 pub fn main() {
-    do xcc::oops::cond.trap(|_| 1).inside {
-        xcc::oops::cond.raise(1);
-    }
+    xcc::oops::cond.trap(|_| 1).inside(|| xcc::oops::cond.raise(1));
 }
index 69ddb3701b09951ae95100a0834d54f3dcebee9f..e8eea00e4924947f862c6bfe3bf146cc5dc6c70c 100644 (file)
@@ -25,8 +25,8 @@ fn call(self) -> xcc::Color {
 }
 
 pub fn main() {
-    do xcc::oops::cond.trap(|_| xcc::Red).inside {
+    xcc::oops::cond.trap(|_| xcc::Red).inside(|| {
         let t = SThunk { x : 10 };
         assert_eq!(xcc::callback(t), xcc::Red)
-    }
+    })
 }
index 7eb4adfd0675755a456d106406787d5a42389a52..2ea8ab864e1624e369a949bb8a44fbab0e1a67dc 100644 (file)
@@ -21,8 +21,8 @@ pub fn main() {
 
     // Previously this fail'd because there were two addresses that were being
     // used when declaring constants.
-    do other::test::cond.trap(|_| {
-    }).inside {
+    other::test::cond.trap(|_| {
+    }).inside(|| {
         other::raise();
-    }
+    })
 }