Skip to content

Commit 36990df

Browse files
committed
test: Add a test that POD types can be implicitly copied.
1 parent e7fbc1f commit 36990df

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/test/compile-fail/kindck-pod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
// Test which of the builtin types are considered POD.
1212

13+
#[feature(managed_boxes)];
14+
15+
use std::rc::Rc;
16+
1317
fn assert_pod<T:Pod>() { }
1418
trait Dummy { }
1519

@@ -71,8 +75,12 @@ fn test<'a,T,U:Pod>(_: &'a int) {
7175

7276
// structs containing non-POD are not ok
7377
assert_pod::<MyNonpodStruct>(); //~ ERROR does not fulfill `Pod`
78+
79+
// managed or ref counted types are not ok
80+
assert_pod::<@int>(); //~ ERROR does not fulfill `Pod`
81+
assert_pod::<Rc<int>>(); //~ ERROR does not fulfill `Pod`
7482
}
7583

76-
fn main() {
84+
pub fn main() {
7785
}
7886

src/test/run-pass/can-copy-pod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* Any copyright is dedicated to the Public Domain.
2+
* http://creativecommons.org/publicdomain/zero/1.0/ */
3+
4+
// Tests that type parameters with the `Pod` are implicitly copyable.
5+
6+
#[allow(dead_code)];
7+
8+
fn can_copy_pod<T:Pod>(v: T) {
9+
let _a = v;
10+
let _b = v;
11+
}
12+
13+
pub fn main() {}
14+
15+

0 commit comments

Comments
 (0)