Skip to content

Commit 77b6a70

Browse files
committed
---
yaml --- r: 118583 b: refs/heads/try c: 01dc27a h: refs/heads/master i: 118581: a8e7d01 118579: 0e4b921 118575: 6a5a3c6 v: v3
1 parent 0074f4d commit 77b6a70

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: b1646cbfd908dc948b251e362669af421100647a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: d6736a1440d42f6af967a8a20ab8d73522112b72
5-
refs/heads/try: 0439162d597d4abfebf93096e71ff45242efe6f0
5+
refs/heads/try: 01dc27a219435714ec38d0a2ddd1594d96e4da72
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libstd/sync/future.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ impl<A:Send> Future<A> {
132132
let (tx, rx) = channel();
133133

134134
spawn(proc() {
135-
tx.send(blk());
135+
// Don't fail if the other end has hung up
136+
let _ = tx.send_opt(blk());
136137
});
137138

138139
Future::from_receiver(rx)
@@ -144,6 +145,7 @@ mod test {
144145
use prelude::*;
145146
use sync::Future;
146147
use task;
148+
use comm::{channel, Sender};
147149

148150
#[test]
149151
fn test_from_value() {
@@ -206,4 +208,28 @@ mod test {
206208
assert_eq!(actual, expected);
207209
});
208210
}
211+
212+
#[test]
213+
fn test_dropped_future_doesnt_fail() {
214+
struct Bomb(Sender<bool>);
215+
216+
local_data_key!(LOCAL: Bomb)
217+
218+
impl Drop for Bomb {
219+
fn drop(&mut self) {
220+
let Bomb(ref tx) = *self;
221+
tx.send(task::failing());
222+
}
223+
}
224+
225+
// Spawn a future, but drop it immediately. When we receive the result
226+
// later on, we should never view the task as having failed.
227+
let (tx, rx) = channel();
228+
drop(Future::spawn(proc() {
229+
LOCAL.replace(Some(Bomb(tx)));
230+
}));
231+
232+
// Make sure the future didn't fail the task.
233+
assert!(!rx.recv());
234+
}
209235
}

0 commit comments

Comments
 (0)