diff options
| author | bors <bors@rust-lang.org> | 2015-01-20 23:03:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-20 23:03:09 +0000 |
| commit | 29bd9a06efd2f8c8a7b1102e2203cc0e6ae2dcba (patch) | |
| tree | 98824cc18b1c65ff09f383438d79ad2d0a0e2ea8 /src/libcore | |
| parent | 583c5c589ed02e5b6b14a576e35e0ce68988d949 (diff) | |
| parent | 631896dc1996d239a532b0ce02d5fe886660149e (diff) | |
| download | rust-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/libcore')
| -rw-r--r-- | src/libcore/array.rs | 7 | ||||
| -rw-r--r-- | src/libcore/atomic.rs | 12 | ||||
| -rw-r--r-- | src/libcore/ops.rs | 8 | ||||
| -rw-r--r-- | src/libcore/ptr.rs | 2 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 4 | ||||
| -rw-r--r-- | src/libcore/str/mod.rs | 21 |
6 files changed, 29 insertions, 25 deletions
diff --git a/src/libcore/array.rs b/src/libcore/array.rs index c07fac108d6..0cc31bf70de 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -17,6 +17,7 @@ use clone::Clone; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; use fmt; +use hash::{Hash, Hasher, self}; use marker::Copy; use ops::{Deref, FullRange}; use option::Option; @@ -32,6 +33,12 @@ macro_rules! array_impls { } } + impl<S: hash::Writer + Hasher, T: Hash<S>> Hash<S> for [T; $N] { + fn hash(&self, state: &mut S) { + Hash::hash(&self[], state) + } + } + #[unstable = "waiting for Show to stabilize"] impl<T:fmt::Show> fmt::Show for [T; $N] { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/libcore/atomic.rs b/src/libcore/atomic.rs index aa93d9ed837..18f7fff9053 100644 --- a/src/libcore/atomic.rs +++ b/src/libcore/atomic.rs @@ -199,7 +199,7 @@ impl AtomicBool { #[inline] #[stable] pub fn load(&self, order: Ordering) -> bool { - unsafe { atomic_load(self.v.get() as *const usize, order) > 0 } + unsafe { atomic_load(self.v.get(), order) > 0 } } /// Stores a value into the bool. @@ -438,7 +438,7 @@ impl AtomicIsize { /// ``` #[inline] pub fn load(&self, order: Ordering) -> isize { - unsafe { atomic_load(self.v.get() as *const isize, order) } + unsafe { atomic_load(self.v.get(), order) } } /// Stores a value into the isize. @@ -615,7 +615,7 @@ impl AtomicUsize { /// ``` #[inline] pub fn load(&self, order: Ordering) -> usize { - unsafe { atomic_load(self.v.get() as *const usize, order) } + unsafe { atomic_load(self.v.get(), order) } } /// Stores a value into the usize. @@ -796,7 +796,7 @@ impl<T> AtomicPtr<T> { #[stable] pub fn load(&self, order: Ordering) -> *mut T { unsafe { - atomic_load(self.p.get() as *const *mut T, order) as *mut T + atomic_load(self.p.get(), order) as *mut T } } @@ -1070,7 +1070,7 @@ impl AtomicInt { #[inline] pub fn load(&self, order: Ordering) -> int { - unsafe { atomic_load(self.v.get() as *const int, order) } + unsafe { atomic_load(self.v.get(), order) } } #[inline] @@ -1123,7 +1123,7 @@ impl AtomicUint { #[inline] pub fn load(&self, order: Ordering) -> uint { - unsafe { atomic_load(self.v.get() as *const uint, order) } + unsafe { atomic_load(self.v.get(), order) } } #[inline] diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index db7177e26fa..7131253d5c4 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -880,7 +880,7 @@ pub trait IndexMut<Index: ?Sized> { } /// An unbounded range. -#[derive(Copy, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq)] #[lang="full_range"] #[unstable = "API still in development"] pub struct FullRange; @@ -893,7 +893,7 @@ impl fmt::Show for FullRange { } /// A (half-open) range which is bounded at both ends. -#[derive(Copy, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq)] #[lang="range"] #[unstable = "API still in development"] pub struct Range<Idx> { @@ -952,7 +952,7 @@ impl<Idx: fmt::Show> fmt::Show for Range<Idx> { } /// A range which is only bounded below. -#[derive(Copy, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq)] #[lang="range_from"] #[unstable = "API still in development"] pub struct RangeFrom<Idx> { @@ -981,7 +981,7 @@ impl<Idx: fmt::Show> fmt::Show for RangeFrom<Idx> { } /// A range which is only bounded above. -#[derive(Copy, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq)] #[lang="range_to"] #[unstable = "API still in development"] pub struct RangeTo<Idx> { diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index baf998d0828..0b89467d63b 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -329,7 +329,7 @@ impl<T> PtrExt for *mut T { #[inline] #[stable] unsafe fn offset(self, count: int) -> *mut T { - intrinsics::offset(self as *const T, count) as *mut T + intrinsics::offset(self, count) as *mut T } #[inline] diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 22da168911d..50cbb7a61dc 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -741,7 +741,7 @@ macro_rules! make_slice { diff / mem::size_of::<$t>() }; unsafe { - transmute::<_, $result>(RawSlice { data: $start as *const T, len: len }) + transmute::<_, $result>(RawSlice { data: $start, len: len }) } }} } @@ -1409,7 +1409,7 @@ pub unsafe fn from_raw_buf<'a, T>(p: &'a *const T, len: uint) -> &'a [T] { #[inline] #[unstable = "should be renamed to from_raw_parts_mut"] pub unsafe fn from_raw_mut_buf<'a, T>(p: &'a *mut T, len: uint) -> &'a mut [T] { - transmute(RawSlice { data: *p as *const T, len: len }) + transmute(RawSlice { data: *p, len: len }) } // diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index d9cf6dc086d..6a542b2c458 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -678,18 +678,15 @@ struct TwoWaySearcher { */ impl TwoWaySearcher { fn new(needle: &[u8]) -> TwoWaySearcher { - let (crit_pos1, period1) = TwoWaySearcher::maximal_suffix(needle, false); - let (crit_pos2, period2) = TwoWaySearcher::maximal_suffix(needle, true); - - let crit_pos; - let period; - if crit_pos1 > crit_pos2 { - crit_pos = crit_pos1; - period = period1; - } else { - crit_pos = crit_pos2; - period = period2; - } + let (crit_pos_false, period_false) = TwoWaySearcher::maximal_suffix(needle, false); + let (crit_pos_true, period_true) = TwoWaySearcher::maximal_suffix(needle, true); + + let (crit_pos, period) = + if crit_pos_false > crit_pos_true { + (crit_pos_false, period_false) + } else { + (crit_pos_true, period_true) + }; // This isn't in the original algorithm, as far as I'm aware. let byteset = needle.iter() |
