about summary refs log tree commit diff
path: root/src/libstd/par.rs
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2013-01-10 10:59:58 -0800
committerNiko Matsakis <niko@alum.mit.edu>2013-01-31 12:09:00 -0800
commit0682ad0eb9a6b268498a81b2e16a40544e44f0fa (patch)
tree694819bae28cd319401c121afa4daa00adcbdde2 /src/libstd/par.rs
parent42b462e0765f02fd7bb0f2613240ae2489a47fee (diff)
downloadrust-0682ad0eb9a6b268498a81b2e16a40544e44f0fa.tar.gz
rust-0682ad0eb9a6b268498a81b2e16a40544e44f0fa.zip
Finalize moves-based-on-type implementation.
Changes:

- Refactor move mode computation
- Removes move mode arguments, unary move, capture clauses
  (though they still parse for backwards compatibility)
- Simplify how moves are handled in trans
- Fix a number of illegal copies that cropped up
- Workaround for bug involving def-ids in params
  (see details below)

Future work (I'll open bugs for these...):

- Improve error messages for moves that are due
  to bindings
- Add support for moving owned content like a.b.c
  to borrow check, test in trans (but I think it'll
  "just work")
- Proper fix for def-ids in params

Def ids in params:

Move captures into a map instead of recomputing.

This is a workaround for a larger bug having to do with the def-ids associated
with ty_params, which are not always properly preserved when inlining.  I am
not sure of my preferred fix for the larger bug yet.  This current fix removes
the only code in trans that I know of which relies on ty_param def-ids, but
feels fragile.
Diffstat (limited to 'src/libstd/par.rs')
-rw-r--r--src/libstd/par.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libstd/par.rs b/src/libstd/par.rs
index 04d88af1100..779dda0ab29 100644
--- a/src/libstd/par.rs
+++ b/src/libstd/par.rs
@@ -59,7 +59,8 @@ fn map_slices<A: Copy Owned, B: Copy Owned>(
             let end = uint::min(len, base + items_per_task);
             do vec::as_imm_buf(xs) |p, _len| {
                 let f = f();
-                let f = do future_spawn() |move f, copy base| {
+                let base = base;
+                let f = do future_spawn() |move f| {
                     unsafe {
                         let len = end - base;
                         let slice = (ptr::offset(p, base),
@@ -94,7 +95,8 @@ fn map_slices<A: Copy Owned, B: Copy Owned>(
 pub fn map<A: Copy Owned, B: Copy Owned>(
     xs: &[A], f: fn~(&A) -> B) -> ~[B] {
     vec::concat(map_slices(xs, || {
-        fn~(_base: uint, slice : &[A], copy f) -> ~[B] {
+        let f = copy f;
+        fn~(_base: uint, slice : &[A]) -> ~[B] {
             vec::map(slice, |x| f(x))
         }
     }))
@@ -104,6 +106,7 @@ pub fn map<A: Copy Owned, B: Copy Owned>(
 pub fn mapi<A: Copy Owned, B: Copy Owned>(xs: &[A],
                                     f: fn~(uint, &A) -> B) -> ~[B] {
     let slices = map_slices(xs, || {
+        let f = copy f;
         fn~(base: uint, slice : &[A], copy f) -> ~[B] {
             vec::mapi(slice, |i, x| {
                 f(i + base, x)
@@ -141,6 +144,7 @@ pub fn mapi_factory<A: Copy Owned, B: Copy Owned>(
 /// Returns true if the function holds for all elements in the vector.
 pub fn alli<A: Copy Owned>(xs: &[A], f: fn~(uint, &A) -> bool) -> bool {
     do vec::all(map_slices(xs, || {
+        let f = copy f;
         fn~(base: uint, slice : &[A], copy f) -> bool {
             vec::alli(slice, |i, x| {
                 f(i + base, x)
@@ -152,6 +156,7 @@ pub fn alli<A: Copy Owned>(xs: &[A], f: fn~(uint, &A) -> bool) -> bool {
 /// Returns true if the function holds for any elements in the vector.
 pub fn any<A: Copy Owned>(xs: &[A], f: fn~(&A) -> bool) -> bool {
     do vec::any(map_slices(xs, || {
+        let f = copy f;
         fn~(_base : uint, slice: &[A], copy f) -> bool {
             vec::any(slice, |x| f(x))
         }