]> git.lizzy.rs Git - rust.git/blob - src/test/auxiliary/issue-2526.rs
Auto merge of #22541 - Manishearth:rollup, r=Gankro
[rust.git] / src / test / auxiliary / issue-2526.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![crate_name="issue_2526"]
12 #![crate_type = "lib"]
13
14 #![feature(unsafe_destructor)]
15
16 use std::marker;
17
18 struct arc_destruct<T> {
19     _data: int,
20     _marker: marker::PhantomData<T>
21 }
22
23 #[unsafe_destructor]
24 impl<T: Sync> Drop for arc_destruct<T> {
25     fn drop(&mut self) {}
26 }
27
28 fn arc_destruct<T: Sync>(data: int) -> arc_destruct<T> {
29     arc_destruct {
30         _data: data,
31         _marker: marker::PhantomData
32     }
33 }
34
35 fn arc<T: Sync>(_data: T) -> arc_destruct<T> {
36     arc_destruct(0)
37 }
38
39 fn init() -> arc_destruct<context_res> {
40     arc(context_res())
41 }
42
43 struct context_res {
44     ctx : int,
45 }
46
47 impl Drop for context_res {
48     fn drop(&mut self) {}
49 }
50
51 fn context_res() -> context_res {
52     context_res {
53         ctx: 0
54     }
55 }
56
57 pub type context = arc_destruct<context_res>;