1 // Test which of the builtin types are considered POD.
5 fn assert_copy<T:Copy>() { }
15 struct MyNoncopyStruct {
19 fn test<'a,T,U:Copy>(_: &'a isize) {
20 // lifetime pointers are ok...
21 assert_copy::<&'static isize>();
22 assert_copy::<&'a isize>();
23 assert_copy::<&'a str>();
24 assert_copy::<&'a [isize]>();
26 // ...unless they are mutable
27 assert_copy::<&'static mut isize>(); //~ ERROR : Copy` is not satisfied
28 assert_copy::<&'a mut isize>(); //~ ERROR : Copy` is not satisfied
31 assert_copy::<Box<isize>>(); //~ ERROR : Copy` is not satisfied
32 assert_copy::<String>(); //~ ERROR : Copy` is not satisfied
33 assert_copy::<Vec<isize> >(); //~ ERROR : Copy` is not satisfied
34 assert_copy::<Box<&'a mut isize>>(); //~ ERROR : Copy` is not satisfied
36 // borrowed object types are generally ok
37 assert_copy::<&'a dyn Dummy>();
38 assert_copy::<&'a (dyn Dummy + Send)>();
39 assert_copy::<&'static (dyn Dummy + Send)>();
41 // owned object types are not ok
42 assert_copy::<Box<dyn Dummy>>(); //~ ERROR : Copy` is not satisfied
43 assert_copy::<Box<dyn Dummy + Send>>(); //~ ERROR : Copy` is not satisfied
45 // mutable object types are not ok
46 assert_copy::<&'a mut (dyn Dummy + Send)>(); //~ ERROR : Copy` is not satisfied
49 assert_copy::<*const isize>();
50 assert_copy::<*const &'a mut isize>();
52 // regular old ints and such are ok
53 assert_copy::<isize>();
54 assert_copy::<bool>();
58 assert_copy::<(isize,isize)>();
60 // structs of POD are ok
61 assert_copy::<MyStruct>();
63 // structs containing non-POD are not ok
64 assert_copy::<MyNoncopyStruct>(); //~ ERROR : Copy` is not satisfied
66 // ref counted types are not ok
67 assert_copy::<Rc<isize>>(); //~ ERROR : Copy` is not satisfied