From f571e46ddb696d15a8cc912309714ca74f23dcc4 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 21 Nov 2013 17:23:21 -0800 Subject: [PATCH] test: Remove non-procedure uses of `do` from compiletest, libstd tests, compile-fail tests, run-fail tests, and run-pass tests. --- src/compiletest/compiletest.rs | 4 +- src/compiletest/header.rs | 12 ++--- src/compiletest/procsrv.rs | 4 +- src/compiletest/runtest.rs | 4 +- src/libstd/at_vec.rs | 36 ++++++++++----- src/libstd/bool.rs | 12 ++--- src/libstd/cell.rs | 1 - src/libstd/char.rs | 4 +- src/libstd/condition.rs | 36 +++++++-------- src/libstd/io/buffered.rs | 12 ++--- src/libstd/io/extensions.rs | 32 ++++++------- src/libstd/io/mem.rs | 6 +-- src/libstd/io/net/tcp.rs | 44 +++++++++--------- src/libstd/io/net/udp.rs | 6 +-- src/libstd/io/net/unix.rs | 26 +++++------ src/libstd/io/option.rs | 24 +++++----- src/libstd/iter.rs | 4 +- src/libstd/local_data.rs | 40 ++++++++--------- src/libstd/num/strconv.rs | 8 ++-- src/libstd/num/uint.rs | 2 +- src/libstd/option.rs | 4 +- src/libstd/path/posix.rs | 45 +++++++++---------- src/libstd/path/windows.rs | 44 +++++++++--------- src/libstd/ptr.rs | 44 +++++++++--------- src/libstd/rand/distributions/gamma.rs | 8 ++-- src/libstd/rand/distributions/mod.rs | 8 ++-- src/libstd/rand/mod.rs | 20 ++++----- src/libstd/result.rs | 12 ++--- src/libstd/rt/comm.rs | 18 ++++---- src/libstd/rt/crate_map.rs | 12 ++--- src/libstd/rt/global_heap.rs | 8 ++-- src/libstd/rt/local.rs | 4 +- src/libstd/rt/local_heap.rs | 4 +- src/libstd/rt/sched.rs | 18 ++++---- src/libstd/rt/tube.rs | 16 +++---- src/libstd/select.rs | 6 +-- src/libstd/str.rs | 12 +++-- src/libstd/task/mod.rs | 32 ++++++------- src/libstd/unstable/finally.rs | 20 ++++----- src/libstd/util.rs | 16 +++---- src/libstd/vec.rs | 8 +++- src/test/auxiliary/xc_conditions_3.rs | 4 +- .../arc-rw-cond-shouldnt-escape.rs | 4 +- .../arc-rw-read-mode-shouldnt-escape.rs | 4 +- .../arc-rw-state-shouldnt-escape.rs | 4 +- .../arc-rw-write-mode-cond-shouldnt-escape.rs | 8 ++-- .../arc-rw-write-mode-shouldnt-escape.rs | 4 +- .../block-arg-as-stmt-with-value.rs | 22 --------- .../compile-fail/borrowck-assign-comp-idx.rs | 4 +- .../compile-fail/borrowck-autoref-3261.rs | 4 +- .../borrowck-insert-during-each.rs | 4 +- .../compile-fail/borrowck-lend-flow-loop.rs | 4 +- .../borrowck-loan-blocks-mut-uniq.rs | 4 +- src/test/compile-fail/borrowck-loan-rcvr.rs | 8 ++-- .../compile-fail/borrowck-loan-vec-content.rs | 7 ++- src/test/compile-fail/break-outside-loop.rs | 4 +- ...ure-bounds-static-cant-capture-borrowed.rs | 4 +- src/test/compile-fail/do2.rs | 2 +- .../compile-fail/lint-unused-mut-variables.rs | 4 +- src/test/compile-fail/lint-unused-unsafe.rs | 6 +-- .../moves-based-on-type-block-bad.rs | 4 +- ...ased-on-type-no-recursive-stack-closure.rs | 4 +- src/test/compile-fail/mutex-arc-nested.rs | 4 +- .../once-cant-call-twice-on-stack.rs | 4 +- ...once-cant-move-out-of-non-once-on-stack.rs | 4 +- src/test/compile-fail/regions-freevar.rs | 4 +- src/test/compile-fail/regions-infer-call-3.rs | 2 +- .../compile-fail/sync-cond-shouldnt-escape.rs | 4 +- .../sync-rwlock-cond-shouldnt-escape.rs | 4 +- .../sync-rwlock-read-mode-shouldnt-escape.rs | 4 +- ...-rwlock-write-mode-cond-shouldnt-escape.rs | 8 ++-- .../sync-rwlock-write-mode-shouldnt-escape.rs | 4 +- .../bug-2470-bounds-check-overflow.rs | 4 +- src/test/run-pass/assignability-trait.rs | 9 ++-- src/test/run-pass/bitv-perf-test.rs | 2 +- .../block-arg-can-be-followed-by-binop.rs | 16 ++++--- .../block-arg-can-be-followed-by-block-arg.rs | 11 ++--- .../block-arg-can-be-followed-by-call.rs | 8 ++-- src/test/run-pass/block-arg-in-parentheses.rs | 29 ++++++------ src/test/run-pass/block-arg-used-as-any.rs | 2 +- src/test/run-pass/block-arg.rs | 43 +++++++++++------- .../borrowck-borrow-from-expr-block.rs | 4 +- src/test/run-pass/borrowck-mut-uniq.rs | 4 +- .../borrowck-preserve-box-in-field.rs | 4 +- .../run-pass/borrowck-preserve-box-in-uniq.rs | 4 +- src/test/run-pass/borrowck-preserve-box.rs | 4 +- .../run-pass/borrowck-preserve-expl-deref.rs | 4 +- src/test/run-pass/cci_impl_exe.rs | 4 +- src/test/run-pass/cci_iter_exe.rs | 4 +- src/test/run-pass/cci_no_inline_exe.rs | 4 +- src/test/run-pass/core-run-destroy.rs | 4 +- .../run-pass/deriving-encodable-decodable.rs | 4 +- src/test/run-pass/deriving-rand.rs | 4 +- src/test/run-pass/do-empty-args.rs | 2 +- src/test/run-pass/do-no-args.rs | 4 +- src/test/run-pass/do-pure.rs | 20 --------- src/test/run-pass/do-stack.rs | 15 ------- src/test/run-pass/do1.rs | 2 +- src/test/run-pass/do2.rs | 2 +- src/test/run-pass/do3.rs | 2 +- src/test/run-pass/extern-stress.rs | 4 +- src/test/run-pass/extern-yield.rs | 4 +- src/test/run-pass/foreach-nested.rs | 6 +-- src/test/run-pass/foreach-put-structured.rs | 4 +- .../run-pass/foreach-simple-outer-slot.rs | 2 +- src/test/run-pass/foreign-fn-linkname.rs | 4 +- src/test/run-pass/issue-1458.rs | 22 --------- src/test/run-pass/issue-2487-a.rs | 4 +- src/test/run-pass/issue-2804.rs | 4 +- src/test/run-pass/issue-3211.rs | 4 +- src/test/run-pass/issue-3563-3.rs | 10 ++--- src/test/run-pass/issue-4401.rs | 4 +- .../issue-5321-immediates-with-bare-self.rs | 4 +- src/test/run-pass/issue-6153.rs | 2 +- .../match-ref-binding-in-guard-3256.rs | 2 +- src/test/run-pass/newlambdas.rs | 4 +- src/test/run-pass/once-move-out-on-stack.rs | 4 +- src/test/run-pass/reflect-visit-data.rs | 16 ++----- src/test/run-pass/regions-infer-call-2.rs | 2 +- src/test/run-pass/rename-directory.rs | 12 ++--- src/test/run-pass/trait-bounds-in-arc.rs | 4 +- src/test/run-pass/type-params-in-for-each.rs | 4 +- src/test/run-pass/variadic-ffi.rs | 24 +++++----- src/test/run-pass/writealias.rs | 2 +- src/test/run-pass/xc_conditions_client.rs | 4 +- src/test/run-pass/xc_conditions_client_2.rs | 4 +- src/test/run-pass/xc_conditions_client_4.rs | 4 +- src/test/run-pass/xcrate-static-addresses.rs | 6 +-- 128 files changed, 579 insertions(+), 641 deletions(-) delete mode 100644 src/test/compile-fail/block-arg-as-stmt-with-value.rs delete mode 100644 src/test/run-pass/do-pure.rs delete mode 100644 src/test/run-pass/do-stack.rs delete mode 100644 src/test/run-pass/issue-1458.rs diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 9c8fdafe9ad..65f733cf1de 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -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) } } diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index f722f873d5e..1966701dbde 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -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 @@ pub fn is_test_ignored(config: &config, testfile: &Path) -> bool { ~"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 { diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index e107c53018d..012d57da123 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -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")); } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 7104a506fcc..4c7b212304c 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -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() { diff --git a/src/libstd/at_vec.rs b/src/libstd/at_vec.rs index 4405d5be388..2b105a3fa7d 100644 --- a/src/libstd/at_vec.rs +++ b/src/libstd/at_vec.rs @@ -333,47 +333,57 @@ mod test { #[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 @@ mod test { #[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(); + }); } } diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs index ce0a6696596..29c304f9ac5 100644 --- a/src/libstd/bool.rs +++ b/src/libstd/bool.rs @@ -53,9 +53,9 @@ use num::FromPrimitive; /// # 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 @@ mod tests { #[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 @@ mod tests { #[test] fn test_bool_to_bit() { - do all_values |v| { + all_values(|v| { assert_eq!(v.to_bit::(), if v { 1u8 } else { 0u8 }); assert_eq!(v.to_bit::(), if v { 1u } else { 0u }); assert_eq!(v.to_bit::(), if v { 1i } else { 0i }); - } + }); } #[test] diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 634558b9b97..e49cf3e5303 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -82,7 +82,6 @@ pub struct RefCell { 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; diff --git a/src/libstd/char.rs b/src/libstd/char.rs index c5a4dd1631d..b372993e3e5 100644 --- a/src/libstd/char.rs +++ b/src/libstd/char.rs @@ -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 test_escape_default() { 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"); diff --git a/src/libstd/condition.rs b/src/libstd/condition.rs index 03994043dcf..80ff104e830 100644 --- a/src/libstd/condition.rs +++ b/src/libstd/condition.rs @@ -224,14 +224,14 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 test { #[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); } } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index d74acb5f59b..8c1897339cb 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -438,22 +438,22 @@ mod test { #[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); - } + }); } } diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 5eb2e72e96b..564e664027f 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -276,11 +276,11 @@ mod test { #[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 @@ mod test { 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 @@ mod test { #[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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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] diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index decdfb60bfb..b08f4af9a54 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -331,12 +331,12 @@ mod test { 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); } diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index ac099e67f79..aa7a64d2210 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -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 @@ mod test { 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 @@ mod test { }; 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { e.kind == ConnectionAborted, "unknown error: {:?}", e); stop = true; - }).inside { + }).inside(|| { stream.write(buf); - } + }); if stop { break } } } @@ -414,7 +414,7 @@ mod test { 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 @@ mod test { e.kind == ConnectionAborted, "unknown error: {:?}", e); stop = true; - }).inside { + }).inside(|| { stream.write(buf); - } + }); if stop { break } } } @@ -458,10 +458,10 @@ mod test { do spawntask { port.take().recv(); - do max.times { + max.times(|| { let mut stream = TcpStream::connect(addr); stream.write([99]); - } + }); } } } @@ -487,10 +487,10 @@ mod test { do spawntask { port.take().recv(); - do max.times { + max.times(|| { let mut stream = TcpStream::connect(addr); stream.write([99]); - } + }); } } } diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 38def44d9d0..f02fc1ae447 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -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); } } diff --git a/src/libstd/io/net/unix.rs b/src/libstd/io/net/unix.rs index eb86f0ef97f..809473d64c6 100644 --- a/src/libstd/io/net/unix.rs +++ b/src/libstd/io/net/unix.rs @@ -186,13 +186,13 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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]); - } + }) } } } diff --git a/src/libstd/io/option.rs b/src/libstd/io/option.rs index 5938252571f..61c5411f360 100644 --- a/src/libstd/io/option.rs +++ b/src/libstd/io/option.rs @@ -125,21 +125,21 @@ mod test { let mut writer: Option = 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 @@ mod test { 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); } } diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index b1958bde60d..75a7d5db132 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -2674,13 +2674,13 @@ mod tests { 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 - }; + }); } diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index 89907c7434c..335bbc8b1da 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -479,19 +479,19 @@ mod tests { 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 @@ mod tests { static key: Key = &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 @@ mod tests { fn test_nested_get_set1() { static key: Key = &Key; set(key, 4); - do get(key) |_| { + get(key, |_| { set(key, 4); - } + }) } #[test] @@ -543,9 +543,9 @@ mod tests { fn test_nested_get_mut2() { static key: Key = &Key; set(key, 4); - do get(key) |_| { + get(key, |_| { get_mut(key, |_| {}) - } + }) } #[test] @@ -553,9 +553,9 @@ mod tests { fn test_nested_get_mut3() { static key: Key = &Key; set(key, 4); - do get_mut(key) |_| { + get_mut(key, |_| { get(key, |_| {}) - } + }) } #[test] @@ -563,8 +563,8 @@ mod tests { fn test_nested_get_mut4() { static key: Key = &Key; set(key, 4); - do get_mut(key) |_| { + get_mut(key, |_| { get_mut(key, |_| {}) - } + }) } } diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 5d713f1a622..1028cef9dc6 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -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::().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()); - } + }) } } diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index 1cc0c191501..cf7047bd068 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -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)); } diff --git a/src/libstd/option.rs b/src/libstd/option.rs index c5a10c75640..715072653a7 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -612,14 +612,14 @@ mod tests { #[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); } diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index dcd08295331..ddfb43ed56f 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -523,35 +523,35 @@ mod tests { 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 @@ mod tests { ) 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 @@ mod tests { { 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 @@ mod tests { { 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); } ) diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 4e736458fd8..cc2af54fd10 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1248,35 +1248,35 @@ mod tests { 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 @@ mod tests { ) 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 @@ mod tests { 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); } diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index 9f60c3a32b2..9b9636af901 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -492,28 +492,28 @@ pub mod ptr_tests { 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 @@ pub mod ptr_tests { 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 @@ pub mod ptr_tests { 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); - } + }) } } diff --git a/src/libstd/rand/distributions/gamma.rs b/src/libstd/rand/distributions/gamma.rs index 7e8c193cb77..e0428742459 100644 --- a/src/libstd/rand/distributions/gamma.rs +++ b/src/libstd/rand/distributions/gamma.rs @@ -184,11 +184,11 @@ mod bench { 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::() as u64 * RAND_BENCH_N; } @@ -197,11 +197,11 @@ mod bench { 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::() as u64 * RAND_BENCH_N; } } diff --git a/src/libstd/rand/distributions/mod.rs b/src/libstd/rand/distributions/mod.rs index 247a7824a44..4778e81f951 100644 --- a/src/libstd/rand/distributions/mod.rs +++ b/src/libstd/rand/distributions/mod.rs @@ -571,11 +571,11 @@ mod bench { 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::() as u64 * RAND_BENCH_N; } #[bench] @@ -583,11 +583,11 @@ mod bench { 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::() as u64 * RAND_BENCH_N; } } diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 39b4cca2063..ae53ef8b7c0 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -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::(); } - } + }); bh.bytes = size_of::() 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::(); } - } + }); bh.bytes = size_of::() 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::(); } - } + }); bh.bytes = size_of::() 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::(); } - } + }); bh.bytes = size_of::() as u64 * RAND_BENCH_N; } @@ -944,8 +944,8 @@ mod bench { 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); - } + }) } } diff --git a/src/libstd/result.rs b/src/libstd/result.rs index 97daf8d7e60..ff425a8a73b 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -139,9 +139,9 @@ impl Result { /// /// Example: /// - /// let res = do read_file(file).map |buf| { + /// let res = read_file(file).map(|buf| { /// parse_bytes(buf) - /// } + /// }) #[inline] pub fn map(self, op: |T| -> U) -> Result { match self { @@ -462,11 +462,11 @@ mod tests { 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 @@ mod tests { 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); } diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs index e3e425f620b..52a6d67cb05 100644 --- a/src/libstd/rt/comm.rs +++ b/src/libstd/rt/comm.rs @@ -1013,7 +1013,7 @@ mod test { total.times(|| { port.recv(); - }) + }); } } @@ -1041,7 +1041,7 @@ mod test { total.times(|| { end_port.recv(); - }) + }); } } @@ -1071,7 +1071,7 @@ mod test { do spawntask_random { chan_clone.send(()); } - }) + }); } let end_chan_clone = end_chan.clone(); do spawntask_random { @@ -1082,7 +1082,7 @@ mod test { let recvd = port_clone.try_recv().is_some(); end_chan_clone.send(recvd); } - }) + }); } let mut recvd = 0; @@ -1112,12 +1112,12 @@ mod test { 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 @@ mod test { total.times(|| { end_port.recv(); - }) + }); } } diff --git a/src/libstd/rt/crate_map.rs b/src/libstd/rt/crate_map.rs index 76ccacb331f..6dcbd4a129e 100644 --- a/src/libstd/rt/crate_map.rs +++ b/src/libstd/rt/crate_map.rs @@ -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 @@ mod tests { 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 @@ mod tests { 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); } } diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs index 08d111da351..3147e3c8a07 100644 --- a/src/libstd/rt/global_heap.rs +++ b/src/libstd/rt/global_heap.rs @@ -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]; - } + }) } } diff --git a/src/libstd/rt/local.rs b/src/libstd/rt/local.rs index 23345926543..d5b0e384ca2 100644 --- a/src/libstd/rt/local.rs +++ b/src/libstd/rt/local.rs @@ -182,9 +182,9 @@ mod test { 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); diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs index a7805a9f559..c98a66453eb 100644 --- a/src/libstd/rt/local_heap.rs +++ b/src/libstd/rt/local_heap.rs @@ -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]; }); } } diff --git a/src/libstd/rt/sched.rs b/src/libstd/rt/sched.rs index 519274bb131..ccc786242e6 100644 --- a/src/libstd/rt/sched.rs +++ b/src/libstd/rt/sched.rs @@ -1176,7 +1176,7 @@ mod test { 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 @@ mod test { util::ignore(handle); thread.join(); - } + }) } } @@ -1218,14 +1218,14 @@ mod test { 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 @@ mod test { 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 @@ mod test { 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 @@ mod test { chan.send(()); } - } + }) } // Regression test for a logic bug that would cause single-threaded schedulers @@ -1360,7 +1360,7 @@ mod test { use num::Times; do spawn_sched(SingleThreaded) { - do 5.times { deschedule(); } + 5.times(|| { deschedule(); }) } do spawn { } do spawn { } diff --git a/src/libstd/rt/tube.rs b/src/libstd/rt/tube.rs index 360764daf15..0d4171d5a64 100644 --- a/src/libstd/rt/tube.rs +++ b/src/libstd/rt/tube.rs @@ -103,11 +103,11 @@ mod 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 @@ mod 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 @@ mod test { tube_clone.send(1); } sched.enqueue_blocked_task(task); - } + }); assert!(tube.recv() == 1); } @@ -144,14 +144,14 @@ mod 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, 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 @@ mod test { tube.send(i); callback_send(tube, i + 1); } - } + }) } sched.enqueue_blocked_task(task); - } + }); for i in range(0, MAX) { let j = tube.recv(); diff --git a/src/libstd/select.rs b/src/libstd/select.rs index b619085e201..9b83c493065 100644 --- a/src/libstd/select.rs +++ b/src/libstd/select.rs @@ -211,7 +211,7 @@ mod test { do run_in_uv_task { let (ports, _) = unzip(range(0u, 10).map(|_| stream::())); 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 @@ mod test { 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 @@ mod test { // nondeterministic result, but should succeed select(ports); } - } + }) } } } diff --git a/src/libstd/str.rs b/src/libstd/str.rs index b2ded6ab754..f65ec6971ab 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -3966,19 +3966,25 @@ mod bench { 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] diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index 85f66d4ada8..189f1436d42 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -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 test_spawn_sched_blocking() { 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] diff --git a/src/libstd/unstable/finally.rs b/src/libstd/unstable/finally.rs index 226ce9ef6f2..57aff6031ba 100644 --- a/src/libstd/unstable/finally.rs +++ b/src/libstd/unstable/finally.rs @@ -15,11 +15,11 @@ stack closures that emulates Java-style try/finally blocks. # Example ``` -do || { +(|| { ... -}.finally { +}).finally(|| { always_run_this(); -} +}) ``` */ @@ -70,13 +70,13 @@ impl<'self> Drop for Finallyalizer<'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); } diff --git a/src/libstd/util.rs b/src/libstd/util.rs index 8e939caf756..ddcf408189e 100644 --- a/src/libstd/util.rs +++ b/src/libstd/util.rs @@ -178,17 +178,17 @@ mod bench { 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 @@ mod bench { #[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 }; - } + }); } } diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 30627327d73..9dc4f6ae377 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -3878,13 +3878,17 @@ mod bench { #[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] diff --git a/src/test/auxiliary/xc_conditions_3.rs b/src/test/auxiliary/xc_conditions_3.rs index d5ce63e7e9b..afe9de7abb9 100644 --- a/src/test/auxiliary/xc_conditions_3.rs +++ b/src/test/auxiliary/xc_conditions_3.rs @@ -15,7 +15,7 @@ condition! { } 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() - } + }) } diff --git a/src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs index f8a3c5c573a..c31a7bb244c 100644 --- a/src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs +++ b/src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs @@ -14,8 +14,6 @@ use extra::arc; 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(); } diff --git a/src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs index cb629068681..2fe2095ca87 100644 --- a/src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs +++ b/src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs @@ -13,10 +13,10 @@ use extra::arc; 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); } diff --git a/src/test/compile-fail/arc-rw-state-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-state-shouldnt-escape.rs index 44657dfd0ef..7c129ae0dca 100644 --- a/src/test/compile-fail/arc-rw-state-shouldnt-escape.rs +++ b/src/test/compile-fail/arc-rw-state-shouldnt-escape.rs @@ -13,9 +13,7 @@ use extra::arc; 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 diff --git a/src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs index 44ac0e722d3..674cd570888 100644 --- a/src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs +++ b/src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs @@ -14,10 +14,10 @@ use extra::arc; 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(); } diff --git a/src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs index 75e1989aff0..d9247ab4fc1 100644 --- a/src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs +++ b/src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs @@ -14,9 +14,7 @@ use extra::arc; 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 index 7637ebdc80d..00000000000 --- a/src/test/compile-fail/block-arg-as-stmt-with-value.rs +++ /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 or the MIT license -// , 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); -} diff --git a/src/test/compile-fail/borrowck-assign-comp-idx.rs b/src/test/compile-fail/borrowck-assign-comp-idx.rs index 55ef70ad852..b50a657eae7 100644 --- a/src/test/compile-fail/borrowck-assign-comp-idx.rs +++ b/src/test/compile-fail/borrowck-assign-comp-idx.rs @@ -32,9 +32,9 @@ fn b() { let mut p = ~[1]; - do borrow(p) { + borrow(p, || { p[0] = 5; //~ ERROR cannot assign to - } + }); } fn c() { diff --git a/src/test/compile-fail/borrowck-autoref-3261.rs b/src/test/compile-fail/borrowck-autoref-3261.rs index f834642eb3c..5c7e328969b 100644 --- a/src/test/compile-fail/borrowck-autoref-3261.rs +++ b/src/test/compile-fail/borrowck-autoref-3261.rs @@ -18,7 +18,7 @@ impl X { 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!() } - } + }) } diff --git a/src/test/compile-fail/borrowck-insert-during-each.rs b/src/test/compile-fail/borrowck-insert-during-each.rs index 358305aee08..94ed47b01e1 100644 --- a/src/test/compile-fail/borrowck-insert-during-each.rs +++ b/src/test/compile-fail/borrowck-insert-during-each.rs @@ -23,9 +23,9 @@ impl Foo { } fn bar(f: &mut Foo) { - do f.foo |a| { + f.foo(|a| { f.n.insert(*a); //~ ERROR cannot borrow - } + }) } fn main() { diff --git a/src/test/compile-fail/borrowck-lend-flow-loop.rs b/src/test/compile-fail/borrowck-lend-flow-loop.rs index 14994c0245d..c25f39a9d43 100644 --- a/src/test/compile-fail/borrowck-lend-flow-loop.rs +++ b/src/test/compile-fail/borrowck-lend-flow-loop.rs @@ -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; } diff --git a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs index 417330b6864..a54476abb26 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs @@ -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() { diff --git a/src/test/compile-fail/borrowck-loan-rcvr.rs b/src/test/compile-fail/borrowck-loan-rcvr.rs index e04eaa4d7af..c2ed3378bf9 100644 --- a/src/test/compile-fail/borrowck-loan-rcvr.rs +++ b/src/test/compile-fail/borrowck-loan-rcvr.rs @@ -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() { diff --git a/src/test/compile-fail/borrowck-loan-vec-content.rs b/src/test/compile-fail/borrowck-loan-vec-content.rs index 0617d199191..6527ddfa2ec 100644 --- a/src/test/compile-fail/borrowck-loan-vec-content.rs +++ b/src/test/compile-fail/borrowck-loan-vec-content.rs @@ -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() { diff --git a/src/test/compile-fail/break-outside-loop.rs b/src/test/compile-fail/break-outside-loop.rs index 06281a5e288..4633ca66289 100644 --- a/src/test/compile-fail/break-outside-loop.rs +++ b/src/test/compile-fail/break-outside-loop.rs @@ -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}; diff --git a/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs b/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs index 8fb64ee6dac..1c6d65ba541 100644 --- a/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs +++ b/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs @@ -12,9 +12,9 @@ fn bar(blk: ||:'static) { } fn foo(x: &()) { - do bar { + bar(|| { let _ = x; //~ ERROR does not fulfill `'static` - } + }) } fn main() { diff --git a/src/test/compile-fail/do2.rs b/src/test/compile-fail/do2.rs index ffb779da354..309abe218f6 100644 --- a/src/test/compile-fail/do2.rs +++ b/src/test/compile-fail/do2.rs @@ -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); diff --git a/src/test/compile-fail/lint-unused-mut-variables.rs b/src/test/compile-fail/lint-unused-mut-variables.rs index d73f0e6ab1e..798c1194af8 100644 --- a/src/test/compile-fail/lint-unused-mut-variables.rs +++ b/src/test/compile-fail/lint-unused-mut-variables.rs @@ -35,9 +35,9 @@ fn main() { let mut a = ~[]; a.push(3); let mut a = ~[]; - do callback { + callback(|| { a.push(3); - } + }); let (mut a, b) = (1, 2); a = 34; diff --git a/src/test/compile-fail/lint-unused-unsafe.rs b/src/test/compile-fail/lint-unused-unsafe.rs index 253459be85a..f28322d3bf7 100644 --- a/src/test/compile-fail/lint-unused-unsafe.rs +++ b/src/test/compile-fail/lint-unused-unsafe.rs @@ -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(); - } + }); } } diff --git a/src/test/compile-fail/moves-based-on-type-block-bad.rs b/src/test/compile-fail/moves-based-on-type-block-bad.rs index 355305b6c63..690c778183c 100644 --- a/src/test/compile-fail/moves-based-on-type-block-bad.rs +++ b/src/test/compile-fail/moves-based-on-type-block-bad.rs @@ -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 => {} } - } + }) } } diff --git a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs index bf7383f9c72..260d5a5dd44 100644 --- a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs @@ -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|) { diff --git a/src/test/compile-fail/mutex-arc-nested.rs b/src/test/compile-fail/mutex-arc-nested.rs index bac17dec8ec..476b890efcd 100644 --- a/src/test/compile-fail/mutex-arc-nested.rs +++ b/src/test/compile-fail/mutex-arc-nested.rs @@ -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 + }) }; } diff --git a/src/test/compile-fail/once-cant-call-twice-on-stack.rs b/src/test/compile-fail/once-cant-call-twice-on-stack.rs index 9cc69228c56..98362baef2c 100644 --- a/src/test/compile-fail/once-cant-call-twice-on-stack.rs +++ b/src/test/compile-fail/once-cant-call-twice-on-stack.rs @@ -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); - } + }) } diff --git a/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs b/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs index 4927acde48d..60d1b9c1c34 100644 --- a/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs +++ b/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs @@ -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 - } + }) } diff --git a/src/test/compile-fail/regions-freevar.rs b/src/test/compile-fail/regions-freevar.rs index 7e5abe8e2f7..493b9c466bd 100644 --- a/src/test/compile-fail/regions-freevar.rs +++ b/src/test/compile-fail/regions-freevar.rs @@ -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); - } + }) } diff --git a/src/test/compile-fail/regions-infer-call-3.rs b/src/test/compile-fail/regions-infer-call-3.rs index 8002f8bcc50..bb7c487005f 100644 --- a/src/test/compile-fail/regions-infer-call-3.rs +++ b/src/test/compile-fail/regions-infer-call-3.rs @@ -15,7 +15,7 @@ fn with(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 } diff --git a/src/test/compile-fail/sync-cond-shouldnt-escape.rs b/src/test/compile-fail/sync-cond-shouldnt-escape.rs index 928953de390..4df08b28eb8 100644 --- a/src/test/compile-fail/sync-cond-shouldnt-escape.rs +++ b/src/test/compile-fail/sync-cond-shouldnt-escape.rs @@ -15,8 +15,8 @@ use extra::sync; 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(); } diff --git a/src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs b/src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs index 03779b3ffe3..d59eaf62abf 100644 --- a/src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs +++ b/src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs @@ -14,8 +14,8 @@ use extra::sync; 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(); } diff --git a/src/test/compile-fail/sync-rwlock-read-mode-shouldnt-escape.rs b/src/test/compile-fail/sync-rwlock-read-mode-shouldnt-escape.rs index 6ce3869bab2..e71dfc58816 100644 --- a/src/test/compile-fail/sync-rwlock-read-mode-shouldnt-escape.rs +++ b/src/test/compile-fail/sync-rwlock-read-mode-shouldnt-escape.rs @@ -14,9 +14,9 @@ use extra::sync; 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 { } } diff --git a/src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs b/src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs index fab16894a65..cbe5181d46f 100644 --- a/src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs +++ b/src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs @@ -14,10 +14,10 @@ use extra::sync; 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(); } diff --git a/src/test/compile-fail/sync-rwlock-write-mode-shouldnt-escape.rs b/src/test/compile-fail/sync-rwlock-write-mode-shouldnt-escape.rs index 7210fbf37b4..af0149182ae 100644 --- a/src/test/compile-fail/sync-rwlock-write-mode-shouldnt-escape.rs +++ b/src/test/compile-fail/sync-rwlock-write-mode-shouldnt-escape.rs @@ -14,9 +14,9 @@ use extra::sync; 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 { } } diff --git a/src/test/run-fail/bug-2470-bounds-check-overflow.rs b/src/test/run-fail/bug-2470-bounds-check-overflow.rs index 36f05a0a73c..a476a9727b3 100644 --- a/src/test/run-fail/bug-2470-bounds-check-overflow.rs +++ b/src/test/run-fail/bug-2470-bounds-check-overflow.rs @@ -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::(); error!("ov1 base = 0x{:x}", base); @@ -32,5 +32,5 @@ fn main() { // This should fail. error!("ov1 0x{:x}", x[idx]); - } + }) } diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index 1da5023dce0..c5142897b1d 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -30,14 +30,17 @@ impl iterable for ~[A] { fn length>(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::(z), z.len()); } diff --git a/src/test/run-pass/bitv-perf-test.rs b/src/test/run-pass/bitv-perf-test.rs index dcdab0edc3a..dca0efd94fa 100644 --- a/src/test/run-pass/bitv-perf-test.rs +++ b/src/test/run-pass/bitv-perf-test.rs @@ -20,5 +20,5 @@ fn bitv_test() { } pub fn main() { - do 10000.times || {bitv_test()}; + 10000.times(|| bitv_test()); } diff --git a/src/test/run-pass/block-arg-can-be-followed-by-binop.rs b/src/test/run-pass/block-arg-can-be-followed-by-binop.rs index e65116f2147..f2149e23210 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-binop.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-binop.rs @@ -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]; - - // Trailing expressions don't require parentheses: - let y = do v.iter().fold(0.0) |x, y| { x + *y } + 10.0; - - assert_eq!(y, 15.0); +fn add(x: proc(f64) -> f64) -> f64 { + x(10.0) +} + +pub fn main() { + // Trailing expressions don't require parentheses: + let y = do add |x| { x + 10.0 } + 10.0; + + assert_eq!(y, 30.0); } diff --git a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs index 0d82e294caf..2cdf0a1ffe1 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -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); +fn f(_: proc()) -> proc(proc() -> uint) { + proc(_: proc() -> uint) {} +} + +pub fn main() { + do do f {} { 20 }; } diff --git a/src/test/run-pass/block-arg-can-be-followed-by-call.rs b/src/test/run-pass/block-arg-can-be-followed-by-call.rs index 1bb16f6041e..544367bdfa9 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-call.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-call.rs @@ -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); } diff --git a/src/test/run-pass/block-arg-in-parentheses.rs b/src/test/run-pass/block-arg-in-parentheses.rs index fcd6a8d7c85..083217132de 100644 --- a/src/test/run-pass/block-arg-in-parentheses.rs +++ b/src/test/run-pass/block-arg-in-parentheses.rs @@ -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(); } diff --git a/src/test/run-pass/block-arg-used-as-any.rs b/src/test/run-pass/block-arg-used-as-any.rs index f05eb8e30b1..87a6cbd6fc2 100644 --- a/src/test/run-pass/block-arg-used-as-any.rs +++ b/src/test/run-pass/block-arg-used-as-any.rs @@ -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(); } diff --git a/src/test/run-pass/block-arg.rs b/src/test/run-pass/block-arg.rs index 0608285db1e..afe7747457a 100644 --- a/src/test/run-pass/block-arg.rs +++ b/src/test/run-pass/block-arg.rs @@ -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); } diff --git a/src/test/run-pass/borrowck-borrow-from-expr-block.rs b/src/test/run-pass/borrowck-borrow-from-expr-block.rs index dae10ed6d39..f108d6cad6f 100644 --- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs +++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs @@ -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() { diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index 7b4c4247a35..542a8251f71 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -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); } diff --git a/src/test/run-pass/borrowck-preserve-box-in-field.rs b/src/test/run-pass/borrowck-preserve-box-in-field.rs index bc8eeb5cd41..506d777013c 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-field.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-field.rs @@ -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))); - } + }) } diff --git a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs index 3ff30192efe..d7f7a8e47a2 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs @@ -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))); - } + }) } diff --git a/src/test/run-pass/borrowck-preserve-box.rs b/src/test/run-pass/borrowck-preserve-box.rs index e83621d6bb2..feea06cd69a 100644 --- a/src/test/run-pass/borrowck-preserve-box.rs +++ b/src/test/run-pass/borrowck-preserve-box.rs @@ -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))); - } + }) } diff --git a/src/test/run-pass/borrowck-preserve-expl-deref.rs b/src/test/run-pass/borrowck-preserve-expl-deref.rs index 6041fa977f5..d131a529f1a 100644 --- a/src/test/run-pass/borrowck-preserve-expl-deref.rs +++ b/src/test/run-pass/borrowck-preserve-expl-deref.rs @@ -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))); - } + }) } diff --git a/src/test/run-pass/cci_impl_exe.rs b/src/test/run-pass/cci_impl_exe.rs index b85d53991ea..fd24b7cfe95 100644 --- a/src/test/run-pass/cci_impl_exe.rs +++ b/src/test/run-pass/cci_impl_exe.rs @@ -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); - } + }) } diff --git a/src/test/run-pass/cci_iter_exe.rs b/src/test/run-pass/cci_iter_exe.rs index ea313a48bb3..938956a18b6 100644 --- a/src/test/run-pass/cci_iter_exe.rs +++ b/src/test/run-pass/cci_iter_exe.rs @@ -16,8 +16,8 @@ extern mod cci_iter_lib; 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)); - } + }) } diff --git a/src/test/run-pass/cci_no_inline_exe.rs b/src/test/run-pass/cci_no_inline_exe.rs index 53c67e4802b..e2532667560 100644 --- a/src/test/run-pass/cci_no_inline_exe.rs +++ b/src/test/run-pass/cci_no_inline_exe.rs @@ -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); - } + }) } diff --git a/src/test/run-pass/core-run-destroy.rs b/src/test/run-pass/core-run-destroy.rs index a24d11a89b0..07d9fb95dcb 100644 --- a/src/test/run-pass/core-run-destroy.rs +++ b/src/test/run-pass/core-run-destroy.rs @@ -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) { diff --git a/src/test/run-pass/deriving-encodable-decodable.rs b/src/test/run-pass/deriving-encodable-decodable.rs index 5812800259b..5f3cebed667 100644 --- a/src/test/run-pass/deriving-encodable-decodable.rs +++ b/src/test/run-pass/deriving-encodable-decodable.rs @@ -71,9 +71,9 @@ pub fn main() { roundtrip::(); roundtrip::(); - do 20.times { + 20.times(|| { roundtrip::(); roundtrip::(); roundtrip::>(); - } + }) } diff --git a/src/test/run-pass/deriving-rand.rs b/src/test/run-pass/deriving-rand.rs index 39a86c0ae3f..9a28ed70088 100644 --- a/src/test/run-pass/deriving-rand.rs +++ b/src/test/run-pass/deriving-rand.rs @@ -34,10 +34,10 @@ enum D { fn main() { // check there's no segfaults - do 20.times { + 20.times(|| { rand::random::(); rand::random::(); rand::random::(); rand::random::(); - } + }) } diff --git a/src/test/run-pass/do-empty-args.rs b/src/test/run-pass/do-empty-args.rs index 0078294eb89..56ba2ffddbb 100644 --- a/src/test/run-pass/do-empty-args.rs +++ b/src/test/run-pass/do-empty-args.rs @@ -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 } diff --git a/src/test/run-pass/do-no-args.rs b/src/test/run-pass/do-no-args.rs index eb6a4a3db54..0df5c82ab07 100644 --- a/src/test/run-pass/do-no-args.rs +++ b/src/test/run-pass/do-no-args.rs @@ -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 index 85bb84c6061..00000000000 --- a/src/test/run-pass/do-pure.rs +++ /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 or the MIT license -// , 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 index fddf3b15c78..00000000000 --- a/src/test/run-pass/do-stack.rs +++ /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 or the MIT license -// , 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) } -} diff --git a/src/test/run-pass/do1.rs b/src/test/run-pass/do1.rs index fddf3b15c78..bdbad74b320 100644 --- a/src/test/run-pass/do1.rs +++ b/src/test/run-pass/do1.rs @@ -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) } diff --git a/src/test/run-pass/do2.rs b/src/test/run-pass/do2.rs index 1bfb10a9f75..f509f7b454d 100644 --- a/src/test/run-pass/do2.rs +++ b/src/test/run-pass/do2.rs @@ -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); diff --git a/src/test/run-pass/do3.rs b/src/test/run-pass/do3.rs index c08842a45ce..cdba14f1ded 100644 --- a/src/test/run-pass/do3.rs +++ b/src/test/run-pass/do3.rs @@ -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); diff --git a/src/test/run-pass/extern-stress.rs b/src/test/run-pass/extern-stress.rs index 21706848c81..6ef196ccd41 100644 --- a/src/test/run-pass/extern-stress.rs +++ b/src/test/run-pass/extern-stress.rs @@ -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); }; - } + }) } diff --git a/src/test/run-pass/extern-yield.rs b/src/test/run-pass/extern-yield.rs index 45841e22896..1d2f52d8c2e 100644 --- a/src/test/run-pass/extern-yield.rs +++ b/src/test/run-pass/extern-yield.rs @@ -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); }; - } + }) } diff --git a/src/test/run-pass/foreach-nested.rs b/src/test/run-pass/foreach-nested.rs index 1f63bd68d34..9646c6b6eb7 100644 --- a/src/test/run-pass/foreach-nested.rs +++ b/src/test/run-pass/foreach-nested.rs @@ -16,9 +16,9 @@ fn two(it: |int|) { it(0); it(1); } 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); diff --git a/src/test/run-pass/foreach-put-structured.rs b/src/test/run-pass/foreach-put-structured.rs index 91468841e09..7011088fa5d 100644 --- a/src/test/run-pass/foreach-put-structured.rs +++ b/src/test/run-pass/foreach-put-structured.rs @@ -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); } diff --git a/src/test/run-pass/foreach-simple-outer-slot.rs b/src/test/run-pass/foreach-simple-outer-slot.rs index 34b13189326..81e9ac1b808 100644 --- a/src/test/run-pass/foreach-simple-outer-slot.rs +++ b/src/test/run-pass/foreach-simple-outer-slot.rs @@ -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); diff --git a/src/test/run-pass/foreign-fn-linkname.rs b/src/test/run-pass/foreign-fn-linkname.rs index d05680651f7..aeba5c0ec97 100644 --- a/src/test/run-pass/foreign-fn-linkname.rs +++ b/src/test/run-pass/foreign-fn-linkname.rs @@ -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 index ce5c932f8da..00000000000 --- a/src/test/run-pass/issue-1458.rs +++ /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 or the MIT license -// , 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); -} diff --git a/src/test/run-pass/issue-2487-a.rs b/src/test/run-pass/issue-2487-a.rs index 110bceced82..d8c12d8511c 100644 --- a/src/test/run-pass/issue-2487-a.rs +++ b/src/test/run-pass/issue-2487-a.rs @@ -19,9 +19,7 @@ impl Drop for socket { impl socket { pub fn set_identity(&self) { - do closure { - setsockopt_bytes(self.sock.clone()) - } + closure(|| setsockopt_bytes(self.sock.clone())) } } diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index 2d590f25af1..f3c74cd9295 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -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()) - } + }) } _ => { diff --git a/src/test/run-pass/issue-3211.rs b/src/test/run-pass/issue-3211.rs index 5e89cb2dd36..3d8300010d9 100644 --- a/src/test/run-pass/issue-3211.rs +++ b/src/test/run-pass/issue-3211.rs @@ -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); } diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 50d6a3ae6b8..4bb89e2cf17 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -64,11 +64,9 @@ impl Drop for AsciiArt { 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 @@ impl AsciiArt { 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") diff --git a/src/test/run-pass/issue-4401.rs b/src/test/run-pass/issue-4401.rs index ab38d7650da..a6041c79eac 100644 --- a/src/test/run-pass/issue-4401.rs +++ b/src/test/run-pass/issue-4401.rs @@ -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); } diff --git a/src/test/run-pass/issue-5321-immediates-with-bare-self.rs b/src/test/run-pass/issue-5321-immediates-with-bare-self.rs index 3f1dc2f6986..4a0236b2da8 100644 --- a/src/test/run-pass/issue-5321-immediates-with-bare-self.rs +++ b/src/test/run-pass/issue-5321-immediates-with-bare-self.rs @@ -14,9 +14,7 @@ trait Fooable { impl Fooable for uint { fn yes(self) { - do self.times { - println("yes"); - } + self.times(|| println("yes")); } } diff --git a/src/test/run-pass/issue-6153.rs b/src/test/run-pass/issue-6153.rs index f7d0316880a..989a8e5f9c2 100644 --- a/src/test/run-pass/issue-6153.rs +++ b/src/test/run-pass/issue-6153.rs @@ -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); } diff --git a/src/test/run-pass/match-ref-binding-in-guard-3256.rs b/src/test/run-pass/match-ref-binding-in-guard-3256.rs index e1d2f0e1c48..de4da6e3b06 100644 --- a/src/test/run-pass/match-ref-binding-in-guard-3256.rs +++ b/src/test/run-pass/match-ref-binding-in-guard-3256.rs @@ -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!() } diff --git a/src/test/run-pass/newlambdas.rs b/src/test/run-pass/newlambdas.rs index 1835514c0d1..043136fdad9 100644 --- a/src/test/run-pass/newlambdas.rs +++ b/src/test/run-pass/newlambdas.rs @@ -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(||{}); } diff --git a/src/test/run-pass/once-move-out-on-stack.rs b/src/test/run-pass/once-move-out-on-stack.rs index 645948f1426..9995edf5998 100644 --- a/src/test/run-pass/once-move-out-on-stack.rs +++ b/src/test/run-pass/once-move-out-on-stack.rs @@ -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); - } + }) } diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index 96081d30275..6e5aa1aaf8b 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -37,16 +37,12 @@ impl ptr_visit_adaptor { #[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::() |b| { - self.vals.push(b.to_str()); - }; + self.get::(|b| self.vals.push(b.to_str())); true } fn visit_int(&mut self) -> bool { - do self.get::() |i| { - self.vals.push(i.to_str()); - }; + self.get::(|i| self.vals.push(i.to_str())); true } fn visit_i8(&mut self) -> bool { true } diff --git a/src/test/run-pass/regions-infer-call-2.rs b/src/test/run-pass/regions-infer-call-2.rs index 061f2797287..3350c3b65d0 100644 --- a/src/test/run-pass/regions-infer-call-2.rs +++ b/src/test/run-pass/regions-infer-call-2.rs @@ -15,7 +15,7 @@ fn with(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() { diff --git a/src/test/run-pass/rename-directory.rs b/src/test/run-pass/rename-directory.rs index d20f2bfef3b..fa4321451db 100644 --- a/src/test/run-pass/rename-directory.rs +++ b/src/test/run-pass/rename-directory.rs @@ -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"]); diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index 7b331c43568..1b7c3a1f52e 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -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]>) { diff --git a/src/test/run-pass/type-params-in-for-each.rs b/src/test/run-pass/type-params-in-for-each.rs index 042b5e96bbc..ff7ffb6dc6f 100644 --- a/src/test/run-pass/type-params-in-for-each.rs +++ b/src/test/run-pass/type-params-in-for-each.rs @@ -19,9 +19,9 @@ fn range_(lo: uint, hi: uint, it: |uint|) { } fn create_index(_index: ~[S], _hash_fn: extern fn(T) -> uint) { - do range_(0u, 256u) |_i| { + range_(0u, 256u, |_i| { let _bucket: ~[T] = ~[]; - } + }) } pub fn main() { } diff --git a/src/test/run-pass/variadic-ffi.rs b/src/test/run-pass/variadic-ffi.rs index 06026d58f60..9cb2f22d38e 100644 --- a/src/test/run-pass/variadic-ffi.rs +++ b/src/test/run-pass/variadic-ffi.rs @@ -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 diff --git a/src/test/run-pass/writealias.rs b/src/test/run-pass/writealias.rs index 2db954d27c1..8142cafd89e 100644 --- a/src/test/run-pass/writealias.rs +++ b/src/test/run-pass/writealias.rs @@ -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!() } diff --git a/src/test/run-pass/xc_conditions_client.rs b/src/test/run-pass/xc_conditions_client.rs index 730ed18fbbd..99df4b771c5 100644 --- a/src/test/run-pass/xc_conditions_client.rs +++ b/src/test/run-pass/xc_conditions_client.rs @@ -33,8 +33,8 @@ use xc_conditions::trouble; // 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); - } + }) } diff --git a/src/test/run-pass/xc_conditions_client_2.rs b/src/test/run-pass/xc_conditions_client_2.rs index 9666c037449..b3164f1f0aa 100644 --- a/src/test/run-pass/xc_conditions_client_2.rs +++ b/src/test/run-pass/xc_conditions_client_2.rs @@ -15,7 +15,5 @@ extern mod xc_conditions_2; 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)); } diff --git a/src/test/run-pass/xc_conditions_client_4.rs b/src/test/run-pass/xc_conditions_client_4.rs index 69ddb3701b0..e8eea00e492 100644 --- a/src/test/run-pass/xc_conditions_client_4.rs +++ b/src/test/run-pass/xc_conditions_client_4.rs @@ -25,8 +25,8 @@ impl xcc::Thunk for SThunk { } 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) - } + }) } diff --git a/src/test/run-pass/xcrate-static-addresses.rs b/src/test/run-pass/xcrate-static-addresses.rs index 7eb4adfd067..2ea8ab864e1 100644 --- a/src/test/run-pass/xcrate-static-addresses.rs +++ b/src/test/run-pass/xcrate-static-addresses.rs @@ -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(); - } + }) }