diff options
| author | Flavio Percoco <flaper87@gmail.com> | 2014-03-27 00:01:11 +0100 |
|---|---|---|
| committer | Flavio Percoco <flaper87@gmail.com> | 2014-03-28 10:34:02 +0100 |
| commit | 81ec1f3c186cd64450d8141aab467f0a1f3a7ebd (patch) | |
| tree | 025bc116bb409b5514e9b42d62f19464531dffcd /src/libstd | |
| parent | ff64381c8bf6a49a0671287de5f5b7316ae2ef9c (diff) | |
| download | rust-81ec1f3c186cd64450d8141aab467f0a1f3a7ebd.tar.gz rust-81ec1f3c186cd64450d8141aab467f0a1f3a7ebd.zip | |
Rename Pod into Copy
Summary: So far, we've used the term POD "Plain Old Data" to refer to types that can be safely copied. However, this term is not consistent with the other built-in bounds that use verbs instead. This patch renames the Pod kind into Copy. RFC: 0003-opt-in-builtin-traits Test Plan: make check Reviewers: cmr Differential Revision: http://phabricator.octayn.net/D3
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/cell.rs | 14 | ||||
| -rw-r--r-- | src/libstd/intrinsics.rs | 2 | ||||
| -rw-r--r-- | src/libstd/kinds.rs | 23 | ||||
| -rw-r--r-- | src/libstd/mem.rs | 2 | ||||
| -rw-r--r-- | src/libstd/num/mod.rs | 4 | ||||
| -rw-r--r-- | src/libstd/option.rs | 2 | ||||
| -rw-r--r-- | src/libstd/prelude.rs | 2 | ||||
| -rw-r--r-- | src/libstd/slice.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sync/atomics.rs | 22 | ||||
| -rw-r--r-- | src/libstd/task.rs | 4 |
10 files changed, 48 insertions, 33 deletions
diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index e0912b826cd..a826521ab6b 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -14,18 +14,18 @@ use cast; 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 { @@ -49,13 +49,13 @@ impl<T:Pod> Cell<T> { } } -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() } @@ -71,7 +71,7 @@ impl<T: fmt::Show> fmt::Show for Cell<T> { pub struct RefCell<T> { priv value: Unsafe<T>, priv borrow: BorrowFlag, - priv nopod: marker::NoPod, + priv nocopy: marker::NoCopy, priv noshare: marker::NoShare, } @@ -86,7 +86,7 @@ impl<T> RefCell<T> { pub fn new(value: T) -> RefCell<T> { RefCell { value: Unsafe::new(value), - nopod: marker::NoPod, + nocopy: marker::NoCopy, noshare: marker::NoShare, borrow: UNUSED, } diff --git a/src/libstd/intrinsics.rs b/src/libstd/intrinsics.rs index 55e7746a44d..97e275ae983 100644 --- a/src/libstd/intrinsics.rs +++ b/src/libstd/intrinsics.rs @@ -296,7 +296,7 @@ extern "rust-intrinsic" { /// 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. diff --git a/src/libstd/kinds.rs b/src/libstd/kinds.rs index f116f61509e..c01b09dd5ac 100644 --- a/src/libstd/kinds.rs +++ b/src/libstd/kinds.rs @@ -33,10 +33,16 @@ pub trait Sized { } /// 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. } @@ -264,9 +270,18 @@ pub mod marker { /// 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 diff --git a/src/libstd/mem.rs b/src/libstd/mem.rs index e124ada08c7..1f0a3b5b0bd 100644 --- a/src/libstd/mem.rs +++ b/src/libstd/mem.rs @@ -79,7 +79,7 @@ pub fn pref_align_of_val<T>(_val: &T) -> uint { /// 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() diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index 202e26e2c93..d09cf28357b 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -17,7 +17,7 @@ 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}; @@ -276,7 +276,7 @@ pub trait Bitwise: Bounded /// 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 diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 14dc42195e1..a1b70600186 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -684,7 +684,7 @@ mod tests { #[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(); } diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index a42ee80b53a..0a4b32f5a89 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -20,7 +20,7 @@ generally useful to many Rust programs. */ // 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}; diff --git a/src/libstd/slice.rs b/src/libstd/slice.rs index 8788a584f30..8602c653523 100644 --- a/src/libstd/slice.rs +++ b/src/libstd/slice.rs @@ -2304,12 +2304,12 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] { 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} } } } @@ -2670,7 +2670,7 @@ pub struct MutItems<'a, T> { priv ptr: *mut T, priv end: *mut T, priv marker: marker::ContravariantLifetime<'a>, - priv marker2: marker::NoPod + priv marker2: marker::NoCopy } macro_rules! iterator { diff --git a/src/libstd/sync/atomics.rs b/src/libstd/sync/atomics.rs index d5f6fac2296..bca7cf25944 100644 --- a/src/libstd/sync/atomics.rs +++ b/src/libstd/sync/atomics.rs @@ -117,25 +117,25 @@ use ty::Unsafe; /// 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 @@ -180,15 +180,15 @@ pub enum Ordering { /// 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; @@ -197,7 +197,7 @@ impl AtomicBool { /// 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 @@ -400,7 +400,7 @@ impl AtomicBool { 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 @@ -467,7 +467,7 @@ impl AtomicInt { 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 @@ -534,7 +534,7 @@ impl AtomicUint { 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 diff --git a/src/libstd/task.rs b/src/libstd/task.rs index c158ddf0d83..c3d02236948 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -87,7 +87,7 @@ pub struct TaskBuilder { /// 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>, } /** @@ -98,7 +98,7 @@ pub fn task() -> TaskBuilder { TaskBuilder { opts: TaskOpts::new(), gen_body: None, - nopod: None, + nocopy: None, } } |
