summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-04-01 13:22:10 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-04-01 13:22:10 -0700
commita3f6273795363c29f3b70c9fa1229c3ed5c14afd (patch)
tree1caecaf3c7d0b18d9184db71cb13ab40d43f170d /src/liballoc
parent232e79fb91f4738194cc4d0757ce17895f992fe7 (diff)
parent19d3dab31b1fca3abc3ba00173b9148bd70d24b0 (diff)
downloadrust-a3f6273795363c29f3b70c9fa1229c3ed5c14afd.tar.gz
rust-a3f6273795363c29f3b70c9fa1229c3ed5c14afd.zip
rollup merge of #23867: nikomatsakis/issue-23086-take-3
This PR implements rust-lang/rfcs#1023. In the process it fixes #23086 and #23516. A few impls in libcore had to be updated, but the impact is generally pretty minimal. Most of the fallout is in the tests that probed the limits of today's coherence.

I tested and we were able to build the most popular crates along with iron (modulo errors around errors being sendable).

Fixes #23918.
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/boxed.rs53
1 files changed, 2 insertions, 51 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index c4541e34cdb..bbf5d7a6042 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -51,15 +51,12 @@ use core::prelude::*;
 use core::any::Any;
 use core::cmp::Ordering;
 use core::default::Default;
-use core::error::Error;
 use core::fmt;
 use core::hash::{self, Hash};
 use core::mem;
 use core::ops::{Deref, DerefMut};
-use core::ptr::{self, Unique};
-use core::raw::{TraitObject, Slice};
-
-use heap;
+use core::ptr::{Unique};
+use core::raw::{TraitObject};
 
 /// A value that represents the heap. This is the default place that the `box`
 /// keyword allocates into when no place is supplied.
@@ -303,49 +300,3 @@ impl<I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for Box<I> {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {}
 
-#[stable(feature = "rust1", since = "1.0.0")]
-impl<'a, E: Error + 'a> From<E> for Box<Error + 'a> {
-    fn from(err: E) -> Box<Error + 'a> {
-        Box::new(err)
-    }
-}
-
-#[stable(feature = "rust1", since = "1.0.0")]
-impl<'a, E: Error + Send + 'a> From<E> for Box<Error + Send + 'a> {
-    fn from(err: E) -> Box<Error + Send + 'a> {
-        Box::new(err)
-    }
-}
-
-#[stable(feature = "rust1", since = "1.0.0")]
-impl<'a, 'b> From<&'b str> for Box<Error + Send + 'a> {
-    fn from(err: &'b str) -> Box<Error + Send + 'a> {
-        #[derive(Debug)]
-        struct StringError(Box<str>);
-        impl Error for StringError {
-            fn description(&self) -> &str { &self.0 }
-        }
-        impl fmt::Display for StringError {
-            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-                self.0.fmt(f)
-            }
-        }
-
-        // Unfortunately `String` is located in libcollections, so we construct
-        // a `Box<str>` manually here.
-        unsafe {
-            let alloc = if err.len() == 0 {
-                0 as *mut u8
-            } else {
-                let ptr = heap::allocate(err.len(), 1);
-                if ptr.is_null() { ::oom(); }
-                ptr as *mut u8
-            };
-            ptr::copy(err.as_bytes().as_ptr(), alloc, err.len());
-            Box::new(StringError(mem::transmute(Slice {
-                data: alloc,
-                len: err.len(),
-            })))
-        }
-    }
-}