diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/sync/mutex.rs | 23 | ||||
| -rw-r--r-- | src/libstd/sync/rwlock.rs | 23 | ||||
| -rw-r--r-- | src/libstd/sys/common/wtf8.rs | 32 |
3 files changed, 23 insertions, 55 deletions
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 846a97b547d..f1d264b38a0 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -536,16 +536,15 @@ mod tests { assert_eq!(*lock, 2); } - // FIXME(#25351) needs deeply nested coercions of DST structs. - // #[test] - // fn test_mutex_unsized() { - // let mutex: &Mutex<[i32]> = &Mutex::new([1, 2, 3]); - // { - // let b = &mut *mutex.lock().unwrap(); - // b[0] = 4; - // b[2] = 5; - // } - // let comp: &[i32] = &[4, 2, 5]; - // assert_eq!(&*mutex.lock().unwrap(), comp); - // } + #[test] + fn test_mutex_unsized() { + let mutex: &Mutex<[i32]> = &Mutex::new([1, 2, 3]); + { + let b = &mut *mutex.lock().unwrap(); + b[0] = 4; + b[2] = 5; + } + let comp: &[i32] = &[4, 2, 5]; + assert_eq!(&*mutex.lock().unwrap(), comp); + } } diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 7210328fad8..04ad4708246 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -578,18 +578,17 @@ mod tests { assert_eq!(*lock, 2); } - // FIXME(#25351) needs deeply nested coercions of DST structs. - // #[test] - // fn test_rwlock_unsized() { - // let rw: &RwLock<[i32]> = &RwLock::new([1, 2, 3]); - // { - // let b = &mut *rw.write().unwrap(); - // b[0] = 4; - // b[2] = 5; - // } - // let comp: &[i32] = &[4, 2, 5]; - // assert_eq!(&*rw.read().unwrap(), comp); - // } + #[test] + fn test_rwlock_unsized() { + let rw: &RwLock<[i32]> = &RwLock::new([1, 2, 3]); + { + let b = &mut *rw.write().unwrap(); + b[0] = 4; + b[2] = 5; + } + let comp: &[i32] = &[4, 2, 5]; + assert_eq!(&*rw.read().unwrap(), comp); + } #[test] fn test_rwlock_try_write() { diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 633e7d78a9a..10f77d0207c 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -31,7 +31,6 @@ use core::str::next_code_point; use ascii::*; use borrow::Cow; use char; -use cmp; use fmt; use hash::{Hash, Hasher}; use iter::FromIterator; @@ -375,6 +374,7 @@ impl Extend<CodePoint> for Wtf8Buf { /// /// Similar to `&str`, but can additionally contain surrogate code points /// if they’re not in a surrogate pair. +#[derive(Eq, Ord, PartialEq, PartialOrd)] pub struct Wtf8 { bytes: [u8] } @@ -383,36 +383,6 @@ impl AsInner<[u8]> for Wtf8 { fn as_inner(&self) -> &[u8] { &self.bytes } } -// FIXME: https://github.com/rust-lang/rust/issues/18805 -impl PartialEq for Wtf8 { - fn eq(&self, other: &Wtf8) -> bool { self.bytes.eq(&other.bytes) } -} - -// FIXME: https://github.com/rust-lang/rust/issues/18805 -impl Eq for Wtf8 {} - -// FIXME: https://github.com/rust-lang/rust/issues/18738 -impl PartialOrd for Wtf8 { - #[inline] - fn partial_cmp(&self, other: &Wtf8) -> Option<cmp::Ordering> { - self.bytes.partial_cmp(&other.bytes) - } - #[inline] - fn lt(&self, other: &Wtf8) -> bool { self.bytes.lt(&other.bytes) } - #[inline] - fn le(&self, other: &Wtf8) -> bool { self.bytes.le(&other.bytes) } - #[inline] - fn gt(&self, other: &Wtf8) -> bool { self.bytes.gt(&other.bytes) } - #[inline] - fn ge(&self, other: &Wtf8) -> bool { self.bytes.ge(&other.bytes) } -} - -// FIXME: https://github.com/rust-lang/rust/issues/18738 -impl Ord for Wtf8 { - #[inline] - fn cmp(&self, other: &Wtf8) -> cmp::Ordering { self.bytes.cmp(&other.bytes) } -} - /// Format the slice with double quotes, /// and surrogates as `\u` followed by four hexadecimal digits. /// Example: `"a\u{D800}"` for a slice with code points [U+0061, U+D800] |
