diff options
| author | Flavio Percoco <flaper87@gmail.com> | 2014-01-26 11:42:46 +0100 |
|---|---|---|
| committer | Flavio Percoco <flaper87@gmail.com> | 2014-02-04 00:15:27 +0100 |
| commit | c6b1bce96f25e785d22e976d1cc41cabdae5ea73 (patch) | |
| tree | 7becccf629cd6737546e49325a6a8c8a4fd61c50 /src/libstd | |
| parent | d42521aa92006a3378c535adec80ae2257bff083 (diff) | |
| download | rust-c6b1bce96f25e785d22e976d1cc41cabdae5ea73.tar.gz rust-c6b1bce96f25e785d22e976d1cc41cabdae5ea73.zip | |
Replace NonCopyable usage with NoPod
cc #10834
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/cell.rs | 7 | ||||
| -rw-r--r-- | src/libstd/option.rs | 3 | ||||
| -rw-r--r-- | src/libstd/sync/atomics.rs | 40 | ||||
| -rw-r--r-- | src/libstd/task.rs | 7 | ||||
| -rw-r--r-- | src/libstd/util.rs | 38 |
5 files changed, 29 insertions, 66 deletions
diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index eb7d62b7bd3..e19b8ae712f 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -12,8 +12,7 @@ use prelude::*; use cast; -use util::NonCopyable; -use kinds::{marker,Pod}; +use kinds::{marker, Pod}; /// A mutable memory location that admits only `Pod` data. pub struct Cell<T> { @@ -57,9 +56,9 @@ impl<T:Pod> Clone for Cell<T> { pub struct RefCell<T> { priv value: T, priv borrow: BorrowFlag, - priv nc: NonCopyable, priv marker1: marker::InvariantType<T>, priv marker2: marker::NoFreeze, + priv marker3: marker::NoPod, } // Values [1, MAX-1] represent the number of `Ref` active @@ -74,9 +73,9 @@ impl<T> RefCell<T> { RefCell { marker1: marker::InvariantType::<T>, marker2: marker::NoFreeze, + marker3: marker::NoPod, value: value, borrow: UNUSED, - nc: NonCopyable } } diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 19478e3dbb3..39b516aeb12 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -481,6 +481,7 @@ mod tests { use iter::range; use str::StrSlice; use util; + use kinds::marker; use vec::ImmutableVector; #[test] @@ -551,7 +552,7 @@ mod tests { #[test] #[should_fail] fn test_option_too_much_dance() { - let mut y = Some(util::NonCopyable); + let mut y = Some(marker::NoPod); let _y2 = y.take_unwrap(); let _y3 = y.take_unwrap(); } diff --git a/src/libstd/sync/atomics.rs b/src/libstd/sync/atomics.rs index fb62bed9ed0..9b90e434491 100644 --- a/src/libstd/sync/atomics.rs +++ b/src/libstd/sync/atomics.rs @@ -23,16 +23,16 @@ use unstable::intrinsics; use cast; +use std::kinds::marker; use option::{Option,Some,None}; use ops::Drop; -use util::NonCopyable; /** * A simple atomic flag, that can be set and cleared. The most basic atomic type. */ pub struct AtomicFlag { priv v: int, - priv nocopy: NonCopyable + priv nopod: marker::NoPod } /** @@ -40,7 +40,7 @@ pub struct AtomicFlag { */ pub struct AtomicBool { priv v: uint, - priv nocopy: NonCopyable + priv nopod: marker::NoPod } /** @@ -48,7 +48,7 @@ pub struct AtomicBool { */ pub struct AtomicInt { priv v: int, - priv nocopy: NonCopyable + priv nopod: marker::NoPod } /** @@ -56,7 +56,7 @@ pub struct AtomicInt { */ pub struct AtomicUint { priv v: uint, - priv nocopy: NonCopyable + priv nopod: marker::NoPod } /** @@ -66,7 +66,7 @@ pub struct AtomicUint { #[cfg(not(stage0))] pub struct AtomicU64 { priv v: u64, - priv nocopy: NonCopyable + priv nopod: marker::NoPod } /** @@ -75,12 +75,12 @@ pub struct AtomicU64 { #[cfg(not(stage0))] pub struct AtomicPtr<T> { priv p: uint, - priv nocopy: NonCopyable + priv nopod: marker::NoPod } #[cfg(stage0)] pub struct AtomicPtr<T> { priv p: *mut T, - priv nocopy: NonCopyable + priv nopod: marker::NoPod } /** @@ -105,17 +105,17 @@ pub enum Ordering { SeqCst } -pub static INIT_ATOMIC_FLAG : AtomicFlag = AtomicFlag { v: 0, nocopy: NonCopyable }; -pub static INIT_ATOMIC_BOOL : AtomicBool = AtomicBool { v: 0, nocopy: NonCopyable }; -pub static INIT_ATOMIC_INT : AtomicInt = AtomicInt { v: 0, nocopy: NonCopyable }; -pub static INIT_ATOMIC_UINT : AtomicUint = AtomicUint { v: 0, nocopy: NonCopyable }; +pub static INIT_ATOMIC_FLAG : AtomicFlag = AtomicFlag { v: 0, nopod: marker::NoPod }; +pub static INIT_ATOMIC_BOOL : AtomicBool = AtomicBool { v: 0, nopod: marker::NoPod }; +pub static INIT_ATOMIC_INT : AtomicInt = AtomicInt { v: 0, nopod: marker::NoPod }; +pub static INIT_ATOMIC_UINT : AtomicUint = AtomicUint { v: 0, nopod: marker::NoPod }; #[cfg(not(stage0))] -pub static INIT_ATOMIC_U64 : AtomicU64 = AtomicU64 { v: 0, nocopy: NonCopyable }; +pub static INIT_ATOMIC_U64 : AtomicU64 = AtomicU64 { v: 0, nopod: marker::NoPod }; impl AtomicFlag { pub fn new() -> AtomicFlag { - AtomicFlag { v: 0, nocopy: NonCopyable } + AtomicFlag { v: 0, nopod: marker::NoPod} } /** @@ -138,7 +138,7 @@ impl AtomicFlag { impl AtomicBool { pub fn new(v: bool) -> AtomicBool { - AtomicBool { v: if v { 1 } else { 0 }, nocopy: NonCopyable } + AtomicBool { v: if v { 1 } else { 0 }, nopod: marker::NoPod } } #[inline] @@ -203,7 +203,7 @@ impl AtomicBool { impl AtomicInt { pub fn new(v: int) -> AtomicInt { - AtomicInt { v:v, nocopy: NonCopyable } + AtomicInt { v:v, nopod: marker::NoPod} } #[inline] @@ -242,7 +242,7 @@ impl AtomicInt { #[cfg(not(stage0))] impl AtomicU64 { pub fn new(v: u64) -> AtomicU64 { - AtomicU64 { v:v, nocopy: NonCopyable } + AtomicU64 { v:v, nopod: marker::NoPod } } #[inline] @@ -278,7 +278,7 @@ impl AtomicU64 { impl AtomicUint { pub fn new(v: uint) -> AtomicUint { - AtomicUint { v:v, nocopy: NonCopyable } + AtomicUint { v:v, nopod: marker::NoPod } } #[inline] @@ -317,11 +317,11 @@ impl AtomicUint { impl<T> AtomicPtr<T> { #[cfg(stage0)] pub fn new(p: *mut T) -> AtomicPtr<T> { - AtomicPtr { p: p, nocopy: NonCopyable } + AtomicPtr { p: p, nopod: marker::NoPod } } #[cfg(not(stage0))] pub fn new(p: *mut T) -> AtomicPtr<T> { - AtomicPtr { p: p as uint, nocopy: NonCopyable } + AtomicPtr { p: p as uint, nopod: marker::NoPod } } #[inline] diff --git a/src/libstd/task.rs b/src/libstd/task.rs index 5fa0c6431ab..078933be78f 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -56,7 +56,7 @@ use any::Any; use comm::{Chan, Port}; use io::Writer; -use kinds::Send; +use kinds::{Send, marker}; use logging::Logger; use option::{None, Some, Option}; use result::{Result, Ok, Err}; @@ -64,7 +64,6 @@ use rt::local::Local; use rt::task::Task; use send_str::{SendStr, IntoSendStr}; use str::Str; -use util; #[cfg(test)] use any::{AnyOwnExt, AnyRefExt}; #[cfg(test)] use comm::SharedChan; @@ -126,7 +125,7 @@ pub struct TaskOpts { pub struct TaskBuilder { opts: TaskOpts, priv gen_body: Option<proc(v: proc()) -> proc()>, - priv can_not_copy: Option<util::NonCopyable>, + priv nopod: Option<marker::NoPod>, } /** @@ -138,7 +137,7 @@ pub fn task() -> TaskBuilder { TaskBuilder { opts: TaskOpts::new(), gen_body: None, - can_not_copy: None, + nopod: None, } } diff --git a/src/libstd/util.rs b/src/libstd/util.rs index 06c7923bfed..c075f9b4ba8 100644 --- a/src/libstd/util.rs +++ b/src/libstd/util.rs @@ -12,7 +12,6 @@ use cast; use ptr; -use prelude::*; use unstable::intrinsics; /// The identity function. @@ -53,15 +52,6 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T { src } -/// A non-copyable dummy type. -#[deriving(Eq, TotalEq, Ord, TotalOrd)] -#[unsafe_no_drop_flag] -pub struct NonCopyable; - -impl Drop for NonCopyable { - fn drop(&mut self) { } -} - /// A type with no inhabitants pub enum Void { } @@ -101,37 +91,11 @@ mod tests { #[test] fn test_replace() { - let mut x = Some(NonCopyable); + let mut x = Some(~"test"); let y = replace(&mut x, None); assert!(x.is_none()); assert!(y.is_some()); } - - #[test] - fn test_noncopyable() { - assert_eq!(size_of::<NonCopyable>(), 0); - - // verify that `#[unsafe_no_drop_flag]` works as intended on a zero-size struct - - static mut did_run: bool = false; - - struct Foo { five: int } - - impl Drop for Foo { - fn drop(&mut self) { - assert_eq!(self.five, 5); - unsafe { - did_run = true; - } - } - } - - { - let _a = (NonCopyable, Foo { five: 5 }, NonCopyable); - } - - unsafe { assert_eq!(did_run, true); } - } } /// Completely miscellaneous language-construct benchmarks. |
