about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-01-20 23:03:09 +0000
committerbors <bors@rust-lang.org>2015-01-20 23:03:09 +0000
commit29bd9a06efd2f8c8a7b1102e2203cc0e6ae2dcba (patch)
tree98824cc18b1c65ff09f383438d79ad2d0a0e2ea8 /src/libstd
parent583c5c589ed02e5b6b14a576e35e0ce68988d949 (diff)
parent631896dc1996d239a532b0ce02d5fe886660149e (diff)
downloadrust-29bd9a06efd2f8c8a7b1102e2203cc0e6ae2dcba.tar.gz
rust-29bd9a06efd2f8c8a7b1102e2203cc0e6ae2dcba.zip
Auto merge of #21439 - alexcrichton:rollup, r=alexcrichton
Continuation of https://github.com/rust-lang/rust/pull/21428
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/collections/hash/map.rs17
-rw-r--r--src/libstd/collections/hash/table.rs23
-rw-r--r--src/libstd/error.rs4
-rw-r--r--src/libstd/fmt.rs2
-rw-r--r--src/libstd/io/mod.rs6
-rw-r--r--src/libstd/lib.rs2
-rw-r--r--src/libstd/os.rs6
-rw-r--r--src/libstd/sync/poison.rs29
-rw-r--r--src/libstd/sys/unix/backtrace.rs2
-rw-r--r--src/libstd/sys/windows/os.rs2
-rw-r--r--src/libstd/thread_local/mod.rs2
11 files changed, 46 insertions, 49 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index 80ae3076df3..d3ac632617d 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -2113,23 +2113,6 @@ mod test_map {
     }
 
     #[test]
-    fn test_find_equiv() {
-        let mut m = HashMap::new();
-
-        let (foo, bar, baz) = (1i,2i,3i);
-        m.insert("foo".to_string(), foo);
-        m.insert("bar".to_string(), bar);
-        m.insert("baz".to_string(), baz);
-
-
-        assert_eq!(m.get("foo"), Some(&foo));
-        assert_eq!(m.get("bar"), Some(&bar));
-        assert_eq!(m.get("baz"), Some(&baz));
-
-        assert_eq!(m.get("qux"), None);
-    }
-
-    #[test]
     fn test_from_iter() {
         let xs = [(1i, 1i), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)];
 
diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs
index f28b95dbe95..d810460a7d4 100644
--- a/src/libstd/collections/hash/table.rs
+++ b/src/libstd/collections/hash/table.rs
@@ -395,9 +395,6 @@ impl<K, V, M: Deref<Target=RawTable<K, V>> + DerefMut> FullBucket<K, V, M> {
     /// This works similarly to `put`, building an `EmptyBucket` out of the
     /// taken bucket.
     pub fn take(mut self) -> (EmptyBucket<K, V, M>, K, V) {
-        let key = self.raw.key as *const K;
-        let val = self.raw.val as *const V;
-
         self.table.size -= 1;
 
         unsafe {
@@ -408,8 +405,8 @@ impl<K, V, M: Deref<Target=RawTable<K, V>> + DerefMut> FullBucket<K, V, M> {
                     idx: self.idx,
                     table: self.table
                 },
-                ptr::read(key),
-                ptr::read(val)
+                ptr::read(self.raw.key),
+                ptr::read(self.raw.val)
             )
         }
     }
@@ -477,8 +474,8 @@ impl<K, V, M: Deref<Target=RawTable<K, V>>> GapThenFull<K, V, M> {
     pub fn shift(mut self) -> Option<GapThenFull<K, V, M>> {
         unsafe {
             *self.gap.raw.hash = mem::replace(&mut *self.full.raw.hash, EMPTY_BUCKET);
-            copy_nonoverlapping_memory(self.gap.raw.key, self.full.raw.key as *const K, 1);
-            copy_nonoverlapping_memory(self.gap.raw.val, self.full.raw.val as *const V, 1);
+            copy_nonoverlapping_memory(self.gap.raw.key, self.full.raw.key, 1);
+            copy_nonoverlapping_memory(self.gap.raw.val, self.full.raw.val, 1);
         }
 
         let FullBucket { raw: prev_raw, idx: prev_idx, .. } = self.full;
@@ -781,8 +778,8 @@ impl<'a, K, V> Iterator for RevMoveBuckets<'a, K, V> {
                 if *self.raw.hash != EMPTY_BUCKET {
                     self.elems_left -= 1;
                     return Some((
-                        ptr::read(self.raw.key as *const K),
-                        ptr::read(self.raw.val as *const V)
+                        ptr::read(self.raw.key),
+                        ptr::read(self.raw.val)
                     ));
                 }
             }
@@ -878,8 +875,8 @@ impl<K, V> Iterator for IntoIter<K, V> {
                     SafeHash {
                         hash: *bucket.hash,
                     },
-                    ptr::read(bucket.key as *const K),
-                    ptr::read(bucket.val as *const V)
+                    ptr::read(bucket.key),
+                    ptr::read(bucket.val)
                 )
             }
         })
