]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/pinned-deep-copy.rs
rollup merge of #17355 : gamazeps/issue17210
[rust.git] / src / test / compile-fail / pinned-deep-copy.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 #![feature(unsafe_destructor)]
12
13 extern crate debug;
14
15 use std::cell::Cell;
16 use std::gc::{Gc, GC};
17
18 struct r {
19   i: Gc<Cell<int>>,
20 }
21
22 #[unsafe_destructor]
23 impl Drop for r {
24     fn drop(&mut self) {
25         unsafe {
26             self.i.set(self.i.get() + 1);
27         }
28     }
29 }
30
31 fn r(i: Gc<Cell<int>>) -> r {
32     r {
33         i: i
34     }
35 }
36
37 struct A {
38     y: r,
39 }
40
41 fn main() {
42     let i = box(GC) Cell::new(0);
43     {
44         // Can't do this copy
45         let x = box box box A {y: r(i)};
46         let _z = x.clone(); //~ ERROR not implemented
47         println!("{:?}", x);
48     }
49     println!("{:?}", *i);
50 }