]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/kindck-copy.rs
Ignore tests broken by failing on ICE
[rust.git] / src / test / compile-fail / kindck-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 // Test which of the builtin types are considered POD.
12
13 #![feature(managed_boxes)]
14
15 use std::rc::Rc;
16
17 fn assert_copy<T:Copy>() { }
18 trait Dummy { }
19
20 struct MyStruct {
21     x: int,
22     y: int,
23 }
24
25 struct MyNoncopyStruct {
26     x: ~int,
27 }
28
29 fn test<'a,T,U:Copy>(_: &'a int) {
30     // lifetime pointers are ok...
31     assert_copy::<&'static int>();
32     assert_copy::<&'a int>();
33     assert_copy::<&'a str>();
34     assert_copy::<&'a [int]>();
35
36     // ...unless they are mutable
37     assert_copy::<&'static mut int>(); //~ ERROR does not fulfill
38     assert_copy::<&'a mut int>();  //~ ERROR does not fulfill
39
40     // ~ pointers are not ok
41     assert_copy::<~int>();   //~ ERROR does not fulfill
42     assert_copy::<~str>();   //~ ERROR does not fulfill
43     assert_copy::<Vec<int> >(); //~ ERROR does not fulfill
44     assert_copy::<~&'a mut int>(); //~ ERROR does not fulfill
45
46     // borrowed object types are generally ok
47     assert_copy::<&'a Dummy>();
48     assert_copy::<&'a Dummy:Copy>();
49     assert_copy::<&'static Dummy:Copy>();
50
51     // owned object types are not ok
52     assert_copy::<~Dummy>(); //~ ERROR does not fulfill
53     assert_copy::<~Dummy:Copy>(); //~ ERROR does not fulfill
54
55     // mutable object types are not ok
56     assert_copy::<&'a mut Dummy:Copy>();  //~ ERROR does not fulfill
57
58     // closures are like an `&mut` object
59     assert_copy::<||>(); //~ ERROR does not fulfill
60
61     // unsafe ptrs are ok
62     assert_copy::<*int>();
63     assert_copy::<*&'a mut int>();
64
65     // regular old ints and such are ok
66     assert_copy::<int>();
67     assert_copy::<bool>();
68     assert_copy::<()>();
69
70     // tuples are ok
71     assert_copy::<(int,int)>();
72
73     // structs of POD are ok
74     assert_copy::<MyStruct>();
75
76     // structs containing non-POD are not ok
77     assert_copy::<MyNoncopyStruct>(); //~ ERROR does not fulfill
78
79     // managed or ref counted types are not ok
80     assert_copy::<@int>();   //~ ERROR does not fulfill
81     assert_copy::<Rc<int>>();   //~ ERROR does not fulfill
82 }
83
84 pub fn main() {
85 }
86