diff --git a/src/libcore/future.rs b/src/libcore/future.rs index 361f41ba21b1..79259c785fec 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -1,3 +1,7 @@ +// NB: transitionary, de-mode-ing. +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; + /*! * A type representing values that may be computed concurrently and * operations for working with them. @@ -37,13 +41,13 @@ impl future { fn get() -> A { //! Get the value of the future - get(self) + get(&self) } - fn with(blk: fn(A) -> B) -> B { + fn with(blk: fn((&A)) -> B) -> B { //! Work with the value without copying it - with(self, blk) + with(&self, blk) } } @@ -64,7 +68,7 @@ macro_rules! move_it { {$x:expr} => { unsafe { let y <- *ptr::addr_of($x); y } } } -fn from_port(-port: future_pipe::client::waiting) -> future { +fn from_port(+port: future_pipe::client::waiting) -> future { #[doc = " Create a future from a port @@ -110,13 +114,13 @@ fn spawn(+blk: fn~() -> A) -> future { })) } -fn get(future: future) -> A { +fn get(future: &future) -> A { //! Get the value of the future - do with(future) |v| { v } + do with(future) |v| { *v } } -fn with(future: future, blk: fn(A) -> B) -> B { +fn with(future: &future, blk: fn((&A)) -> B) -> B { //! Work with the value without copying it let v = match copy future.v { @@ -127,7 +131,7 @@ fn with(future: future, blk: fn(A) -> B) -> B { v } }; - blk(*v) + blk(v) } proto! future_pipe { @@ -139,7 +143,7 @@ proto! future_pipe { #[test] fn test_from_value() { let f = from_value(~"snail"); - assert get(f) == ~"snail"; + assert get(&f) == ~"snail"; } #[test] @@ -147,14 +151,14 @@ fn test_from_port() { let (po, ch) = future_pipe::init(); future_pipe::server::completed(ch, ~"whale"); let f = from_port(po); - assert get(f) == ~"whale"; + assert get(&f) == ~"whale"; } #[test] fn test_from_fn() { let f = fn@() -> ~str { ~"brail" }; let f = from_fn(f); - assert get(f) == ~"brail"; + assert get(&f) == ~"brail"; } #[test] @@ -166,19 +170,19 @@ fn test_interface_get() { #[test] fn test_with() { let f = from_value(~"nail"); - assert with(f, |v| v) == ~"nail"; + assert with(&f, |v| *v) == ~"nail"; } #[test] fn test_interface_with() { let f = from_value(~"kale"); - assert f.with(|v| v) == ~"kale"; + assert f.with(|v| *v) == ~"kale"; } #[test] fn test_spawn() { let f = spawn(|| ~"bale"); - assert get(f) == ~"bale"; + assert get(&f) == ~"bale"; } #[test] @@ -186,5 +190,5 @@ fn test_spawn() { #[ignore(cfg(target_os = "win32"))] fn test_futurefail() { let f = spawn(|| fail); - let _x: ~str = get(f); + let _x: ~str = get(&f); } diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 244feb3f713d..230e9173dcb1 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -409,7 +409,7 @@ impl task_builder { do self.future_result(|+r| { result = some(r); }).spawn { comm::send(ch, f()); } - match future::get(option::unwrap(result)) { + match future::get(&option::unwrap(result)) { success => result::ok(comm::recv(po)), failure => result::err(()) } @@ -1704,13 +1704,13 @@ fn test_add_wrapper() { fn test_future_result() { let mut result = none; do task().future_result(|+r| { result = some(r); }).spawn { } - assert future::get(option::unwrap(result)) == success; + assert future::get(&option::unwrap(result)) == success; result = none; do task().future_result(|+r| { result = some(r); }).unlinked().spawn { fail; } - assert future::get(option::unwrap(result)) == failure; + assert future::get(&option::unwrap(result)) == failure; } #[test] #[should_fail] #[ignore(cfg(windows))] diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 03261ec00250..847e08083ef4 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -429,7 +429,7 @@ mod tests { } } // Wait for children to pass their asserts - for vec::each(children) |r| { future::get(r); } + for vec::each(children) |r| { future::get(&r); } // Wait for writer to finish p.recv(); do arc.read |num| { assert *num == 10; } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 4f6d04a5dd79..104826afbac3 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -391,7 +391,7 @@ fn run_test(+test: test_desc, monitor_ch: comm::chan) { task::task().unlinked().future_result(|+r| { result_future = some(r); }).spawn(testfn); - let task_result = future::get(option::unwrap(result_future)); + let task_result = future::get(&option::unwrap(result_future)); let test_result = calc_result(test, task_result == task::success); comm::send(monitor_ch, (copy test, test_result)); }; diff --git a/src/rustdoc/markdown_writer.rs b/src/rustdoc/markdown_writer.rs index 139ea0f36f52..3f33780ed2f2 100644 --- a/src/rustdoc/markdown_writer.rs +++ b/src/rustdoc/markdown_writer.rs @@ -274,7 +274,7 @@ fn future_writer_factory( do task::spawn { let (writer, future) = future_writer(); comm::send(writer_ch, writer); - let s = future::get(future); + let s = future::get(&future); comm::send(markdown_ch, (page, s)); } comm::recv(writer_po)