Skip to content

Commit

Permalink
rollup merge of rust-lang#21437: FlaPer87/snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Jan 21, 2015
2 parents de89dc8 + cd631c6 commit 04a2255
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 340 deletions.
154 changes: 0 additions & 154 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,61 +175,17 @@ struct RcBox<T> {
/// See the [module level documentation](../index.html) for more details.
#[unsafe_no_drop_flag]
#[stable]
#[cfg(stage0)] // NOTE remove impl after next snapshot
pub struct Rc<T> {
// FIXME #12808: strange names to try to avoid interfering with field accesses of the contained
// type via Deref
_ptr: NonZero<*mut RcBox<T>>,
_nosend: marker::NoSend,
_noshare: marker::NoSync
}

/// An immutable reference-counted pointer type.
///
/// See the [module level documentation](../index.html) for more details.
#[unsafe_no_drop_flag]
#[stable]
#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
pub struct Rc<T> {
// FIXME #12808: strange names to try to avoid interfering with field accesses of the contained
// type via Deref
_ptr: NonZero<*mut RcBox<T>>,
}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
impl<T> !marker::Send for Rc<T> {}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
impl<T> !marker::Sync for Rc<T> {}

impl<T> Rc<T> {
/// Constructs a new `Rc<T>`.
///
/// # Examples
///
/// ```
/// use std::rc::Rc;
///
/// let five = Rc::new(5i);
/// ```
#[stable]
#[cfg(stage0)] // NOTE remove after next snapshot
pub fn new(value: T) -> Rc<T> {
unsafe {
Rc {
// there is an implicit weak pointer owned by all the strong pointers, which
// ensures that the weak destructor never frees the allocation while the strong
// destructor is running, even if the weak pointer is stored inside the strong one.
_ptr: NonZero::new(transmute(box RcBox {
value: value,
strong: Cell::new(1),
weak: Cell::new(1)
})),
_nosend: marker::NoSend,
_noshare: marker::NoSync
}
}
}

/// Constructs a new `Rc<T>`.
///
Expand All @@ -241,7 +197,6 @@ impl<T> Rc<T> {
/// let five = Rc::new(5i);
/// ```
#[stable]
#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
pub fn new(value: T) -> Rc<T> {
unsafe {
Rc {
Expand All @@ -268,29 +223,6 @@ impl<T> Rc<T> {
///
/// let weak_five = five.downgrade();
/// ```
#[cfg(stage0)] // NOTE remove after next snapshot
#[unstable = "Weak pointers may not belong in this module"]
pub fn downgrade(&self) -> Weak<T> {
self.inc_weak();
Weak {
_ptr: self._ptr,
_nosend: marker::NoSend,
_noshare: marker::NoSync
}
}

/// Downgrades the `Rc<T>` to a `Weak<T>` reference.
///
/// # Examples
///
/// ```
/// use std::rc::Rc;
///
/// let five = Rc::new(5i);
///
/// let weak_five = five.downgrade();
/// ```
#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
#[unstable = "Weak pointers may not belong in this module"]
pub fn downgrade(&self) -> Weak<T> {
self.inc_weak();
Expand Down Expand Up @@ -484,25 +416,6 @@ impl<T> Drop for Rc<T> {

#[stable]
impl<T> Clone for Rc<T> {
/// Makes a clone of the `Rc<T>`.
///
/// This increases the strong reference count.
///
/// # Examples
///
/// ```
/// use std::rc::Rc;
///
/// let five = Rc::new(5i);
///
/// five.clone();
/// ```
#[inline]
#[cfg(stage0)] // NOTE remove after next snapshot
fn clone(&self) -> Rc<T> {
self.inc_strong();
Rc { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoSync }
}

/// Makes a clone of the `Rc<T>`.
///
Expand All @@ -518,7 +431,6 @@ impl<T> Clone for Rc<T> {
/// five.clone();
/// ```
#[inline]
#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
fn clone(&self) -> Rc<T> {
self.inc_strong();
Rc { _ptr: self._ptr }
Expand Down Expand Up @@ -715,66 +627,21 @@ impl<T: fmt::String> fmt::String for Rc<T> {
/// See the [module level documentation](../index.html) for more.
#[unsafe_no_drop_flag]
#[unstable = "Weak pointers may not belong in this module."]
#[cfg(stage0)] // NOTE remove impl after next snapshot
pub struct Weak<T> {
// FIXME #12808: strange names to try to avoid interfering with
// field accesses of the contained type via Deref
_ptr: NonZero<*mut RcBox<T>>,
_nosend: marker::NoSend,
_noshare: marker::NoSync
}

/// A weak version of `Rc<T>`.
///
/// Weak references do not count when determining if the inner value should be dropped.
///
/// See the [module level documentation](../index.html) for more.
#[unsafe_no_drop_flag]
#[unstable = "Weak pointers may not belong in this module."]
#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
pub struct Weak<T> {
// FIXME #12808: strange names to try to avoid interfering with
// field accesses of the contained type via Deref
_ptr: NonZero<*mut RcBox<T>>,
}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
#[allow(unstable)]
impl<T> !marker::Send for Weak<T> {}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
#[allow(unstable)]
impl<T> !marker::Sync for Weak<T> {}


#[unstable = "Weak pointers may not belong in this module."]
impl<T> Weak<T> {
/// Upgrades a weak reference to a strong reference.
///
/// Upgrades the `Weak<T>` reference to an `Rc<T>`, if possible.
///
/// Returns `None` if there were no strong references and the data was destroyed.
///
/// # Examples
///
/// ```
/// use std::rc::Rc;
///
/// let five = Rc::new(5i);
///
/// let weak_five = five.downgrade();
///
/// let strong_five: Option<Rc<_>> = weak_five.upgrade();
/// ```
#[cfg(stage0)] // NOTE remove after next snapshot
pub fn upgrade(&self) -> Option<Rc<T>> {
if self.strong() == 0 {
None
} else {
self.inc_strong();
Some(Rc { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoSync })
}
}

/// Upgrades a weak reference to a strong reference.
///
Expand All @@ -793,7 +660,6 @@ impl<T> Weak<T> {
///
/// let strong_five: Option<Rc<_>> = weak_five.upgrade();
/// ```
#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
pub fn upgrade(&self) -> Option<Rc<T>> {
if self.strong() == 0 {
None
Expand Down Expand Up @@ -850,25 +716,6 @@ impl<T> Drop for Weak<T> {

#[unstable = "Weak pointers may not belong in this module."]
impl<T> Clone for Weak<T> {
/// Makes a clone of the `Weak<T>`.
///
/// This increases the weak reference count.
///
/// # Examples
///
/// ```
/// use std::rc::Rc;
///
/// let weak_five = Rc::new(5i).downgrade();
///
/// weak_five.clone();
/// ```
#[inline]
#[cfg(stage0)] // NOTE remove after next snapshot
fn clone(&self) -> Weak<T> {
self.inc_weak();
Weak { _ptr: self._ptr, _nosend: marker::NoSend, _noshare: marker::NoSync }
}

/// Makes a clone of the `Weak<T>`.
///
Expand All @@ -884,7 +731,6 @@ impl<T> Clone for Weak<T> {
/// weak_five.clone();
/// ```
#[inline]
#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
fn clone(&self) -> Weak<T> {
self.inc_weak();
Weak { _ptr: self._ptr }
Expand Down
3 changes: 0 additions & 3 deletions src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ use core::cmp::Ordering::{self, Less, Greater, Equal};
use core::default::Default;
use core::fmt::Show;
use core::fmt;
// NOTE(stage0) remove import after a snapshot
#[cfg(stage0)]
use core::hash::Hash;
use core::iter::{Peekable, Map, FromIterator};
use core::ops::{BitOr, BitAnd, BitXor, Sub};

Expand Down
19 changes: 0 additions & 19 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,16 +376,6 @@ pub struct ContravariantLifetime<'a>;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct InvariantLifetime<'a>;

/// A type which is considered "not sendable", meaning that it cannot
/// be safely sent between tasks, even if it is owned. This is
/// typically embedded in other types, such as `Gc`, to ensure that
/// their instances remain thread-local.
#[unstable = "likely to change with new variance strategy"]
#[lang="no_send_bound"]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[cfg(stage0)] // NOTE remove impl after next snapshot
pub struct NoSend;

/// 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.
Expand All @@ -395,15 +385,6 @@ pub struct NoSend;
#[allow(missing_copy_implementations)]
pub struct NoCopy;

/// A type which is considered "not sync", meaning that
/// its contents are not threadsafe, hence they cannot be
/// shared between tasks.
#[unstable = "likely to change with new variance strategy"]
#[lang="no_sync_bound"]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[cfg(stage0)] // NOTE remove impl after next snapshot
pub struct NoSync;

/// A type which is considered managed by the GC. This is typically
/// embedded in other types.
#[unstable = "likely to change with new variance strategy"]
Expand Down
3 changes: 0 additions & 3 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ use util::nodemap::{FnvHashMap, FnvHashSet, NodeMap};
use util::common::can_reach;

use std::cell::RefCell;
// NOTE(stage0) remove import after a snapshot
#[cfg(stage0)]
use std::hash::{Hash};
use syntax::codemap::Span;
use syntax::{ast, visit};
use syntax::ast::{Block, Item, FnDecl, NodeId, Arm, Pat, Stmt, Expr, Local};
Expand Down
3 changes: 0 additions & 3 deletions src/libstd/io/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ use prelude::v1::*;
use collections::HashMap;
use ffi::CString;
use fmt;
// NOTE(stage0) remove import after a snapshot
#[cfg(stage0)]
use hash::Hash;
use io::pipe::{PipeStream, PipePair};
use io::{IoResult, IoError};
use io;
Expand Down
30 changes: 0 additions & 30 deletions src/libstd/sync/mpsc/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ use thread::Thread;
use sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
use sync::Arc;
use marker::{Sync, Send};
#[cfg(stage0)] // NOTE remove use after next snapshot
use marker::{NoSend, NoSync};
use mem;
use clone::Clone;

Expand All @@ -32,42 +30,14 @@ pub struct SignalToken {
inner: Arc<Inner>,
}

#[cfg(stage0)] // NOTE remove impl after next snapshot
pub struct WaitToken {
inner: Arc<Inner>,
no_send: NoSend,
no_sync: NoSync,
}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
pub struct WaitToken {
inner: Arc<Inner>,
}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
impl !Send for WaitToken {}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
impl !Sync for WaitToken {}

#[cfg(stage0)] // NOTE remove impl after next snapshot
pub fn tokens() -> (WaitToken, SignalToken) {
let inner = Arc::new(Inner {
thread: Thread::current(),
woken: ATOMIC_BOOL_INIT,
});
let wait_token = WaitToken {
inner: inner.clone(),
no_send: NoSend,
no_sync: NoSync,
};
let signal_token = SignalToken {
inner: inner
};
(wait_token, signal_token)
}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
pub fn tokens() -> (WaitToken, SignalToken) {
let inner = Arc::new(Inner {
thread: Thread::current(),
Expand Down
17 changes: 0 additions & 17 deletions src/libstd/sync/mpsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,22 +370,10 @@ unsafe impl<T:Send> Send for Sender<T> { }
/// The sending-half of Rust's synchronous channel type. This half can only be
/// owned by one task, but it can be cloned to send to other tasks.
#[stable]
#[cfg(stage0)] // NOTE remove impl after next snapshot
pub struct SyncSender<T> {
inner: Arc<RacyCell<sync::Packet<T>>>,
// can't share in an arc
_marker: marker::NoSync,
}

/// The sending-half of Rust's synchronous channel type. This half can only be
/// owned by one task, but it can be cloned to send to other tasks.
#[stable]
#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
pub struct SyncSender<T> {
inner: Arc<RacyCell<sync::Packet<T>>>,
}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
impl<T> !marker::Sync for SyncSender<T> {}

/// An error returned from the `send` function on channels.
Expand Down Expand Up @@ -689,12 +677,7 @@ impl<T: Send> Drop for Sender<T> {
////////////////////////////////////////////////////////////////////////////////

impl<T: Send> SyncSender<T> {
#[cfg(stage0)] // NOTE remove impl after next snapshot
fn new(inner: Arc<RacyCell<sync::Packet<T>>>) -> SyncSender<T> {
SyncSender { inner: inner, _marker: marker::NoSync }
}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
fn new(inner: Arc<RacyCell<sync::Packet<T>>>) -> SyncSender<T> {
SyncSender { inner: inner }
}
Expand Down

0 comments on commit 04a2255

Please sign in to comment.