about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2015-05-12 12:48:14 +1200
committerNick Cameron <ncameron@mozilla.com>2015-05-12 12:48:14 +1200
commite0216fcc42d5f4961d07378a783c87814097015f (patch)
treee5f503c129942a2b7c2815b1c8e4db85b5bbcf1b /src/liballoc
parentaa5ca282b20391c6df51fdfa94e0de5672ccfac1 (diff)
parent750f2c63f2737305d33288303cdecb7a470a7922 (diff)
downloadrust-e0216fcc42d5f4961d07378a783c87814097015f.tar.gz
rust-e0216fcc42d5f4961d07378a783c87814097015f.zip
Merge branch 'master' into
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/arc.rs8
-rw-r--r--src/liballoc/boxed.rs13
-rw-r--r--src/liballoc/heap.rs4
-rw-r--r--src/liballoc/lib.rs4
4 files changed, 17 insertions, 12 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs
index ab7030bee15..8c3c21a8902 100644
--- a/src/liballoc/arc.rs
+++ b/src/liballoc/arc.rs
@@ -31,7 +31,7 @@
 //!
 //! # Examples
 //!
-//! Sharing some immutable data between tasks:
+//! Sharing some immutable data between threads:
 //!
 //! ```no_run
 //! use std::sync::Arc;
@@ -48,7 +48,7 @@
 //! }
 //! ```
 //!
-//! Sharing mutable data safely between tasks with a `Mutex`:
+//! Sharing mutable data safely between threads with a `Mutex`:
 //!
 //! ```no_run
 //! use std::sync::{Arc, Mutex};
@@ -89,9 +89,9 @@ use heap::deallocate;
 ///
 /// # Examples
 ///
-/// In this example, a large vector of floats is shared between several tasks.
+/// In this example, a large vector of floats is shared between several threads.
 /// With simple pipes, without `Arc`, a copy would have to be made for each
-/// task.
+/// thread.
 ///
 /// When you clone an `Arc<T>`, it will create another pointer to the data and
 /// increase the reference counter.
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 7696abd659f..a0d60be3000 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -37,7 +37,7 @@
 //! }
 //! ```
 //!
-//! This will print `Cons(1, Box(Cons(2, Box(Nil))))`.
+//! This will print `Cons(1, Cons(2, Nil))`.
 //!
 //! Recursive structures must be boxed, because if the definition of `Cons` looked like this:
 //!
@@ -240,6 +240,7 @@ impl<T: ?Sized + Hash> Hash for Box<T> {
 impl Box<Any> {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
+    /// Attempt to downcast the box to a concrete type.
     pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
         if self.is::<T>() {
             unsafe {
@@ -257,11 +258,15 @@ impl Box<Any> {
     }
 }
 
-impl Box<Any+Send> {
+impl Box<Any + Send> {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
-        <Box<Any>>::downcast(self)
+    /// Attempt to downcast the box to a concrete type.
+    pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any + Send>> {
+        <Box<Any>>::downcast(self).map_err(|s| unsafe {
+            // reapply the Send marker
+            mem::transmute::<Box<Any>, Box<Any + Send>>(s)
+        })
     }
 }
 
diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs
index 86a04a0687a..83795a24c81 100644
--- a/src/liballoc/heap.rs
+++ b/src/liballoc/heap.rs
@@ -95,7 +95,7 @@ pub const EMPTY: *mut () = 0x1 as *mut ();
 
 /// The allocator for unique pointers.
 #[cfg(not(test))]
-#[lang="exchange_malloc"]
+#[lang = "exchange_malloc"]
 #[inline]
 unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
     if size == 0 {
@@ -108,7 +108,7 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
 }
 
 #[cfg(not(test))]
-#[lang="exchange_free"]
+#[lang = "exchange_free"]
 #[inline]
 unsafe fn exchange_free(ptr: *mut u8, old_size: usize, align: usize) {
     deallocate(ptr, old_size, align);
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index c0974dcb2a0..473429b813c 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -26,14 +26,14 @@
 //! There can only be one owner of a `Box`, and the owner can decide to mutate
 //! the contents, which live on the heap.
 //!
-//! This type can be sent among tasks efficiently as the size of a `Box` value
+//! This type can be sent among threads efficiently as the size of a `Box` value
 //! is the same as that of a pointer. Tree-like data structures are often built
 //! with boxes because each node often has only one owner, the parent.
 //!
 //! ## Reference counted pointers
 //!
 //! The [`Rc`](rc/index.html) type is a non-threadsafe reference-counted pointer
-//! type intended for sharing memory within a task. An `Rc` pointer wraps a
+//! type intended for sharing memory within a thread. An `Rc` pointer wraps a
 //! type, `T`, and only allows access to `&T`, a shared reference.
 //!
 //! This type is useful when inherited mutability (such as using `Box`) is too