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)})); +}