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
This commit is contained in:
parent
e9f19283b3
commit
91b69aeb63
1 changed files with 38 additions and 0 deletions
38
src/test/run-pass/issue-2718.rs
Normal file
38
src/test/run-pass/issue-2718.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
fn sender_terminate<T:send>(p: *packet<T>) {
|
||||
}
|
||||
|
||||
class send_packet<T: send> {
|
||||
let mut p: option<*packet<T>>;
|
||||
new(p: *packet<T>) { self.p = some(p); }
|
||||
drop {
|
||||
if self.p != none {
|
||||
let mut p = none;
|
||||
p <-> self.p;
|
||||
sender_terminate(option::unwrap(p))
|
||||
}
|
||||
}
|
||||
fn unwrap() -> *packet<T> {
|
||||
let mut p = none;
|
||||
p <-> self.p;
|
||||
option::unwrap(p)
|
||||
}
|
||||
}
|
||||
|
||||
enum state {
|
||||
empty,
|
||||
full,
|
||||
blocked,
|
||||
terminated
|
||||
}
|
||||
|
||||
type packet<T: send> = {
|
||||
mut state: state,
|
||||
mut blocked_task: option<task::task>,
|
||||
mut payload: option<T>
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let _s: send_packet<int> = send_packet(ptr::addr_of({mut state: empty,
|
||||
mut blocked_task: none,
|
||||
mut payload: some(42)}));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue