]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/pinned-deep-copy.rs
auto merge of #13967 : richo/rust/features/ICE-fails, r=alexcrichton
[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(managed_boxes)]
12
13 use std::cell::Cell;
14
15 struct r {
16   i: @Cell<int>,
17 }
18
19 #[unsafe_destructor]
20 impl Drop for r {
21     fn drop(&mut self) {
22         unsafe {
23             self.i.set(self.i.get() + 1);
24         }
25     }
26 }
27
28 fn r(i: @Cell<int>) -> r {
29     r {
30         i: i
31     }
32 }
33
34 struct A {
35     y: r,
36 }
37
38 fn main() {
39     let i = @Cell::new(0);
40     {
41         // Can't do this copy
42         let x = box box box A {y: r(i)};
43         let _z = x.clone(); //~ ERROR failed to find an implementation
44         println!("{:?}", x);
45     }
46     println!("{:?}", *i);
47 }