@@ -906,8 +903,8 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> {
                     SafeHash {
                         hash: ptr::replace(bucket.hash, EMPTY_BUCKET),
                     },
-                    ptr::read(bucket.key as *const K),
-                    ptr::read(bucket.val as *const V)
+                    ptr::read(bucket.key),
+                    ptr::read(bucket.val)
                 )
             }
         })
diff --git a/src/libstd/error.rs b/src/libstd/error.rs
index 9963e4861b7..ff128461978 100644
--- a/src/libstd/error.rs
+++ b/src/libstd/error.rs
@@ -18,7 +18,7 @@
 //! chain information:
 //!
 //! ```
-//! trait Error: Send {
+//! trait Error {
 //!     fn description(&self) -> &str;
 //!
 //!     fn detail(&self) -> Option<String> { None }
@@ -87,7 +87,7 @@ use string::{FromUtf8Error, FromUtf16Error};
 
 /// Base functionality for all errors in Rust.
 #[unstable = "the exact API of this trait may change"]
-pub trait Error: Send {
+pub trait Error {
     /// A short description of the error; usually a static string.
     fn description(&self) -> &str;
 
diff --git a/src/libstd/fmt.rs b/src/libstd/fmt.rs
index 36afa0956d2..88fb983361a 100644
--- a/src/libstd/fmt.rs
+++ b/src/libstd/fmt.rs
@@ -221,7 +221,7 @@
 //! - `fmt::Show` implementations should be implemented for **all** public types.
 //!   Output will typically represent the internal state as faithfully as possible.
 //!   The purpose of the `Show` trait is to facilitate debugging Rust code. In
-//!   most cases, using `#[deriving(Show)]` is sufficient and recommended.
+//!   most cases, using `#[derive(Show)]` is sufficient and recommended.
 //!
 //! Some examples of the output from both traits:
 //!
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index e2b71cd43af..dc21416df7b 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -234,7 +234,7 @@ use error::{FromError, Error};
 use fmt;
 use int;
 use iter::{Iterator, IteratorExt};
-use marker::Sized;
+use marker::{Sized, Send};
 use mem::transmute;
 use ops::FnOnce;
 use option::Option;
@@ -363,8 +363,8 @@ impl Error for IoError {
     }
 }
 
-impl FromError<IoError> for Box<Error> {
-    fn from_error(err: IoError) -> Box<Error> {
+impl FromError<IoError> for Box<Error + Send> {
+    fn from_error(err: IoError) -> Box<Error + Send> {
         box err
     }
 }
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index ddb8129630f..648326eee99 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -18,7 +18,7 @@
 //!
 //! The [`ptr`](ptr/index.html) and [`mem`](mem/index.html)
 //! modules deal with unsafe pointers and memory manipulation.
-//! [`markers`](markers/index.html) defines the special built-in traits,
+//! [`marker`](marker/index.html) defines the special built-in traits,
 //! and [`raw`](raw/index.html) the runtime representation of Rust types.
 //! These are some of the lowest-level building blocks in Rust.
 //!
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index fc0c838a3f1..78db6c158a8 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -37,7 +37,7 @@ use error::{FromError, Error};
 use fmt;
 use io::{IoResult, IoError};
 use iter::{Iterator, IteratorExt};
-use marker::Copy;
+use marker::{Copy, Send};
 use libc::{c_void, c_int, c_char};
 use libc;
 use boxed::Box;
@@ -937,8 +937,8 @@ impl Error for MapError {
     fn detail(&self) -> Option<String> { Some(format!("{:?}", self)) }
 }
 
-impl FromError<MapError> for Box<Error> {
-    fn from_error(err: MapError) -> Box<Error> {
+impl FromError<MapError> for Box<Error + Send> {
+    fn from_error(err: MapError) -> Box<Error + Send> {
         box err
     }
 }
diff --git a/src/libstd/sync/poison.rs b/src/libstd/sync/poison.rs
index cc8c331ef39..e28c3c37b6f 100644
--- a/src/libstd/sync/poison.rs
+++ b/src/libstd/sync/poison.rs
@@ -11,7 +11,7 @@
 use prelude::v1::*;
 
 use cell::UnsafeCell;
-use error::FromError;
+use error::{Error, FromError};
 use fmt;
 use thread::Thread;
 
@@ -92,7 +92,13 @@ pub type TryLockResult<Guard> = Result<Guard, TryLockError<Guard>>;
 
 impl<T> fmt::Show for PoisonError<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        "poisoned lock: another task failed inside".fmt(f)
+        self.description().fmt(f)
+    }
+}
+
+impl<T> Error for PoisonError<T> {
+    fn description(&self) -> &str {
+        "poisoned lock: another task failed inside"
     }
 }
 
@@ -126,11 +132,22 @@ impl<T> FromError<PoisonError<T>> for TryLockError<T> {
 
 impl<T> fmt::Show for TryLockError<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        self.description().fmt(f)
+    }
+}
+
+impl<T> Error for TryLockError<T> {
+    fn description(&self) -> &str {
+        match *self {
+            TryLockError::Poisoned(ref p) => p.description(),
+            TryLockError::WouldBlock => "try_lock failed because the operation would block"
+        }
+    }
+
+    fn cause(&self) -> Option<&Error> {
         match *self {
-            TryLockError::Poisoned(ref p) => p.fmt(f),
-            TryLockError::WouldBlock => {
-                "try_lock failed because the operation would block".fmt(f)
-            }
+            TryLockError::Poisoned(ref p) => Some(p),
+            _ => None
         }
     }
 }
diff --git a/src/libstd/sys/unix/backtrace.rs b/src/libstd/sys/unix/backtrace.rs
index 7164931c55a..70b9c012b00 100644
--- a/src/libstd/sys/unix/backtrace.rs
+++ b/src/libstd/sys/unix/backtrace.rs
@@ -229,7 +229,7 @@ fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void) -> IoResult<()> {
     }
 
     let mut info: Dl_info = unsafe { intrinsics::init() };
-    if unsafe { dladdr(addr as *const libc::c_void, &mut info) == 0 } {
+    if unsafe { dladdr(addr, &mut info) == 0 } {
         output(w, idx,addr, None)
     } else {
         output(w, idx, addr, Some(unsafe {
diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs
index 4540068133b..e9490dc95c9 100644
--- a/src/libstd/sys/windows/os.rs
+++ b/src/libstd/sys/windows/os.rs
@@ -281,7 +281,7 @@ pub fn join_paths<T: BytesContainer>(paths: &[T]) -> Result<Vec<u8>, &'static st
 pub fn load_self() -> Option<Vec<u8>> {
     unsafe {
         fill_utf16_buf_and_decode(|buf, sz| {
-            libc::GetModuleFileNameW(0u as libc::DWORD, buf, sz)
+            libc::GetModuleFileNameW(ptr::null_mut(), buf, sz)
         }).map(|s| s.to_string().into_bytes())
     }
 }
diff --git a/src/libstd/thread_local/mod.rs b/src/libstd/thread_local/mod.rs
index e7c4e4ccdfb..4c99cff34da 100644
--- a/src/libstd/thread_local/mod.rs
+++ b/src/libstd/thread_local/mod.rs
@@ -449,7 +449,7 @@ mod imp {
         // destructor as running for this thread so calls to `get` will return
         // `None`.
         *(*ptr).dtor_running.get() = true;
-        ptr::read((*ptr).inner.get() as *const T);
+        ptr::read((*ptr).inner.get());
     }
 }