]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/unique-vec-res.rs
Imported Upstream version 1.1.0+dfsg1
[rustc.git] / src / test / compile-fail / unique-vec-res.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 use std::cell::Cell;
12
13 #[derive(Debug)]
14 struct r<'a> {
15 i: &'a Cell<isize>,
16 }
17
18 impl<'a> Drop for r<'a> {
19 fn drop(&mut self) {
20 unsafe {
21 self.i.set(self.i.get() + 1);
22 }
23 }
24 }
25
26 fn f<T>(__isize: Vec<T> , _j: Vec<T> ) {
27 }
28
29 fn clone<T: Clone>(t: &T) -> T { t.clone() }
30
31 fn main() {
32 let i1 = &Cell::new(0);
33 let i2 = &Cell::new(1);
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 }));
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()));
42 }