test: Add a test that POD types can be implicitly copied.
This commit is contained in:
parent
e7fbc1f553
commit
36990dfa3f
2 changed files with 24 additions and 1 deletions
|
@ -10,6 +10,10 @@
|
|||
|
||||
// Test which of the builtin types are considered POD.
|
||||
|
||||
#[feature(managed_boxes)];
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
fn assert_pod<T:Pod>() { }
|
||||
trait Dummy { }
|
||||
|
||||
|
@ -71,8 +75,12 @@ fn test<'a,T,U:Pod>(_: &'a int) {
|
|||
|
||||
// structs containing non-POD are not ok
|
||||
assert_pod::<MyNonpodStruct>(); //~ ERROR does not fulfill `Pod`
|
||||
|
||||
// managed or ref counted types are not ok
|
||||
assert_pod::<@int>(); //~ ERROR does not fulfill `Pod`
|
||||
assert_pod::<Rc<int>>(); //~ ERROR does not fulfill `Pod`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
pub fn main() {
|
||||
}
|
||||
|
||||
|
|
15
src/test/run-pass/can-copy-pod.rs
Normal file
15
src/test/run-pass/can-copy-pod.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Tests that type parameters with the `Pod` are implicitly copyable.
|
||||
|
||||
#[allow(dead_code)];
|
||||
|
||||
fn can_copy_pod<T:Pod>(v: T) {
|
||||
let _a = v;
|
||||
let _b = v;
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue