use std::cast;
use std::comm;
+use std::kinds::marker;
use std::sync::arc::UnsafeArc;
use std::sync::atomics;
use std::unstable::finally::Finally;
use std::util;
-use std::util::NonCopyable;
use arc::MutexArc;
// See the comment in write_cond for more detail.
priv order: ReacquireOrderLock<'a>,
// Make sure condvars are non-copyable.
- priv token: util::NonCopyable,
+ priv nopod: marker::NoPod,
}
impl<'a> Condvar<'a> {
blk(&Condvar {
sem: self,
order: Nothing,
- token: NonCopyable
+ nopod: marker::NoPod
})
})
}
(&self.order_lock).release();
let opt_lock = Just(&self.order_lock);
blk(&Condvar { sem: cond.sem, order: opt_lock,
- token: NonCopyable })
+ nopod: marker::NoPod })
})
}
(&self.access_lock).acquire();
(&self.order_lock).release();
(|| {
- blk(RWLockWriteMode { lock: self, token: NonCopyable })
+ blk(RWLockWriteMode { lock: self, nopod: marker::NoPod })
}).finally(|| {
let writer_or_last_reader;
// Check if we're releasing from read mode or from write mode.
(&self.access_lock).release();
}
}
- RWLockReadMode { lock: token.lock, token: NonCopyable }
+ RWLockReadMode { lock: token.lock, nopod: marker::NoPod }
}
}
/// The "write permission" token used for rwlock.write_downgrade().
-pub struct RWLockWriteMode<'a> { priv lock: &'a RWLock, priv token: NonCopyable }
+pub struct RWLockWriteMode<'a> { priv lock: &'a RWLock, priv nopod: marker::NoPod }
/// The "read permission" token used for rwlock.write_downgrade().
pub struct RWLockReadMode<'a> { priv lock: &'a RWLock,
- priv token: NonCopyable }
+ priv nopod: marker::NoPod }
impl<'a> RWLockWriteMode<'a> {
/// Access the pre-downgrade rwlock in write mode.
// access lock. See comment in RWLock::write_cond for why.
blk(&Condvar { sem: &self.lock.access_lock,
order: Just(&self.lock.order_lock),
- token: NonCopyable })
+ nopod: marker::NoPod })
}
}
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> {
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
RefCell {
marker1: marker::InvariantType::<T>,
marker2: marker::NoFreeze,
+ marker3: marker::NoPod,
value: value,
borrow: UNUSED,
- nc: NonCopyable
}
}
use iter::range;
use str::StrSlice;
use util;
+ use kinds::marker;
use vec::ImmutableVector;
#[test]
#[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();
}
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
}
/**
*/
pub struct AtomicBool {
priv v: uint,
- priv nocopy: NonCopyable
+ priv nopod: marker::NoPod
}
/**
*/
pub struct AtomicInt {
priv v: int,
- priv nocopy: NonCopyable
+ priv nopod: marker::NoPod
}
/**
*/
pub struct AtomicUint {
priv v: uint,
- priv nocopy: NonCopyable
+ priv nopod: marker::NoPod
}
/**
#[cfg(not(stage0))]
pub struct AtomicU64 {
priv v: u64,
- priv nocopy: NonCopyable
+ priv nopod: marker::NoPod
}
/**
#[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
}
/**
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}
}
/**
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]
impl AtomicInt {
pub fn new(v: int) -> AtomicInt {
- AtomicInt { v:v, nocopy: NonCopyable }
+ AtomicInt { v:v, nopod: marker::NoPod}
}
#[inline]
#[cfg(not(stage0))]
impl AtomicU64 {
pub fn new(v: u64) -> AtomicU64 {
- AtomicU64 { v:v, nocopy: NonCopyable }
+ AtomicU64 { v:v, nopod: marker::NoPod }
}
#[inline]
impl AtomicUint {
pub fn new(v: uint) -> AtomicUint {
- AtomicUint { v:v, nocopy: NonCopyable }
+ AtomicUint { v:v, nopod: marker::NoPod }
}
#[inline]
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]
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};
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;
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>,
}
/**
TaskBuilder {
opts: TaskOpts::new(),
gen_body: None,
- can_not_copy: None,
+ nopod: None,
}
}
use cast;
use ptr;
-use prelude::*;
use unstable::intrinsics;
/// The identity function.
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 { }
#[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.
use std::cell::Cell;
use std::hashmap::HashSet;
+use std::kinds::marker;
use std::util;
use std::vec;
obsolete_set: HashSet::new(),
mod_path_stack: ~[],
open_braces: ~[],
- non_copyable: util::NonCopyable
+ nopod: marker::NoPod
}
}
/// Stack of spans of open delimiters. Used for error message.
open_braces: ~[Span],
/* do not copy the parser; its state is tied to outside state */
- priv non_copyable: util::NonCopyable
+ priv nopod: marker::NoPod
}
fn is_plain_ident_or_underscore(t: &token::Token) -> bool {
// Issue 4691: Ensure that functional-struct-update can only copy, not
// move, when the struct implements Drop.
-use NC = std::util::NonCopyable;
-struct S { a: int, nc: NC }
+// NoPod
+use NP = std::kinds::marker::NoPod;
+struct S { a: int, np: NP }
impl Drop for S { fn drop(&mut self) { } }
struct T { a: int, mv: ~int }
// Issue 4691: Ensure that functional-struct-updates operates
// correctly and moves rather than copy when appropriate.
-use NC = std::util::NonCopyable;
+use NP = std::kinds::marker::NoPod;
-struct ncint { nc: NC, v: int }
-fn ncint(v: int) -> ncint { ncint { nc: NC, v: v } }
+struct ncint { np: NP, v: int }
+fn ncint(v: int) -> ncint { ncint { np: NP, v: v } }
-struct NoFoo { copied: int, noncopy: ncint, }
+struct NoFoo { copied: int, nopod: ncint, }
impl NoFoo {
- fn new(x:int,y:int) -> NoFoo { NoFoo { copied: x, noncopy: ncint(y) } }
+ fn new(x:int,y:int) -> NoFoo { NoFoo { copied: x, nopod: 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: NonCopyable
+ // Case 1: Nopodable
let f = DropNoFoo::new(1, 2);
- let b = DropNoFoo { inner: NoFoo { noncopy: ncint(3), ..f.inner }};
- let c = DropNoFoo { inner: NoFoo { noncopy: ncint(4), ..f.inner }};
+ let b = DropNoFoo { inner: NoFoo { nopod: ncint(3), ..f.inner }};
+ let c = DropNoFoo { inner: NoFoo { nopod: ncint(4), ..f.inner }};
assert_eq!(f.inner.copied, 1);
- assert_eq!(f.inner.noncopy.v, 2);
+ assert_eq!(f.inner.nopod.v, 2);
assert_eq!(b.inner.copied, 1);
- assert_eq!(b.inner.noncopy.v, 3);
+ assert_eq!(b.inner.nopod.v, 3);
assert_eq!(c.inner.copied, 1);
- assert_eq!(c.inner.noncopy.v, 4);
+ assert_eq!(c.inner.nopod.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 {noncopy: ncint(23), ..f};
+ let b = NoFoo {nopod: ncint(23), ..f};
let c = NoFoo {copied: 24, ..f};
assert_eq!(b.copied, 21);
- assert_eq!(b.noncopy.v, 23);
+ assert_eq!(b.nopod.v, 23);
assert_eq!(c.copied, 24);
- assert_eq!(c.noncopy.v, 22);
+ assert_eq!(c.nopod.v, 22);
}
pub fn main() {