diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-18 15:48:40 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-18 15:48:40 -0800 |
| commit | 231eeaa35b3a7700cfd05dcb30f01cd7a36313b8 (patch) | |
| tree | 83644afe1c67870e2f015abfc834307aa532dec7 /src/libcollections | |
| parent | 2cdbd288ac0606902885434e1ccd8d8bde68913d (diff) | |
| parent | 9ea84aeed4ed3006eddb6a7b24e9714f2844cd22 (diff) | |
| download | rust-231eeaa35b3a7700cfd05dcb30f01cd7a36313b8.tar.gz rust-231eeaa35b3a7700cfd05dcb30f01cd7a36313b8.zip | |
rollup merge of #22502: nikomatsakis/deprecate-bracket-bracket
Conflicts: src/libcollections/slice.rs src/libcollections/str.rs src/librustc/middle/lang_items.rs src/librustc_back/rpath.rs src/librustc_typeck/check/regionck.rs src/libstd/ffi/os_str.rs src/libsyntax/diagnostic.rs src/libsyntax/parse/parser.rs src/libsyntax/util/interner.rs src/test/run-pass/regions-refcell.rs
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/slice.rs | 20 | ||||
| -rw-r--r-- | src/libcollections/str.rs | 94 | ||||
| -rw-r--r-- | src/libcollections/string.rs | 10 | ||||
| -rw-r--r-- | src/libcollections/vec.rs | 2 |
4 files changed, 63 insertions, 63 deletions
diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index a0cb98267fa..0abe7f120ea 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1177,12 +1177,12 @@ impl ElementSwaps { #[stable(feature = "rust1", since = "1.0.0")] impl<T> Borrow<[T]> for Vec<T> { - fn borrow(&self) -> &[T] { &self[] } + fn borrow(&self) -> &[T] { &self[..] } } #[stable(feature = "rust1", since = "1.0.0")] impl<T> BorrowMut<[T]> for Vec<T> { - fn borrow_mut(&mut self) -> &mut [T] { &mut self[] } + fn borrow_mut(&mut self) -> &mut [T] { &mut self[..] } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1744,7 +1744,7 @@ mod tests { #[test] fn test_slice_from() { let vec: &[_] = &[1, 2, 3, 4]; - assert_eq!(&vec[], vec); + assert_eq!(&vec[..], vec); let b: &[_] = &[3, 4]; assert_eq!(&vec[2..], b); let b: &[_] = &[]; @@ -1997,9 +1997,9 @@ mod tests { #[test] fn test_lexicographic_permutations_empty_and_short() { - let empty : &mut[i32] = &mut[]; + let empty : &mut[i32] = &mut[..]; assert!(empty.next_permutation() == false); - let b: &mut[i32] = &mut[]; + let b: &mut[i32] = &mut[..]; assert!(empty == b); assert!(empty.prev_permutation() == false); assert!(empty == b); @@ -2265,15 +2265,15 @@ mod tests { #[test] fn test_total_ord() { let c = &[1, 2, 3]; - [1, 2, 3, 4][].cmp(c) == Greater; + [1, 2, 3, 4][..].cmp(c) == Greater; let c = &[1, 2, 3, 4]; - [1, 2, 3][].cmp(c) == Less; + [1, 2, 3][..].cmp(c) == Less; let c = &[1, 2, 3, 6]; - [1, 2, 3, 4][].cmp(c) == Equal; + [1, 2, 3, 4][..].cmp(c) == Equal; let c = &[1, 2, 3, 4, 5, 6]; - [1, 2, 3, 4, 5, 5, 5, 5][].cmp(c) == Less; + [1, 2, 3, 4, 5, 5, 5, 5][..].cmp(c) == Less; let c = &[1, 2, 3, 4]; - [2, 2][].cmp(c) == Greater; + [2, 2][..].cmp(c) == Greater; } #[test] diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index cdc503500d2..ec0a487acdc 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -388,7 +388,7 @@ macro_rules! utf8_acc_cont_byte { #[stable(feature = "rust1", since = "1.0.0")] impl Borrow<str> for String { - fn borrow(&self) -> &str { &self[] } + fn borrow(&self) -> &str { &self[..] } } #[stable(feature = "rust1", since = "1.0.0")] @@ -467,7 +467,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { reason = "this functionality may be moved to libunicode")] fn nfd_chars(&self) -> Decompositions { Decompositions { - iter: self[].chars(), + iter: self[..].chars(), buffer: Vec::new(), sorted: false, kind: Canonical @@ -481,7 +481,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { reason = "this functionality may be moved to libunicode")] fn nfkd_chars(&self) -> Decompositions { Decompositions { - iter: self[].chars(), + iter: self[..].chars(), buffer: Vec::new(), sorted: false, kind: Compatible @@ -531,7 +531,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn contains(&self, pat: &str) -> bool { - core_str::StrExt::contains(&self[], pat) + core_str::StrExt::contains(&self[..], pat) } /// Returns true if a string contains a char pattern. @@ -548,7 +548,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "might get removed in favour of a more generic contains()")] fn contains_char<P: CharEq>(&self, pat: P) -> bool { - core_str::StrExt::contains_char(&self[], pat) + core_str::StrExt::contains_char(&self[..], pat) } /// An iterator over the characters of `self`. Note, this iterates @@ -562,7 +562,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn chars(&self) -> Chars { - core_str::StrExt::chars(&self[]) + core_str::StrExt::chars(&self[..]) } /// An iterator over the bytes of `self` @@ -575,13 +575,13 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn bytes(&self) -> Bytes { - core_str::StrExt::bytes(&self[]) + core_str::StrExt::bytes(&self[..]) } /// An iterator over the characters of `self` and their byte offsets. #[stable(feature = "rust1", since = "1.0.0")] fn char_indices(&self) -> CharIndices { - core_str::StrExt::char_indices(&self[]) + core_str::StrExt::char_indices(&self[..]) } /// An iterator over substrings of `self`, separated by characters @@ -604,7 +604,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn split<P: CharEq>(&self, pat: P) -> Split<P> { - core_str::StrExt::split(&self[], pat) + core_str::StrExt::split(&self[..], pat) } /// An iterator over substrings of `self`, separated by characters @@ -631,7 +631,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn splitn<P: CharEq>(&self, count: usize, pat: P) -> SplitN<P> { - core_str::StrExt::splitn(&self[], count, pat) + core_str::StrExt::splitn(&self[..], count, pat) } /// An iterator over substrings of `self`, separated by characters @@ -660,7 +660,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[unstable(feature = "collections", reason = "might get removed")] fn split_terminator<P: CharEq>(&self, pat: P) -> SplitTerminator<P> { - core_str::StrExt::split_terminator(&self[], pat) + core_str::StrExt::split_terminator(&self[..], pat) } /// An iterator over substrings of `self`, separated by characters @@ -681,7 +681,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn rsplitn<P: CharEq>(&self, count: usize, pat: P) -> RSplitN<P> { - core_str::StrExt::rsplitn(&self[], count, pat) + core_str::StrExt::rsplitn(&self[..], count, pat) } /// An iterator over the start and end indices of the disjoint @@ -707,7 +707,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "might have its iterator type changed")] fn match_indices<'a>(&'a self, pat: &'a str) -> MatchIndices<'a> { - core_str::StrExt::match_indices(&self[], pat) + core_str::StrExt::match_indices(&self[..], pat) } /// An iterator over the substrings of `self` separated by the pattern `sep`. @@ -724,7 +724,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "might get removed in the future in favor of a more generic split()")] fn split_str<'a>(&'a self, pat: &'a str) -> SplitStr<'a> { - core_str::StrExt::split_str(&self[], pat) + core_str::StrExt::split_str(&self[..], pat) } /// An iterator over the lines of a string (subsequences separated @@ -740,7 +740,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn lines(&self) -> Lines { - core_str::StrExt::lines(&self[]) + core_str::StrExt::lines(&self[..]) } /// An iterator over the lines of a string, separated by either @@ -756,7 +756,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn lines_any(&self) -> LinesAny { - core_str::StrExt::lines_any(&self[]) + core_str::StrExt::lines_any(&self[..]) } /// Deprecated: use `s[a .. b]` instead. @@ -803,7 +803,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "may have yet to prove its worth")] fn slice_chars(&self, begin: usize, end: usize) -> &str { - core_str::StrExt::slice_chars(&self[], begin, end) + core_str::StrExt::slice_chars(&self[..], begin, end) } /// Takes a bytewise (not UTF-8) slice from a string. @@ -814,7 +814,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// the entire slice as well. #[stable(feature = "rust1", since = "1.0.0")] unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str { - core_str::StrExt::slice_unchecked(&self[], begin, end) + core_str::StrExt::slice_unchecked(&self[..], begin, end) } /// Returns true if the pattern `pat` is a prefix of the string. @@ -826,7 +826,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn starts_with(&self, pat: &str) -> bool { - core_str::StrExt::starts_with(&self[], pat) + core_str::StrExt::starts_with(&self[..], pat) } /// Returns true if the pattern `pat` is a suffix of the string. @@ -838,7 +838,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn ends_with(&self, pat: &str) -> bool { - core_str::StrExt::ends_with(&self[], pat) + core_str::StrExt::ends_with(&self[..], pat) } /// Returns a string with all pre- and suffixes that match @@ -858,7 +858,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn trim_matches<P: CharEq>(&self, pat: P) -> &str { - core_str::StrExt::trim_matches(&self[], pat) + core_str::StrExt::trim_matches(&self[..], pat) } /// Returns a string with all prefixes that match @@ -878,7 +878,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn trim_left_matches<P: CharEq>(&self, pat: P) -> &str { - core_str::StrExt::trim_left_matches(&self[], pat) + core_str::StrExt::trim_left_matches(&self[..], pat) } /// Returns a string with all suffixes that match @@ -898,7 +898,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn trim_right_matches<P: CharEq>(&self, pat: P) -> &str { - core_str::StrExt::trim_right_matches(&self[], pat) + core_str::StrExt::trim_right_matches(&self[..], pat) } /// Check that `index`-th byte lies at the start and/or end of a @@ -927,7 +927,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "naming is uncertain with container conventions")] fn is_char_boundary(&self, index: usize) -> bool { - core_str::StrExt::is_char_boundary(&self[], index) + core_str::StrExt::is_char_boundary(&self[..], index) } /// Pluck a character out of a string and return the index of the next @@ -986,7 +986,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "naming is uncertain with container conventions")] fn char_range_at(&self, start: usize) -> CharRange { - core_str::StrExt::char_range_at(&self[], start) + core_str::StrExt::char_range_at(&self[..], start) } /// Given a byte position and a str, return the previous char and its position. @@ -1002,7 +1002,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "naming is uncertain with container conventions")] fn char_range_at_reverse(&self, start: usize) -> CharRange { - core_str::StrExt::char_range_at_reverse(&self[], start) + core_str::StrExt::char_range_at_reverse(&self[..], start) } /// Plucks the character starting at the `i`th byte of a string. @@ -1023,7 +1023,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "naming is uncertain with container conventions")] fn char_at(&self, i: usize) -> char { - core_str::StrExt::char_at(&self[], i) + core_str::StrExt::char_at(&self[..], i) } /// Plucks the character ending at the `i`th byte of a string. @@ -1035,7 +1035,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "naming is uncertain with container conventions")] fn char_at_reverse(&self, i: usize) -> char { - core_str::StrExt::char_at_reverse(&self[], i) + core_str::StrExt::char_at_reverse(&self[..], i) } /// Work with the byte buffer of a string as a byte slice. @@ -1047,7 +1047,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn as_bytes(&self) -> &[u8] { - core_str::StrExt::as_bytes(&self[]) + core_str::StrExt::as_bytes(&self[..]) } /// Returns the byte index of the first character of `self` that @@ -1075,7 +1075,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn find<P: CharEq>(&self, pat: P) -> Option<usize> { - core_str::StrExt::find(&self[], pat) + core_str::StrExt::find(&self[..], pat) } /// Returns the byte index of the last character of `self` that @@ -1103,7 +1103,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn rfind<P: CharEq>(&self, pat: P) -> Option<usize> { - core_str::StrExt::rfind(&self[], pat) + core_str::StrExt::rfind(&self[..], pat) } /// Returns the byte index of the first matching substring @@ -1128,7 +1128,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "might get removed in favor of a more generic find in the future")] fn find_str(&self, needle: &str) -> Option<usize> { - core_str::StrExt::find_str(&self[], needle) + core_str::StrExt::find_str(&self[..], needle) } /// Retrieves the first character from a string slice and returns @@ -1152,7 +1152,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "awaiting conventions about shifting and slices")] fn slice_shift_char(&self) -> Option<(char, &str)> { - core_str::StrExt::slice_shift_char(&self[]) + core_str::StrExt::slice_shift_char(&self[..]) } /// Returns the byte offset of an inner slice relative to an enclosing outer slice. @@ -1172,7 +1172,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "awaiting convention about comparability of arbitrary slices")] fn subslice_offset(&self, inner: &str) -> usize { - core_str::StrExt::subslice_offset(&self[], inner) + core_str::StrExt::subslice_offset(&self[..], inner) } /// Return an unsafe pointer to the strings buffer. @@ -1183,14 +1183,14 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[stable(feature = "rust1", since = "1.0.0")] #[inline] fn as_ptr(&self) -> *const u8 { - core_str::StrExt::as_ptr(&self[]) + core_str::StrExt::as_ptr(&self[..]) } /// Return an iterator of `u16` over the string encoded as UTF-16. #[unstable(feature = "collections", reason = "this functionality may only be provided by libunicode")] fn utf16_units(&self) -> Utf16Units { - Utf16Units { encoder: Utf16Encoder::new(self[].chars()) } + Utf16Units { encoder: Utf16Encoder::new(self[..].chars()) } } /// Return the number of bytes in this string @@ -1204,7 +1204,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[stable(feature = "rust1", since = "1.0.0")] #[inline] fn len(&self) -> usize { - core_str::StrExt::len(&self[]) + core_str::StrExt::len(&self[..]) } /// Returns true if this slice contains no bytes @@ -1217,7 +1217,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn is_empty(&self) -> bool { - core_str::StrExt::is_empty(&self[]) + core_str::StrExt::is_empty(&self[..]) } /// Parse this string into the specified type. @@ -1231,7 +1231,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn parse<F: FromStr>(&self) -> Result<F, F::Err> { - core_str::StrExt::parse(&self[]) + core_str::StrExt::parse(&self[..]) } /// Returns an iterator over the @@ -1256,7 +1256,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "this functionality may only be provided by libunicode")] fn graphemes(&self, is_extended: bool) -> Graphemes { - UnicodeStr::graphemes(&self[], is_extended) + UnicodeStr::graphemes(&self[..], is_extended) } /// Returns an iterator over the grapheme clusters of self and their byte offsets. @@ -1272,7 +1272,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "this functionality may only be provided by libunicode")] fn grapheme_indices(&self, is_extended: bool) -> GraphemeIndices { - UnicodeStr::grapheme_indices(&self[], is_extended) + UnicodeStr::grapheme_indices(&self[..], is_extended) } /// An iterator over the words of a string (subsequences separated @@ -1289,7 +1289,7 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "str_words", reason = "the precise algorithm to use is unclear")] fn words(&self) -> Words { - UnicodeStr::words(&self[]) + UnicodeStr::words(&self[..]) } /// Returns a string's displayed width in columns, treating control @@ -1304,25 +1304,25 @@ pub trait StrExt: Index<RangeFull, Output = str> { #[unstable(feature = "collections", reason = "this functionality may only be provided by libunicode")] fn width(&self, is_cjk: bool) -> usize { - UnicodeStr::width(&self[], is_cjk) + UnicodeStr::width(&self[..], is_cjk) } /// Returns a string with leading and trailing whitespace removed. #[stable(feature = "rust1", since = "1.0.0")] fn trim(&self) -> &str { - UnicodeStr::trim(&self[]) + UnicodeStr::trim(&self[..]) } /// Returns a string with leading whitespace removed. #[stable(feature = "rust1", since = "1.0.0")] fn trim_left(&self) -> &str { - UnicodeStr::trim_left(&self[]) + UnicodeStr::trim_left(&self[..]) } /// Returns a string with trailing whitespace removed. #[stable(feature = "rust1", since = "1.0.0")] fn trim_right(&self) -> &str { - UnicodeStr::trim_right(&self[]) + UnicodeStr::trim_right(&self[..]) } } @@ -2705,7 +2705,7 @@ mod tests { &["\u{378}\u{308}\u{903}"], &["\u{378}\u{308}", "\u{903}"]), ]; - for &(s, g) in &test_same[] { + for &(s, g) in &test_same[..] { // test forward iterator assert!(order::equals(s.graphemes(true), g.iter().cloned())); assert!(order::equals(s.graphemes(false), g.iter().cloned())); diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 5e48336dfad..3b179d0b94c 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -868,7 +868,7 @@ impl ops::Index<ops::Range<usize>> for String { type Output = str; #[inline] fn index(&self, index: &ops::Range<usize>) -> &str { - &self[][*index] + &self[..][*index] } } #[stable(feature = "rust1", since = "1.0.0")] @@ -876,7 +876,7 @@ impl ops::Index<ops::RangeTo<usize>> for String { type Output = str; #[inline] fn index(&self, index: &ops::RangeTo<usize>) -> &str { - &self[][*index] + &self[..][*index] } } #[stable(feature = "rust1", since = "1.0.0")] @@ -884,7 +884,7 @@ impl ops::Index<ops::RangeFrom<usize>> for String { type Output = str; #[inline] fn index(&self, index: &ops::RangeFrom<usize>) -> &str { - &self[][*index] + &self[..][*index] } } #[stable(feature = "rust1", since = "1.0.0")] @@ -902,7 +902,7 @@ impl ops::Deref for String { #[inline] fn deref(&self) -> &str { - unsafe { mem::transmute(&self.vec[]) } + unsafe { mem::transmute(&self.vec[..]) } } } @@ -1301,7 +1301,7 @@ mod tests { #[test] fn test_slicing() { let s = "foobar".to_string(); - assert_eq!("foobar", &s[]); + assert_eq!("foobar", &s[..]); assert_eq!("foo", &s[..3]); assert_eq!("bar", &s[3..]); assert_eq!("oob", &s[1..4]); diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index e303d776003..1adcb77e0b6 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -2605,7 +2605,7 @@ mod tests { b.bytes = src_len as u64; b.iter(|| { - let dst = src.clone()[].to_vec(); + let dst = src.clone()[..].to_vec(); assert_eq!(dst.len(), src_len); assert!(dst.iter().enumerate().all(|(i, x)| i == *x)); }); |
