- stack unwinding and general failure; the `eh_personality`, `fail_`
and `fail_bounds_checks` lang items.
- the traits in `std::kinds` used to indicate types that satisfy
- various kinds; lang items `send`, `share` and `pod`.
+ various kinds; lang items `send`, `share` and `copy`.
- the marker types and variance indicators found in
`std::kinds::markers`; lang items `covariant_type`,
`contravariant_lifetime`, `no_share_bound`, etc.
This kind includes scalars, owning pointers, owned closures, and
structural types containing only other owned types.
All `Send` types are `'static`.
-`Pod`
+`Copy`
: Types of this kind consist of "Plain Old Data"
which can be copied by simply moving bits.
All values of this kind can be implicitly copied.
This kind includes scalars and immutable references,
- as well as structural types containing other `Pod` types.
+ as well as structural types containing other `Copy` types.
`'static`
: Types of this kind do not contain any references (except for
references with the `static` lifetime, which are allowed).
" to make it easy to update.
" Core operators {{{3
-syn keyword rustTrait Freeze Pod Send Sized
+syn keyword rustTrait Freeze Copy Send Sized
syn keyword rustTrait Add Sub Mul Div Rem Neg Not
syn keyword rustTrait BitAnd BitOr BitXor
syn keyword rustTrait Drop
struct Chunk {
data: Rc<RefCell<Vec<u8> >>,
fill: Cell<uint>,
- is_pod: Cell<bool>,
+ is_copy: Cell<bool>,
}
impl Chunk {
fn capacity(&self) -> uint {
// microoptimization, to avoid needing to case on the list to
// access the head.
priv head: Chunk,
- priv pod_head: Chunk,
+ priv copy_head: Chunk,
priv chunks: RefCell<@List<Chunk>>,
}
pub fn new_with_size(initial_size: uint) -> Arena {
Arena {
head: chunk(initial_size, false),
- pod_head: chunk(initial_size, true),
+ copy_head: chunk(initial_size, true),
chunks: RefCell::new(@Nil),
}
}
}
-fn chunk(size: uint, is_pod: bool) -> Chunk {
+fn chunk(size: uint, is_copy: bool) -> Chunk {
Chunk {
data: Rc::new(RefCell::new(Vec::with_capacity(size))),
fill: Cell::new(0u),
- is_pod: Cell::new(is_pod),
+ is_copy: Cell::new(is_copy),
}
}
unsafe {
destroy_chunk(&self.head);
for chunk in self.chunks.get().iter() {
- if !chunk.is_pod.get() {
+ if !chunk.is_copy.get() {
destroy_chunk(chunk);
}
}
impl Arena {
fn chunk_size(&self) -> uint {
- self.pod_head.capacity()
+ self.copy_head.capacity()
}
// Functions for the POD part of the arena
- fn alloc_pod_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
+ fn alloc_copy_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
// Allocate a new chunk.
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
- self.chunks.set(@Cons(self.pod_head.clone(), self.chunks.get()));
- self.pod_head =
+ self.chunks.set(@Cons(self.copy_head.clone(), self.chunks.get()));
+ self.copy_head =
chunk(num::next_power_of_two(new_min_chunk_size + 1u), true);
- return self.alloc_pod_inner(n_bytes, align);
+ return self.alloc_copy_inner(n_bytes, align);
}
#[inline]
- fn alloc_pod_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
+ fn alloc_copy_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
unsafe {
let this = transmute_mut_region(self);
- let start = round_up(this.pod_head.fill.get(), align);
+ let start = round_up(this.copy_head.fill.get(), align);
let end = start + n_bytes;
if end > self.chunk_size() {
- return this.alloc_pod_grow(n_bytes, align);
+ return this.alloc_copy_grow(n_bytes, align);
}
- this.pod_head.fill.set(end);
+ this.copy_head.fill.set(end);
//debug!("idx = {}, size = {}, align = {}, fill = {}",
// start, n_bytes, align, head.fill.get());
- this.pod_head.as_ptr().offset(start as int)
+ this.copy_head.as_ptr().offset(start as int)
}
}
#[inline]
- fn alloc_pod<'a, T>(&'a mut self, op: || -> T) -> &'a T {
+ fn alloc_copy<'a, T>(&'a mut self, op: || -> T) -> &'a T {
unsafe {
- let ptr = self.alloc_pod_inner(mem::size_of::<T>(), mem::min_align_of::<T>());
+ let ptr = self.alloc_copy_inner(mem::size_of::<T>(), mem::min_align_of::<T>());
let ptr: *mut T = transmute(ptr);
mem::move_val_init(&mut (*ptr), op());
return transmute(ptr);
}
// Functions for the non-POD part of the arena
- fn alloc_nonpod_grow(&mut self, n_bytes: uint, align: uint)
+ fn alloc_noncopy_grow(&mut self, n_bytes: uint, align: uint)
-> (*u8, *u8) {
// Allocate a new chunk.
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
self.head =
chunk(num::next_power_of_two(new_min_chunk_size + 1u), false);
- return self.alloc_nonpod_inner(n_bytes, align);
+ return self.alloc_noncopy_inner(n_bytes, align);
}
#[inline]
- fn alloc_nonpod_inner(&mut self, n_bytes: uint, align: uint)
+ fn alloc_noncopy_inner(&mut self, n_bytes: uint, align: uint)
-> (*u8, *u8) {
unsafe {
let start;
}
if end > self.head.capacity() {
- return self.alloc_nonpod_grow(n_bytes, align);
+ return self.alloc_noncopy_grow(n_bytes, align);
}
let head = transmute_mut_region(&mut self.head);
}
#[inline]
- fn alloc_nonpod<'a, T>(&'a mut self, op: || -> T) -> &'a T {
+ fn alloc_noncopy<'a, T>(&'a mut self, op: || -> T) -> &'a T {
unsafe {
let tydesc = get_tydesc::<T>();
let (ty_ptr, ptr) =
- self.alloc_nonpod_inner(mem::size_of::<T>(), mem::min_align_of::<T>());
+ self.alloc_noncopy_inner(mem::size_of::<T>(), mem::min_align_of::<T>());
let ty_ptr: *mut uint = transmute(ty_ptr);
let ptr: *mut T = transmute(ptr);
// Write in our tydesc along with a bit indicating that it
// FIXME: Borrow check
let this = transmute_mut(self);
if intrinsics::needs_drop::<T>() {
- this.alloc_nonpod(op)
+ this.alloc_noncopy(op)
} else {
- this.alloc_pod(op)
+ this.alloc_copy(op)
}
}
}
}
#[test]
- pub fn test_pod() {
+ pub fn test_copy() {
let arena = TypedArena::new();
for _ in range(0, 100000) {
arena.alloc(Point {
}
#[bench]
- pub fn bench_pod(bh: &mut BenchHarness) {
+ pub fn bench_copy(bh: &mut BenchHarness) {
let arena = TypedArena::new();
bh.iter(|| {
arena.alloc(Point {
}
#[bench]
- pub fn bench_pod_nonarena(bh: &mut BenchHarness) {
+ pub fn bench_copy_nonarena(bh: &mut BenchHarness) {
bh.iter(|| {
~Point {
x: 1,
}
#[bench]
- pub fn bench_pod_old_arena(bh: &mut BenchHarness) {
+ pub fn bench_copy_old_arena(bh: &mut BenchHarness) {
let arena = Arena::new();
bh.iter(|| {
arena.alloc(|| {
})
}
- struct Nonpod {
+ struct Noncopy {
string: ~str,
array: Vec<int> ,
}
#[test]
- pub fn test_nonpod() {
+ pub fn test_noncopy() {
let arena = TypedArena::new();
for _ in range(0, 100000) {
- arena.alloc(Nonpod {
+ arena.alloc(Noncopy {
string: ~"hello world",
array: vec!( 1, 2, 3, 4, 5 ),
});
}
#[bench]
- pub fn bench_nonpod(bh: &mut BenchHarness) {
+ pub fn bench_noncopy(bh: &mut BenchHarness) {
let arena = TypedArena::new();
bh.iter(|| {
- arena.alloc(Nonpod {
+ arena.alloc(Noncopy {
string: ~"hello world",
array: vec!( 1, 2, 3, 4, 5 ),
})
}
#[bench]
- pub fn bench_nonpod_nonarena(bh: &mut BenchHarness) {
+ pub fn bench_noncopy_nonarena(bh: &mut BenchHarness) {
bh.iter(|| {
- ~Nonpod {
+ ~Noncopy {
string: ~"hello world",
array: vec!( 1, 2, 3, 4, 5 ),
}
}
#[bench]
- pub fn bench_nonpod_old_arena(bh: &mut BenchHarness) {
+ pub fn bench_noncopy_old_arena(bh: &mut BenchHarness) {
let arena = Arena::new();
bh.iter(|| {
- arena.alloc(|| Nonpod {
+ arena.alloc(|| Noncopy {
string: ~"hello world",
array: vec!( 1, 2, 3, 4, 5 ),
})
/// Represents an index into a `RawTable` with no key or value in it.
pub struct EmptyIndex {
priv idx: int,
- priv nopod: marker::NoPod,
+ priv nocopy: marker::NoCopy,
}
/// Represents an index into a `RawTable` with a key, value, and hash
pub struct FullIndex {
priv idx: int,
priv hash: SafeHash,
- priv nopod: marker::NoPod,
+ priv nocopy: marker::NoCopy,
}
impl FullIndex {
let idx = index as int;
let hash = unsafe { *self.hashes.offset(idx) };
- let nopod = marker::NoPod;
+ let nocopy = marker::NoCopy;
match hash {
EMPTY_BUCKET =>
Empty(EmptyIndex {
idx: idx,
- nopod: nopod
+ nocopy: nocopy
}),
full_hash =>
Full(FullIndex {
idx: idx,
hash: SafeHash { hash: full_hash },
- nopod: nopod,
+ nocopy: nocopy,
})
}
}
self.size += 1;
- FullIndex { idx: idx, hash: hash, nopod: marker::NoPod }
+ FullIndex { idx: idx, hash: hash, nocopy: marker::NoCopy }
}
/// Removes a key and value from the hashtable.
self.size -= 1;
- (EmptyIndex { idx: idx, nopod: marker::NoPod }, k, v)
+ (EmptyIndex { idx: idx, nocopy: marker::NoCopy }, k, v)
}
}
param_bounds.builtin_bounds.add(ty::BoundSized);
}
'P' => {
- param_bounds.builtin_bounds.add(ty::BoundPod);
+ param_bounds.builtin_bounds.add(ty::BoundCopy);
}
'T' => {
param_bounds.builtin_bounds.add(ty::BoundShare);
ty::BoundSend => mywrite!(w, "S"),
ty::BoundStatic => mywrite!(w, "O"),
ty::BoundSized => mywrite!(w, "Z"),
- ty::BoundPod => mywrite!(w, "P"),
+ ty::BoundCopy => mywrite!(w, "P"),
ty::BoundShare => mywrite!(w, "T"),
}
}
Some(ty::BoundSend)
} else if Some(id) == self.sized_trait() {
Some(ty::BoundSized)
- } else if Some(id) == self.pod_trait() {
- Some(ty::BoundPod)
+ } else if Some(id) == self.copy_trait() {
+ Some(ty::BoundCopy)
} else if Some(id) == self.share_trait() {
Some(ty::BoundShare)
} else {
// Variant name, Name, Method name;
SendTraitLangItem, "send", send_trait;
SizedTraitLangItem, "sized", sized_trait;
- PodTraitLangItem, "pod", pod_trait;
+ CopyTraitLangItem, "copy", copy_trait;
ShareTraitLangItem, "share", share_trait;
DropTraitLangItem, "drop", drop_trait;
InvariantLifetimeItem, "invariant_lifetime", invariant_lifetime;
NoSendItem, "no_send_bound", no_send_bound;
- NoPodItem, "no_pod_bound", no_pod_bound;
+ NoCopyItem, "no_copy_bound", no_copy_bound;
NoShareItem, "no_share_bound", no_share_bound;
ManagedItem, "managed_bound", managed_bound;
}
BoundStatic,
BoundSend,
BoundSized,
- BoundPod,
+ BoundCopy,
BoundShare,
}
// Things that make values considered not POD (would be same
// as `Moves`, but for the fact that managed data `@` is
// not considered POD)
- Nonpod = 0b0000_0000__0000_1111__0000,
+ Noncopy = 0b0000_0000__0000_1111__0000,
// Bits to set when a managed value is encountered
//
BoundStatic => self.is_static(cx),
BoundSend => self.is_sendable(cx),
BoundSized => self.is_sized(cx),
- BoundPod => self.is_pod(cx),
+ BoundCopy => self.is_copy(cx),
BoundShare => self.is_sharable(cx),
}
}
!self.intersects(TC::Nonsized)
}
- pub fn is_pod(&self, _: &ctxt) -> bool {
- !self.intersects(TC::Nonpod)
+ pub fn is_copy(&self, _: &ctxt) -> bool {
+ !self.intersects(TC::Noncopy)
}
pub fn interior_unsafe(&self) -> bool {
tc | TC::ReachesNonsendAnnot
} else if Some(did) == cx.lang_items.managed_bound() {
tc | TC::Managed
- } else if Some(did) == cx.lang_items.no_pod_bound() {
+ } else if Some(did) == cx.lang_items.no_copy_bound() {
tc | TC::OwnsAffine
} else if Some(did) == cx.lang_items.no_share_bound() {
tc | TC::ReachesNoShare
BoundStatic => TC::Nonstatic,
BoundSend => TC::Nonsendable,
BoundSized => TC::Nonsized,
- BoundPod => TC::Nonpod,
+ BoundCopy => TC::Noncopy,
BoundShare => TC::Nonsharable,
};
});
ty::BoundStatic => ~"'static",
ty::BoundSend => ~"Send",
ty::BoundSized => ~"Sized",
- ty::BoundPod => ~"Pod",
+ ty::BoundCopy => ~"Pod",
ty::BoundShare => ~"Share",
});
}
ty::BoundStatic => ~"'static",
ty::BoundSend => ~"Send",
ty::BoundSized => ~"Sized",
- ty::BoundPod => ~"Pod",
+ ty::BoundCopy => ~"Pod",
ty::BoundShare => ~"Share",
}
}
use clone::Clone;
use cmp::Eq;
use fmt;
-use kinds::{marker, Pod};
+use kinds::{marker, Copy};
use ops::{Deref, DerefMut, Drop};
use option::{None, Option, Some};
use ty::Unsafe;
-/// A mutable memory location that admits only `Pod` data.
+/// A mutable memory location that admits only `Copy` data.
pub struct Cell<T> {
priv value: Unsafe<T>,
priv noshare: marker::NoShare,
}
-impl<T:Pod> Cell<T> {
+impl<T:Copy> Cell<T> {
/// Creates a new `Cell` containing the given value.
pub fn new(value: T) -> Cell<T> {
Cell {
}
}
-impl<T:Pod> Clone for Cell<T> {
+impl<T:Copy> Clone for Cell<T> {
fn clone(&self) -> Cell<T> {
Cell::new(self.get())
}
}
-impl<T:Eq + Pod> Eq for Cell<T> {
+impl<T:Eq + Copy> Eq for Cell<T> {
fn eq(&self, other: &Cell<T>) -> bool {
self.get() == other.get()
}
pub struct RefCell<T> {
priv value: Unsafe<T>,
priv borrow: BorrowFlag,
- priv nopod: marker::NoPod,
+ priv nocopy: marker::NoCopy,
priv noshare: marker::NoShare,
}
pub fn new(value: T) -> RefCell<T> {
RefCell {
value: Unsafe::new(value),
- nopod: marker::NoPod,
+ nocopy: marker::NoCopy,
noshare: marker::NoShare,
borrow: UNUSED,
}
/// Create a value initialized to zero.
///
/// `init` is unsafe because it returns a zeroed-out datum,
- /// which is unsafe unless T is Pod.
+ /// which is unsafe unless T is Copy.
pub fn init<T>() -> T;
/// Create an uninitialized value.
}
/// Types that can be copied by simply copying bits (i.e. `memcpy`).
-///
-/// The name "POD" stands for "Plain Old Data" and is borrowed from C++.
+#[cfg(stage0)]
#[lang="pod"]
-pub trait Pod {
+pub trait Copy {
+ // Empty.
+}
+
+/// Types that can be copied by simply copying bits (i.e. `memcpy`).
+#[cfg(not(stage0))]
+#[lang="copy"]
+pub trait Copy {
// Empty.
}
/// A type which is considered "not POD", meaning that it is not
/// implicitly copyable. This is typically embedded in other types to
/// ensure that they are never copied, even if they lack a destructor.
+ #[cfg(not(stage0))]
+ #[lang="no_copy_bound"]
+ #[deriving(Eq,Clone)]
+ pub struct NoCopy;
+
+ /// A type which is considered "not POD", meaning that it is not
+ /// implicitly copyable. This is typically embedded in other types to
+ /// ensure that they are never copied, even if they lack a destructor.
+ #[cfg(stage0)]
#[lang="no_pod_bound"]
#[deriving(Eq,Clone)]
- pub struct NoPod;
+ pub struct NoCopy;
/// A type which is considered "not sharable", meaning that
/// its contents are not threadsafe, hence they cannot be
/// Create a value initialized to zero.
///
/// `init` is unsafe because it returns a zeroed-out datum,
-/// which is unsafe unless T is Pod.
+/// which is unsafe unless T is Copy.
#[inline]
pub unsafe fn init<T>() -> T {
intrinsics::init()
use clone::Clone;
use cmp::{Eq, Ord};
-use kinds::Pod;
+use kinds::Copy;
use mem::size_of;
use ops::{Add, Sub, Mul, Div, Rem, Neg};
use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr};
/// Specifies the available operations common to all of Rust's core numeric primitives.
/// These may not always make sense from a purely mathematical point of view, but
/// may be useful for systems programming.
-pub trait Primitive: Pod
+pub trait Primitive: Copy
+ Clone
+ Num
+ NumCast
#[test] #[should_fail]
fn test_option_too_much_dance() {
- let mut y = Some(marker::NoPod);
+ let mut y = Some(marker::NoCopy);
let _y2 = y.take_unwrap();
let _y3 = y.take_unwrap();
}
*/
// Reexported core operators
-pub use kinds::{Pod, Send, Sized, Share};
+pub use kinds::{Copy, Send, Sized, Share};
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
pub use ops::{BitAnd, BitOr, BitXor};
pub use ops::{Drop, Deref, DerefMut};
MutItems{ptr: p,
end: (p as uint + self.len()) as *mut T,
marker: marker::ContravariantLifetime::<'a>,
- marker2: marker::NoPod}
+ marker2: marker::NoCopy}
} else {
MutItems{ptr: p,
end: p.offset(self.len() as int),
marker: marker::ContravariantLifetime::<'a>,
- marker2: marker::NoPod}
+ marker2: marker::NoCopy}
}
}
}
priv ptr: *mut T,
priv end: *mut T,
priv marker: marker::ContravariantLifetime<'a>,
- priv marker2: marker::NoPod
+ priv marker2: marker::NoCopy
}
macro_rules! iterator {
/// An atomic boolean type.
pub struct AtomicBool {
priv v: Unsafe<uint>,
- priv nopod: marker::NoPod
+ priv nocopy: marker::NoCopy
}
/// A signed atomic integer type, supporting basic atomic arithmetic operations
pub struct AtomicInt {
priv v: Unsafe<int>,
- priv nopod: marker::NoPod
+ priv nocopy: marker::NoCopy
}
/// An unsigned atomic integer type, supporting basic atomic arithmetic operations
pub struct AtomicUint {
priv v: Unsafe<uint>,
- priv nopod: marker::NoPod
+ priv nocopy: marker::NoCopy
}
/// An unsafe atomic pointer. Only supports basic atomic operations
pub struct AtomicPtr<T> {
priv p: Unsafe<uint>,
- priv nopod: marker::NoPod
+ priv nocopy: marker::NoCopy
}
/// An atomic, nullable unique pointer
/// An `AtomicBool` initialized to `false`
pub static INIT_ATOMIC_BOOL : AtomicBool = AtomicBool { v: Unsafe{value: 0,
marker1: marker::InvariantType},
- nopod: marker::NoPod };
+ nocopy: marker::NoCopy };
/// An `AtomicInt` initialized to `0`
pub static INIT_ATOMIC_INT : AtomicInt = AtomicInt { v: Unsafe{value: 0,
marker1: marker::InvariantType},
- nopod: marker::NoPod };
+ nocopy: marker::NoCopy };
/// An `AtomicUint` initialized to `0`
pub static INIT_ATOMIC_UINT : AtomicUint = AtomicUint { v: Unsafe{value: 0,
marker1: marker::InvariantType},
- nopod: marker::NoPod };
+ nocopy: marker::NoCopy };
// NB: Needs to be -1 (0b11111111...) to make fetch_nand work correctly
static UINT_TRUE: uint = -1;
/// Create a new `AtomicBool`
pub fn new(v: bool) -> AtomicBool {
let val = if v { UINT_TRUE } else { 0 };
- AtomicBool { v: Unsafe::new(val), nopod: marker::NoPod }
+ AtomicBool { v: Unsafe::new(val), nocopy: marker::NoCopy }
}
/// Load the value
impl AtomicInt {
/// Create a new `AtomicInt`
pub fn new(v: int) -> AtomicInt {
- AtomicInt {v: Unsafe::new(v), nopod: marker::NoPod}
+ AtomicInt {v: Unsafe::new(v), nocopy: marker::NoCopy}
}
/// Load the value
impl AtomicUint {
/// Create a new `AtomicUint`
pub fn new(v: uint) -> AtomicUint {
- AtomicUint { v: Unsafe::new(v), nopod: marker::NoPod }
+ AtomicUint { v: Unsafe::new(v), nocopy: marker::NoCopy }
}
/// Load the value
impl<T> AtomicPtr<T> {
/// Create a new `AtomicPtr`
pub fn new(p: *mut T) -> AtomicPtr<T> {
- AtomicPtr { p: Unsafe::new(p as uint), nopod: marker::NoPod }
+ AtomicPtr { p: Unsafe::new(p as uint), nocopy: marker::NoCopy }
}
/// Load the value
/// Options to spawn the new task with
opts: TaskOpts,
priv gen_body: Option<proc:Send(v: proc:Send()) -> proc:Send()>,
- priv nopod: Option<marker::NoPod>,
+ priv nocopy: Option<marker::NoCopy>,
}
/**
TaskBuilder {
opts: TaskOpts::new(),
gen_body: None,
- nopod: None,
+ nocopy: None,
}
}
pub fn access_cond<'a>(&'a self) -> SemCondGuard<'a> {
SemCondGuard {
guard: self.access(),
- cvar: Condvar { sem: self, order: Nothing, nopod: marker::NoPod },
+ cvar: Condvar { sem: self, order: Nothing, nocopy: marker::NoCopy },
}
}
}
// See the comment in write_cond for more detail.
priv order: ReacquireOrderLock<'a>,
// Make sure condvars are non-copyable.
- priv nopod: marker::NoPod,
+ priv nocopy: marker::NoCopy,
}
impl<'a> Condvar<'a> {
cond: Condvar {
sem: &self.access_lock,
order: Just(&self.order_lock),
- nopod: marker::NoPod,
+ nocopy: marker::NoCopy,
}
}
}
#[deriving(Clone)]
pub struct Values<'a, T>(slice::Items<'a, T>);
-impl<'a, T: Pod> Iterator<T> for Values<'a, T> {
+impl<'a, T: Copy> Iterator<T> for Values<'a, T> {
fn next(&mut self) -> Option<T> {
let &Values(ref mut items) = self;
items.next().map(|&x| x)
obsolete_set: HashSet::new(),
mod_path_stack: Vec::new(),
open_braces: Vec::new(),
- nopod: marker::NoPod
+ nocopy: marker::NoCopy
}
}
/// Stack of spans of open delimiters. Used for error message.
open_braces: Vec<Span> ,
/* do not copy the parser; its state is tied to outside state */
- priv nopod: marker::NoPod
+ priv nocopy: marker::NoCopy
}
fn is_plain_ident_or_underscore(t: &token::Token) -> bool {
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
-// Tests that metadata serialization works for the `Pod` kind.
+// Tests that metadata serialization works for the `Copy` kind.
#[crate_type="lib"];
-pub fn f<T:Pod>() {}
+pub fn f<T:Copy>() {}
pub trait RequiresShare : Share { }
pub trait RequiresRequiresShareAndSend : RequiresShare + Send { }
-pub trait RequiresPod : Pod { }
+pub trait RequiresCopy : Copy { }
struct Foo {
foo: int,
- nopod: marker::NoPod
+ nocopy: marker::NoCopy
}
-static BAR: Foo = Foo{foo: 5, nopod: marker::NoPod};
+static BAR: Foo = Foo{foo: 5, nocopy: marker::NoCopy};
fn test(f: Foo) {
// Issue 4691: Ensure that functional-struct-update can only copy, not
// move, when the struct implements Drop.
-// NoPod
-use NP = std::kinds::marker::NoPod;
+// NoCopy
+use NP = std::kinds::marker::NoCopy;
struct S { a: int, np: NP }
impl Drop for S { fn drop(&mut self) { } }
--- /dev/null
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test which of the builtin types are considered POD.
+
+#[feature(managed_boxes)];
+
+use std::rc::Rc;
+
+fn assert_copy<T:Copy>() { }
+trait Dummy { }
+
+struct MyStruct {
+ x: int,
+ y: int,
+}
+
+struct MyNoncopyStruct {
+ x: ~int,
+}
+
+fn test<'a,T,U:Copy>(_: &'a int) {
+ // lifetime pointers are ok...
+ assert_copy::<&'static int>();
+ assert_copy::<&'a int>();
+ assert_copy::<&'a str>();
+ assert_copy::<&'a [int]>();
+
+ // ...unless they are mutable
+ assert_copy::<&'static mut int>(); //~ ERROR does not fulfill
+ assert_copy::<&'a mut int>(); //~ ERROR does not fulfill
+
+ // ~ pointers are not ok
+ assert_copy::<~int>(); //~ ERROR does not fulfill
+ assert_copy::<~str>(); //~ ERROR does not fulfill
+ assert_copy::<Vec<int> >(); //~ ERROR does not fulfill
+ assert_copy::<~&'a mut int>(); //~ ERROR does not fulfill
+
+ // borrowed object types are generally ok
+ assert_copy::<&'a Dummy>();
+ assert_copy::<&'a Dummy:Copy>();
+ assert_copy::<&'static Dummy:Copy>();
+
+ // owned object types are not ok
+ assert_copy::<~Dummy>(); //~ ERROR does not fulfill
+ assert_copy::<~Dummy:Copy>(); //~ ERROR does not fulfill
+
+ // mutable object types are not ok
+ assert_copy::<&'a mut Dummy:Copy>(); //~ ERROR does not fulfill
+
+ // closures are like an `&mut` object
+ assert_copy::<||>(); //~ ERROR does not fulfill
+
+ // unsafe ptrs are ok
+ assert_copy::<*int>();
+ assert_copy::<*&'a mut int>();
+
+ // regular old ints and such are ok
+ assert_copy::<int>();
+ assert_copy::<bool>();
+ assert_copy::<()>();
+
+ // tuples are ok
+ assert_copy::<(int,int)>();
+
+ // structs of POD are ok
+ assert_copy::<MyStruct>();
+
+ // structs containing non-POD are not ok
+ assert_copy::<MyNoncopyStruct>(); //~ ERROR does not fulfill
+
+ // managed or ref counted types are not ok
+ assert_copy::<@int>(); //~ ERROR does not fulfill
+ assert_copy::<Rc<int>>(); //~ ERROR does not fulfill
+}
+
+pub fn main() {
+}
+
+++ /dev/null
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test which of the builtin types are considered POD.
-
-#[feature(managed_boxes)];
-
-use std::rc::Rc;
-
-fn assert_pod<T:Pod>() { }
-trait Dummy { }
-
-struct MyStruct {
- x: int,
- y: int,
-}
-
-struct MyNonpodStruct {
- x: ~int,
-}
-
-fn test<'a,T,U:Pod>(_: &'a int) {
- // lifetime pointers are ok...
- assert_pod::<&'static int>();
- assert_pod::<&'a int>();
- assert_pod::<&'a str>();
- assert_pod::<&'a [int]>();
-
- // ...unless they are mutable
- assert_pod::<&'static mut int>(); //~ ERROR does not fulfill `Pod`
- assert_pod::<&'a mut int>(); //~ ERROR does not fulfill `Pod`
-
- // ~ pointers are not ok
- assert_pod::<~int>(); //~ ERROR does not fulfill `Pod`
- assert_pod::<~str>(); //~ ERROR does not fulfill `Pod`
- assert_pod::<Vec<int> >(); //~ ERROR does not fulfill `Pod`
- assert_pod::<~&'a mut int>(); //~ ERROR does not fulfill `Pod`
-
- // borrowed object types are generally ok
- assert_pod::<&'a Dummy>();
- assert_pod::<&'a Dummy:Pod>();
- assert_pod::<&'static Dummy:Pod>();
-
- // owned object types are not ok
- assert_pod::<~Dummy>(); //~ ERROR does not fulfill `Pod`
- assert_pod::<~Dummy:Pod>(); //~ ERROR does not fulfill `Pod`
-
- // mutable object types are not ok
- assert_pod::<&'a mut Dummy:Pod>(); //~ ERROR does not fulfill `Pod`
-
- // closures are like an `&mut` object
- assert_pod::<||>(); //~ ERROR does not fulfill `Pod`
-
- // unsafe ptrs are ok
- assert_pod::<*int>();
- assert_pod::<*&'a mut int>();
-
- // regular old ints and such are ok
- assert_pod::<int>();
- assert_pod::<bool>();
- assert_pod::<()>();
-
- // tuples are ok
- assert_pod::<(int,int)>();
-
- // structs of POD are ok
- assert_pod::<MyStruct>();
-
- // 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`
-}
-
-pub fn main() {
-}
-
--- /dev/null
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::kinds::marker;
+
+fn foo<P:Copy>(p: P) { }
+
+fn main()
+{
+ foo(marker::NoCopy); //~ ERROR does not fulfill
+}
+++ /dev/null
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::kinds::marker;
-
-fn foo<P:Pod>(p: P) { }
-
-fn main()
-{
- foo(marker::NoPod); //~ ERROR does not fulfill `Pod`
-}
struct Foo {
foo: int,
- nopod: marker::NoPod
+ nocopy: marker::NoCopy
}
-static BAR: Foo = Foo{foo: 5, nopod: marker::NoPod};
+static BAR: Foo = Foo{foo: 5, nocopy: marker::NoCopy};
fn test(f: Foo) {
extern crate trait_superkinds_in_metadata;
use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare};
-use trait_superkinds_in_metadata::{RequiresPod};
+use trait_superkinds_in_metadata::{RequiresCopy};
struct X<T>(T);
impl <T:Share+Send> RequiresRequiresShareAndSend for X<T> { }
-impl <T:Pod> RequiresPod for X<T> { }
+impl <T:Copy> RequiresCopy for X<T> { }
pub fn main() { }
/* 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.
+// Tests that type parameters with the `Copy` are implicitly copyable.
#[allow(dead_code)];
-fn can_copy_pod<T:Pod>(v: T) {
+fn can_copy_copy<T:Copy>(v: T) {
let _a = v;
let _b = v;
}
// Issue 4691: Ensure that functional-struct-updates operates
// correctly and moves rather than copy when appropriate.
-use NP = std::kinds::marker::NoPod;
+use NP = std::kinds::marker::NoCopy;
struct ncint { np: NP, v: int }
fn ncint(v: int) -> ncint { ncint { np: NP, v: v } }
-struct NoFoo { copied: int, nopod: ncint, }
+struct NoFoo { copied: int, nocopy: ncint, }
impl NoFoo {
- fn new(x:int,y:int) -> NoFoo { NoFoo { copied: x, nopod: ncint(y) } }
+ fn new(x:int,y:int) -> NoFoo { NoFoo { copied: x, nocopy: ncint(y) } }
}
struct MoveFoo { copied: int, moved: ~int, }
// (and thus it is okay that these are Drop; compare against
// compile-fail test: borrowck-struct-update-with-dtor.rs).
- // Case 1: Nopodable
+ // Case 1: Nocopyable
let f = DropNoFoo::new(1, 2);
- let b = DropNoFoo { inner: NoFoo { nopod: ncint(3), ..f.inner }};
- let c = DropNoFoo { inner: NoFoo { nopod: ncint(4), ..f.inner }};
+ let b = DropNoFoo { inner: NoFoo { nocopy: ncint(3), ..f.inner }};
+ let c = DropNoFoo { inner: NoFoo { nocopy: ncint(4), ..f.inner }};
assert_eq!(f.inner.copied, 1);
- assert_eq!(f.inner.nopod.v, 2);
+ assert_eq!(f.inner.nocopy.v, 2);
assert_eq!(b.inner.copied, 1);
- assert_eq!(b.inner.nopod.v, 3);
+ assert_eq!(b.inner.nocopy.v, 3);
assert_eq!(c.inner.copied, 1);
- assert_eq!(c.inner.nopod.v, 4);
+ assert_eq!(c.inner.nocopy.v, 4);
// Case 2: Owned
let f = DropMoveFoo::new(5, 6);
fn test2() {
// move non-copyable field
let f = NoFoo::new(21, 22);
- let b = NoFoo {nopod: ncint(23), ..f};
+ let b = NoFoo {nocopy: ncint(23), ..f};
let c = NoFoo {copied: 24, ..f};
assert_eq!(b.copied, 21);
- assert_eq!(b.nopod.v, 23);
+ assert_eq!(b.nocopy.v, 23);
assert_eq!(c.copied, 24);
- assert_eq!(c.nopod.v, 22);
+ assert_eq!(c.nocopy.v, 22);
}
pub fn main() {
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
-// Tests that metadata serialization works for the `Pod` kind.
+// Tests that metadata serialization works for the `Copy` kind.
extern crate kinds_in_metadata;