From 91b69aeb63440d0d8ba09fdff57be2e343e6b2e8 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 25 Jun 2012 12:21:01 -0700 Subject: [PATCH] Test case for issue 2718 This was already fixed by the time I read the issue, but more test cases are always good. Closes #2718 --- src/test/run-pass/issue-2718.rs | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/test/run-pass/issue-2718.rs diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs new file mode 100644 index 0000000000000..e31e57d9213ac --- /dev/null +++ b/src/test/run-pass/issue-2718.rs @@ -0,0 +1,38 @@ +fn sender_terminate(p: *packet) { +} + +class send_packet { + let mut p: option<*packet>; + new(p: *packet) { self.p = some(p); } + drop { + if self.p != none { + let mut p = none; + p <-> self.p; + sender_terminate(option::unwrap(p)) + } + } + fn unwrap() -> *packet { + let mut p = none; + p <-> self.p; + option::unwrap(p) + } +} + +enum state { + empty, + full, + blocked, + terminated +} + +type packet = { + mut state: state, + mut blocked_task: option, + mut payload: option +}; + +fn main() { + let _s: send_packet = send_packet(ptr::addr_of({mut state: empty, + mut blocked_task: none, + mut payload: some(42)})); +}