Skip to content

Commit 02ddbad

Browse files
olsonjefferybrson
authored andcommitted
core: patch from nmatsakis to make futures non-copyable
1 parent 27129c6 commit 02ddbad

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/libcore/future.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ export future_pipe;
3333

3434
#[doc = "The future type"]
3535
struct Future<A> {
36-
/*priv*/ mut state: FutureState<A>,
36+
/*priv*/ mut state: FutureState<A>;
37+
38+
// FIXME(#2829) -- futures should not be copyable, because they close
39+
// over fn~'s that have pipes and so forth within!
40+
drop {}
3741
}
3842

3943
priv enum FutureState<A> {
@@ -88,7 +92,7 @@ fn from_port<A:Send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
8892
port_ <-> *port;
8993
let port = option::unwrap(port_);
9094
match recv(port) {
91-
future_pipe::completed(move data) => data
95+
future_pipe::completed(move data) => data
9296
}
9397
}
9498
}

src/libcore/unsafe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,13 @@ mod tests {
415415

416416
for uint::range(0u, num_tasks) |_i| {
417417
let total = total.clone();
418-
futures += ~[future::spawn(|| {
418+
vec::push(futures, future::spawn(|| {
419419
for uint::range(0u, count) |_i| {
420420
do total.with |count| {
421421
**count += 1u;
422422
}
423423
}
424-
})];
424+
}));
425425
};
426426

427427
for futures.each |f| { f.get() }

0 commit comments

Comments
 (0)