]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
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 | ||
1a4d82fc JJ |
11 | use std::cell::Cell; |
12 | ||
85aaf69f | 13 | #[derive(Debug)] |
1a4d82fc JJ |
14 | struct r<'a> { |
15 | i: &'a Cell<isize>, | |
223e47cc LB |
16 | } |
17 | ||
1a4d82fc JJ |
18 | impl<'a> Drop for r<'a> { |
19 | fn drop(&mut self) { | |
223e47cc | 20 | unsafe { |
1a4d82fc | 21 | self.i.set(self.i.get() + 1); |
223e47cc LB |
22 | } |
23 | } | |
24 | } | |
25 | ||
85aaf69f | 26 | fn f<T>(__isize: Vec<T> , _j: Vec<T> ) { |
223e47cc LB |
27 | } |
28 | ||
1a4d82fc JJ |
29 | fn clone<T: Clone>(t: &T) -> T { t.clone() } |
30 | ||
223e47cc | 31 | fn main() { |
1a4d82fc JJ |
32 | let i1 = &Cell::new(0); |
33 | let i2 = &Cell::new(1); | |
c34b1796 AL |
34 | // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. |
35 | let r1 = vec!(Box::new(r { i: i1 })); | |
36 | let r2 = vec!(Box::new(r { i: i2 })); | |
1a4d82fc JJ |
37 | f(clone(&r1), clone(&r2)); |
38 | //~^ ERROR the trait `core::clone::Clone` is not implemented for the type | |
39 | //~^^ ERROR the trait `core::clone::Clone` is not implemented for the type | |
40 | println!("{:?}", (r2, i1.get())); | |
41 | println!("{:?}", (r1, i2.get())); | |
223e47cc | 42 | } |