diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-01-07 17:26:58 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-07 17:26:58 -0800 |
| commit | 6e806bdefde91af102567ef4b5dbd3ccf0c5c2ec (patch) | |
| tree | b8627ad2c80976f618b661ec14695f6a322ad1b3 /src/libcore | |
| parent | f6a7dc5528a9a9ac36867bbca2a6044b7be5bce2 (diff) | |
| parent | 7d72719efc25c6cdb8963c187e93df646ba65245 (diff) | |
| download | rust-6e806bdefde91af102567ef4b5dbd3ccf0c5c2ec.tar.gz rust-6e806bdefde91af102567ef4b5dbd3ccf0c5c2ec.zip | |
rollup merge of #20721: japaric/snap
Conflicts: src/libcollections/vec.rs src/libcore/fmt/mod.rs src/librustc/lint/builtin.rs src/librustc/session/config.rs src/librustc_trans/trans/base.rs src/librustc_trans/trans/context.rs src/librustc_trans/trans/type_.rs src/librustc_typeck/check/_match.rs src/librustdoc/html/format.rs src/libsyntax/std_inject.rs src/libsyntax/util/interner.rs src/test/compile-fail/mut-pattern-mismatched.rs
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/array.rs | 28 | ||||
| -rw-r--r-- | src/libcore/fmt/float.rs | 4 | ||||
| -rw-r--r-- | src/libcore/fmt/mod.rs | 8 | ||||
| -rw-r--r-- | src/libcore/fmt/num.rs | 3 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/mod.rs | 4 | ||||
| -rw-r--r-- | src/libcore/option.rs | 2 | ||||
| -rw-r--r-- | src/libcore/result.rs | 6 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 24 | ||||
| -rw-r--r-- | src/libcore/str/mod.rs | 12 |
10 files changed, 46 insertions, 47 deletions
diff --git a/src/libcore/array.rs b/src/libcore/array.rs index 05db9e11760..0cea0b3d88e 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -18,7 +18,7 @@ use clone::Clone; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; use fmt; use marker::Copy; -use ops::{Deref, FullRange, Index}; +use ops::{Deref, FullRange}; use option::Option; // macro for implementing n-ary tuple functions and operations @@ -35,7 +35,7 @@ macro_rules! array_impls { #[unstable = "waiting for Show to stabilize"] impl<T:fmt::Show> fmt::Show for [T; $N] { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Show::fmt(&self.index(&FullRange), f) + fmt::Show::fmt(&&self[], f) } } @@ -43,11 +43,11 @@ macro_rules! array_impls { impl<A, B> PartialEq<[B; $N]> for [A; $N] where A: PartialEq<B> { #[inline] fn eq(&self, other: &[B; $N]) -> bool { - self.index(&FullRange) == other.index(&FullRange) + &self[] == &other[] } #[inline] fn ne(&self, other: &[B; $N]) -> bool { - self.index(&FullRange) != other.index(&FullRange) + &self[] != &other[] } } @@ -58,11 +58,11 @@ macro_rules! array_impls { { #[inline(always)] fn eq(&self, other: &Rhs) -> bool { - PartialEq::eq(self.index(&FullRange), &**other) + PartialEq::eq(&self[], &**other) } #[inline(always)] fn ne(&self, other: &Rhs) -> bool { - PartialEq::ne(self.index(&FullRange), &**other) + PartialEq::ne(&self[], &**other) } } @@ -73,11 +73,11 @@ macro_rules! array_impls { { #[inline(always)] fn eq(&self, other: &[B; $N]) -> bool { - PartialEq::eq(&**self, other.index(&FullRange)) + PartialEq::eq(&**self, &other[]) } #[inline(always)] fn ne(&self, other: &[B; $N]) -> bool { - PartialEq::ne(&**self, other.index(&FullRange)) + PartialEq::ne(&**self, &other[]) } } @@ -88,23 +88,23 @@ macro_rules! array_impls { impl<T:PartialOrd> PartialOrd for [T; $N] { #[inline] fn partial_cmp(&self, other: &[T; $N]) -> Option<Ordering> { - PartialOrd::partial_cmp(&self.index(&FullRange), &other.index(&FullRange)) + PartialOrd::partial_cmp(&&self[], &&other[]) } #[inline] fn lt(&self, other: &[T; $N]) -> bool { - PartialOrd::lt(&self.index(&FullRange), &other.index(&FullRange)) + PartialOrd::lt(&&self[], &&other[]) } #[inline] fn le(&self, other: &[T; $N]) -> bool { - PartialOrd::le(&self.index(&FullRange), &other.index(&FullRange)) + PartialOrd::le(&&self[], &&other[]) } #[inline] fn ge(&self, other: &[T; $N]) -> bool { - PartialOrd::ge(&self.index(&FullRange), &other.index(&FullRange)) + PartialOrd::ge(&&self[], &&other[]) } #[inline] fn gt(&self, other: &[T; $N]) -> bool { - PartialOrd::gt(&self.index(&FullRange), &other.index(&FullRange)) + PartialOrd::gt(&&self[], &&other[]) } } @@ -112,7 +112,7 @@ macro_rules! array_impls { impl<T:Ord> Ord for [T; $N] { #[inline] fn cmp(&self, other: &[T; $N]) -> Ordering { - Ord::cmp(&self.index(&FullRange), &other.index(&FullRange)) + Ord::cmp(&&self[], &&other[]) } } )+ diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index d833b8fed77..0ffcb014c28 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -20,7 +20,7 @@ use fmt; use iter::{IteratorExt, range}; use num::{cast, Float, ToPrimitive}; use num::FpCategory as Fp; -use ops::{FnOnce, Index}; +use ops::FnOnce; use result::Result::Ok; use slice::{self, SliceExt}; use str::{self, StrExt}; @@ -332,5 +332,5 @@ pub fn float_to_str_bytes_common<T: Float, U, F>( } } - f(unsafe { str::from_utf8_unchecked(buf.index(&(0..end))) }) + f(unsafe { str::from_utf8_unchecked(&buf[0..end]) }) } diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index a9da1903d69..69df413a88c 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -21,7 +21,7 @@ use mem; use option::Option; use option::Option::{Some, None}; use result::Result::Ok; -use ops::{Deref, FnOnce, Index}; +use ops::{Deref, FnOnce}; use result; use slice::SliceExt; use slice; @@ -425,7 +425,7 @@ impl<'a> Formatter<'a> { for c in sign.into_iter() { let mut b = [0; 4]; let n = c.encode_utf8(&mut b).unwrap_or(0); - let b = unsafe { str::from_utf8_unchecked(b.index(&(0..n))) }; + let b = unsafe { str::from_utf8_unchecked(&b[0..n]) }; try!(f.buf.write_str(b)); } if prefixed { f.buf.write_str(prefix) } @@ -533,7 +533,7 @@ impl<'a> Formatter<'a> { let mut fill = [0u8; 4]; let len = self.fill.encode_utf8(&mut fill).unwrap_or(0); - let fill = unsafe { str::from_utf8_unchecked(fill.index(&(..len))) }; + let fill = unsafe { str::from_utf8_unchecked(&fill[..len]) }; for _ in range(0, pre_pad) { try!(self.buf.write_str(fill)); @@ -668,7 +668,7 @@ impl String for char { fn fmt(&self, f: &mut Formatter) -> Result { let mut utf8 = [0u8; 4]; let amt = self.encode_utf8(&mut utf8).unwrap_or(0); - let s: &str = unsafe { mem::transmute(utf8.index(&(0..amt))) }; + let s: &str = unsafe { mem::transmute(&utf8[0..amt]) }; String::fmt(s, f) } } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 905001cd567..1df6f845225 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -16,7 +16,6 @@ use fmt; use iter::IteratorExt; -use ops::Index; use num::{Int, cast}; use slice::SliceExt; use str; @@ -62,7 +61,7 @@ trait GenericRadix { if x == zero { break }; // No more digits left to accumulate. } } - let buf = unsafe { str::from_utf8_unchecked(buf.index(&(curr..))) }; + let buf = unsafe { str::from_utf8_unchecked(&buf[curr..]) }; f.pad_integral(is_positive, self.prefix(), buf) } } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index f0f4a191e4f..eae466266d6 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -2344,7 +2344,7 @@ impl<A, I, F> RandomAccessIterator for Inspect<A, I, F> where /// /// // This iterator will yield up to the last Fibonacci number before the max value of `u32`. /// // You can simply change `u32` to `u64` in this line if you want higher values than that. -/// let mut fibonacci = Unfold::new((Some(0u32), Some(1u32)), |&(ref mut x2, ref mut x1)| { +/// let mut fibonacci = Unfold::new((Some(0u32), Some(1u32)), |&mut (ref mut x2, ref mut x1)| { /// // Attempt to get the next Fibonacci number /// // `x1` will be `None` if previously overflowed. /// let next = match (*x2, *x1) { diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 47da5de5391..91fed8a31bd 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -24,7 +24,7 @@ use iter::IteratorExt; use marker::Copy; use mem::size_of; use ops::{Add, Sub, Mul, Div, Rem, Neg}; -use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr, Index}; +use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr}; use option::Option; use option::Option::{Some, None}; use str::{FromStr, StrExt}; @@ -1577,7 +1577,7 @@ macro_rules! from_str_radix_float_impl { }; // Parse the exponent as decimal integer - let src = src.index(&(offset..)); + let src = &src[offset..]; let (is_positive, exp) = match src.slice_shift_char() { Some(('-', src)) => (false, src.parse::<uint>()), Some(('+', src)) => (true, src.parse::<uint>()), diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 56e27e801af..24a20fbc066 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -534,7 +534,7 @@ impl<T> Option<T> { /// ``` /// let mut x = Some(4u); /// match x.iter_mut().next() { - /// Some(&ref mut v) => *v = 42u, + /// Some(&mut ref mut v) => *v = 42u, /// None => {}, /// } /// assert_eq!(x, Some(42)); diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 95ae6ebfb68..7868ec67c8a 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -383,8 +383,8 @@ impl<T, E> Result<T, E> { /// ``` /// fn mutate(r: &mut Result<int, int>) { /// match r.as_mut() { - /// Ok(&ref mut v) => *v = 42, - /// Err(&ref mut e) => *e = 0, + /// Ok(&mut ref mut v) => *v = 42, + /// Err(&mut ref mut e) => *e = 0, /// } /// } /// @@ -529,7 +529,7 @@ impl<T, E> Result<T, E> { /// ``` /// let mut x: Result<uint, &str> = Ok(7); /// match x.iter_mut().next() { - /// Some(&ref mut x) => *x = 40, + /// Some(&mut ref mut x) => *x = 40, /// None => {}, /// } /// assert_eq!(x, Ok(40)); diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index bf2df465370..6c62bfda1fe 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -159,7 +159,7 @@ impl<T> SliceExt for [T] { #[inline] fn split_at(&self, mid: uint) -> (&[T], &[T]) { - (self.index(&(0..mid)), self.index(&(mid..))) + (&self[0..mid], &self[mid..]) } #[inline] @@ -236,11 +236,11 @@ impl<T> SliceExt for [T] { } #[inline] - fn tail(&self) -> &[T] { self.index(&(1..)) } + fn tail(&self) -> &[T] { &self[1..] } #[inline] fn init(&self) -> &[T] { - self.index(&(0..(self.len() - 1))) + &self[0..(self.len() - 1)] } #[inline] @@ -443,13 +443,13 @@ impl<T> SliceExt for [T] { #[inline] fn starts_with(&self, needle: &[T]) -> bool where T: PartialEq { let n = needle.len(); - self.len() >= n && needle == self.index(&(0..n)) + self.len() >= n && needle == &self[0..n] } #[inline] fn ends_with(&self, needle: &[T]) -> bool where T: PartialEq { let (m, n) = (self.len(), needle.len()); - m >= n && needle == self.index(&((m-n)..)) + m >= n && needle == &self[(m-n)..] } #[unstable] @@ -972,8 +972,8 @@ impl<'a, T, P> Iterator for Split<'a, T, P> where P: FnMut(&T) -> bool { match self.v.iter().position(|x| (self.pred)(x)) { None => self.finish(), Some(idx) => { - let ret = Some(self.v.index(&(0..idx))); - self.v = self.v.index(&((idx + 1)..)); + let ret = Some(&self.v[0..idx]); + self.v = &self.v[(idx + 1)..]; ret } } @@ -998,8 +998,8 @@ impl<'a, T, P> DoubleEndedIterator for Split<'a, T, P> where P: FnMut(&T) -> boo match self.v.iter().rposition(|x| (self.pred)(x)) { None => self.finish(), Some(idx) => { - let ret = Some(self.v.index(&((idx + 1)..))); - self.v = self.v.index(&(0..idx)); + let ret = Some(&self.v[(idx + 1)..]); + self.v = &self.v[0..idx]; ret } } @@ -1195,8 +1195,8 @@ impl<'a, T> Iterator for Windows<'a, T> { if self.size > self.v.len() { None } else { - let ret = Some(self.v.index(&(0..self.size))); - self.v = self.v.index(&(1..)); + let ret = Some(&self.v[0..self.size]); + self.v = &self.v[1..]; ret } } @@ -1283,7 +1283,7 @@ impl<'a, T> RandomAccessIterator for Chunks<'a, T> { let mut hi = lo + self.size; if hi < lo || hi > self.v.len() { hi = self.v.len(); } - Some(self.v.index(&(lo..hi))) + Some(&self.v[lo..hi]) } else { None } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 3f8ce000e21..6051c68b116 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -26,7 +26,7 @@ use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator}; use marker::Sized; use mem; use num::Int; -use ops::{Fn, FnMut, Index}; +use ops::{Fn, FnMut}; use option::Option::{self, None, Some}; use ptr::PtrExt; use raw::{Repr, Slice}; @@ -580,7 +580,7 @@ impl NaiveSearcher { fn next(&mut self, haystack: &[u8], needle: &[u8]) -> Option<(uint, uint)> { while self.position + needle.len() <= haystack.len() { - if haystack.index(&(self.position .. self.position + needle.len())) == needle { + if &haystack[self.position .. self.position + needle.len()] == needle { let match_pos = self.position; self.position += needle.len(); // add 1 for all matches return Some((match_pos, match_pos + needle.len())); @@ -701,10 +701,10 @@ impl TwoWaySearcher { // // What's going on is we have some critical factorization (u, v) of the // needle, and we want to determine whether u is a suffix of - // v.index(&(0..period)). If it is, we use "Algorithm CP1". Otherwise we use + // &v[0..period]. If it is, we use "Algorithm CP1". Otherwise we use // "Algorithm CP2", which is optimized for when the period of the needle // is large. - if needle.index(&(0..crit_pos)) == needle.index(&(period.. period + crit_pos)) { + if &needle[0..crit_pos] == &needle[period.. period + crit_pos] { TwoWaySearcher { crit_pos: crit_pos, period: period, @@ -1412,13 +1412,13 @@ impl StrExt for str { #[inline] fn starts_with(&self, needle: &str) -> bool { let n = needle.len(); - self.len() >= n && needle.as_bytes() == self.as_bytes().index(&(0..n)) + self.len() >= n && needle.as_bytes() == &self.as_bytes()[0..n] } #[inline] fn ends_with(&self, needle: &str) -> bool { let (m, n) = (self.len(), needle.len()); - m >= n && needle.as_bytes() == self.as_bytes().index(&((m-n)..)) + m >= n && needle.as_bytes() == &self.as_bytes()[(m-n)..] } #[inline] |
