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