Skip to content

Commit 0c7f7a5

Browse files
committed
fallout
1 parent 791f545 commit 0c7f7a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+498
-423
lines changed

src/compiletest/runtest.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -539,18 +539,17 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
539539
script_str.push_str("set print pretty off\n");
540540

541541
// Add the pretty printer directory to GDB's source-file search path
542-
script_str.push_str(format!("directory {}\n", rust_pp_module_abs_path)[]);
542+
script_str.push_str(&format!("directory {}\n", rust_pp_module_abs_path)[]);
543543

544544
// Load the target executable
545-
script_str.push_str(format!("file {}\n",
546-
exe_file.as_str().unwrap().replace("\\", "\\\\"))
547-
.as_slice());
545+
script_str.push_str(&format!("file {}\n",
546+
exe_file.as_str().unwrap().replace("\\", "\\\\"))[]);
548547

549548
// Add line breakpoints
550549
for line in breakpoint_lines.iter() {
551-
script_str.push_str(format!("break '{}':{}\n",
552-
testfile.filename_display(),
553-
*line)[]);
550+
script_str.push_str(&format!("break '{}':{}\n",
551+
testfile.filename_display(),
552+
*line)[]);
554553
}
555554

556555
script_str.push_str(cmds.as_slice());
@@ -676,7 +675,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
676675
.unwrap()
677676
.to_string();
678677

679-
script_str.push_str(format!("command script import {}\n", rust_pp_module_abs_path.index(&FullRange))[]);
678+
script_str.push_str(&format!("command script import {}\n", &rust_pp_module_abs_path[])[]);
680679
script_str.push_str("type summary add --no-value ");
681680
script_str.push_str("--python-function lldb_rust_formatters.print_val ");
682681
script_str.push_str("-x \".*\" --category Rust\n");

src/libcollections/ring_buf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ impl<T> RingBuf<T> {
525525
/// *num = *num - 2;
526526
/// }
527527
/// let b: &[_] = &[&mut 3, &mut 1, &mut 2];
528-
/// assert_eq!(buf.iter_mut().collect::<Vec<&mut int>>()[], b);
528+
/// assert_eq!(&buf.iter_mut().collect::<Vec<&mut int>>()[], b);
529529
/// ```
530530
#[stable]
531531
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {

src/libcollections/slice.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,15 +1393,20 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Order
13931393

13941394
#[cfg(test)]
13951395
mod tests {
1396-
use prelude::{Some, None, range, Vec, ToString, Clone, Greater, Less, Equal};
1397-
use prelude::{SliceExt, Iterator, IteratorExt};
1398-
use prelude::AsSlice;
1399-
use prelude::{RandomAccessIterator, Ord, SliceConcatExt};
1396+
use core::cmp::Ordering::{Greater, Less, Equal};
1397+
use core::prelude::{Some, None, range, Clone};
1398+
use core::prelude::{Iterator, IteratorExt};
1399+
use core::prelude::{AsSlice};
1400+
use core::prelude::{Ord, FullRange};
14001401
use core::default::Default;
14011402
use core::mem;
1403+
use core::ops::Index;
1404+
use std::iter::RandomAccessIterator;
14021405
use std::rand::{Rng, thread_rng};
14031406
use std::rc::Rc;
1404-
use super::ElementSwaps;
1407+
use string::ToString;
1408+
use vec::Vec;
1409+
use super::{ElementSwaps, SliceConcatExt, SliceExt};
14051410

14061411
fn square(n: uint) -> uint { n * n }
14071412

src/libcollections/str.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use core::char::CharExt;
6060
use core::clone::Clone;
6161
use core::iter::AdditiveIterator;
6262
use core::iter::{range, Iterator, IteratorExt};
63-
use core::ops::{self, llRange, Index};
63+
use core::ops::{FullRange, Index};
6464
use core::option::Option::{self, Some, None};
6565
use core::slice::AsSlice;
6666
use core::str as core_str;
@@ -408,7 +408,7 @@ Section: Trait implementations
408408

409409
/// Any string that can be represented as a slice.
410410
#[stable]
411-
pub trait StrExt: Index<FullRange, str> {
411+
pub trait StrExt: Index<FullRange, Output = str> {
412412
/// Escapes each char in `s` with `char::escape_default`.
413413
#[unstable = "return type may change to be an iterator"]
414414
fn escape_default(&self) -> String {
@@ -1339,12 +1339,6 @@ pub trait StrExt: Index<FullRange, str> {
13391339
fn trim_left(&self) -> &str {
13401340
UnicodeStr::trim_left(self.index(&FullRange))
13411341
}
1342-
1343-
/// Returns a string with trailing whitespace removed.
1344-
#[stable]
1345-
fn trim_right(&self) -> &str {
1346-
UnicodeStr::trim_right(self.index(&FullRange))
1347-
}
13481342
}
13491343

13501344
#[stable]
@@ -2133,7 +2127,7 @@ mod tests {
21332127
let mut bytes = [0u8; 4];
21342128
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
21352129
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
2136-
let s = ::core::str::from_utf8(bytes.index(&(0..len))).unwrap();
2130+
let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
21372131
if Some(c) != s.chars().next() {
21382132
panic!("character {:x}={} does not decode correctly", c as u32, c);
21392133
}
@@ -2145,7 +2139,7 @@ mod tests {
21452139
let mut bytes = [0u8; 4];
21462140
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
21472141
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
2148-
let s = ::core::str::from_utf8(bytes.index(&(0..len))).unwrap();
2142+
let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
21492143
if Some(c) != s.chars().rev().next() {
21502144
panic!("character {:x}={} does not decode correctly", c as u32, c);
21512145
}

src/libcollections/string.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use core::fmt;
2222
use core::hash;
2323
use core::iter::FromIterator;
2424
use core::mem;
25-
use core::ops::{self, Deref, Add};
25+
use core::ops::{self, Deref, Add, Index};
2626
use core::ptr;
2727
use core::raw::Slice as RawSlice;
2828
use unicode::str as unicode_str;
@@ -818,28 +818,29 @@ impl<'a> Add<&'a str> for String {
818818
}
819819
}
820820

821-
impl ops::Index<ops::Range<uint>, str> for String {
821+
impl ops::Index<ops::Range<uint>> for String {
822+
type Output = str;
822823
#[inline]
823824
fn index(&self, index: &ops::Range<uint>) -> &str {
824825
&self.index(&FullRange)[*index]
825826
}
826827
}
827-
828-
impl ops::Index<ops::RangeTo<uint>, str> for String {
828+
impl ops::Index<ops::RangeTo<uint>> for String {
829+
type Output = str;
829830
#[inline]
830831
fn index(&self, index: &ops::RangeTo<uint>) -> &str {
831832
&self.index(&FullRange)[*index]
832833
}
833834
}
834-
835-
impl ops::Index<ops::RangeFrom<uint>, str> for String {
835+
impl ops::Index<ops::RangeFrom<uint>> for String {
836+
type Output = str;
836837
#[inline]
837838
fn index(&self, index: &ops::RangeFrom<uint>) -> &str {
838839
&self.index(&FullRange)[*index]
839840
}
840841
}
841-
842-
impl ops::Index<ops::FullRange, str> for String {
842+
impl ops::Index<ops::FullRange> for String {
843+
type Output = str;
843844
#[inline]
844845
fn index(&self, _index: &ops::FullRange) -> &str {
845846
unsafe { mem::transmute(self.vec.as_slice()) }
@@ -949,6 +950,7 @@ mod tests {
949950
use str::Utf8Error;
950951
use core::iter::repeat;
951952
use super::{as_string, CowString};
953+
use core::ops::FullRange;
952954

953955
#[test]
954956
fn test_as_string() {
@@ -1230,10 +1232,10 @@ mod tests {
12301232
#[test]
12311233
fn test_slicing() {
12321234
let s = "foobar".to_string();
1233-
assert_eq!("foobar", s.index(&FullRange));
1234-
assert_eq!("foo", s.index(&(0..3)));
1235-
assert_eq!("bar", s.index(&(3..)));
1236-
assert_eq!("oob", s.index(&(1..4)));
1235+
assert_eq!("foobar", &s[]);
1236+
assert_eq!("foo", &s[..3]);
1237+
assert_eq!("bar", &s[3..]);
1238+
assert_eq!("oob", &s[1..4]);
12371239
}
12381240

12391241
#[test]

src/libcollections/vec.rs

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,62 +1209,66 @@ impl<T> IndexMut<uint> for Vec<T> {
12091209
}
12101210
}
12111211

1212-
impl<T> ops::Index<ops::Range<uint>, [T]> for Vec<T> {
1212+
1213+
impl<T> ops::Index<ops::Range<uint>> for Vec<T> {
1214+
type Output = [T];
12131215
#[inline]
12141216
fn index(&self, index: &ops::Range<uint>) -> &[T] {
12151217
self.as_slice().index(index)
12161218
}
12171219
}
1218-
1219-
impl<T> ops::Index<ops::RangeTo<uint>, [T]> for Vec<T> {
1220+
impl<T> ops::Index<ops::RangeTo<uint>> for Vec<T> {
1221+
type Output = [T];
12201222
#[inline]
12211223
fn index(&self, index: &ops::RangeTo<uint>) -> &[T] {
12221224
self.as_slice().index(index)
12231225
}
12241226
}
1225-
1226-
impl<T> ops::Index<ops::RangeFrom<uint>, [T]> for Vec<T> {
1227+
impl<T> ops::Index<ops::RangeFrom<uint>> for Vec<T> {
1228+
type Output = [T];
12271229
#[inline]
12281230
fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
12291231
self.as_slice().index(index)
12301232
}
12311233
}
1232-
1233-
impl<T> ops::Index<ops::FullRange, [T]> for Vec<T> {
1234+
impl<T> ops::Index<ops::FullRange> for Vec<T> {
1235+
type Output = [T];
12341236
#[inline]
12351237
fn index(&self, _index: &ops::FullRange) -> &[T] {
12361238
self.as_slice()
12371239
}
12381240
}
12391241

1240-
impl<T> ops::IndexMut<ops::Range<uint>, [T]> for Vec<T> {
1242+
impl<T> ops::IndexMut<ops::Range<uint>> for Vec<T> {
1243+
type Output = [T];
12411244
#[inline]
12421245
fn index_mut(&mut self, index: &ops::Range<uint>) -> &mut [T] {
12431246
self.as_mut_slice().index_mut(index)
12441247
}
12451248
}
1246-
1247-
impl<T> ops::IndexMut<ops::RangeTo<uint>, [T]> for Vec<T> {
1249+
impl<T> ops::IndexMut<ops::RangeTo<uint>> for Vec<T> {
1250+
type Output = [T];
12481251
#[inline]
12491252
fn index_mut(&mut self, index: &ops::RangeTo<uint>) -> &mut [T] {
12501253
self.as_mut_slice().index_mut(index)
12511254
}
12521255
}
1253-
1254-
impl<T> ops::IndexMut<ops::RangeFrom<uint>, [T]> for Vec<T> {
1256+
impl<T> ops::IndexMut<ops::RangeFrom<uint>> for Vec<T> {
1257+
type Output = [T];
12551258
#[inline]
12561259
fn index_mut(&mut self, index: &ops::RangeFrom<uint>) -> &mut [T] {
12571260
self.as_mut_slice().index_mut(index)
12581261
}
12591262
}
1260-
1261-
impl<T> ops::IndexMut<ops::FullRange, [T]> for Vec<T> {
1263+
impl<T> ops::IndexMut<ops::FullRange> for Vec<T> {
1264+
type Output = [T];
12621265
#[inline]
12631266
fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] {
12641267
self.as_mut_slice()
12651268
}
12661269
}
12671270

1271+
12681272
#[stable]
12691273
impl<T> ops::Deref for Vec<T> {
12701274
type Target = [T];
@@ -1795,6 +1799,7 @@ mod tests {
17951799
use prelude::*;
17961800
use core::mem::size_of;
17971801
use core::iter::repeat;
1802+
use core::ops::FullRange;
17981803
use test::Bencher;
17991804
use super::as_vec;
18001805

@@ -1932,15 +1937,15 @@ mod tests {
19321937
let (left, right) = values.split_at_mut(2);
19331938
{
19341939
let left: &[_] = left;
1935-
assert!(left[0..left.len()] == [1, 2][]);
1940+
assert!(&left[..left.len()] == &[1, 2][]);
19361941
}
19371942
for p in left.iter_mut() {
19381943
*p += 1;
19391944
}
19401945

19411946
{
19421947
let right: &[_] = right;
1943-
assert!(right[0..right.len()] == [3, 4, 5][]);
1948+
assert!(&right[..right.len()] == &[3, 4, 5][]);
19441949
}
19451950
for p in right.iter_mut() {
19461951
*p += 2;
@@ -2111,35 +2116,35 @@ mod tests {
21112116
#[should_fail]
21122117
fn test_slice_out_of_bounds_1() {
21132118
let x: Vec<int> = vec![1, 2, 3, 4, 5];
2114-
x[-1..];
2119+
&x[(-1)..];
21152120
}
21162121

21172122
#[test]
21182123
#[should_fail]
21192124
fn test_slice_out_of_bounds_2() {
21202125
let x: Vec<int> = vec![1, 2, 3, 4, 5];
2121-
x.index(&(0..6));
2126+
&x[..6];
21222127
}
21232128

21242129
#[test]
21252130
#[should_fail]
21262131
fn test_slice_out_of_bounds_3() {
21272132
let x: Vec<int> = vec![1, 2, 3, 4, 5];
2128-
x[-1..4];
2133+
&x[(-1)..4];
21292134
}
21302135

21312136
#[test]
21322137
#[should_fail]
21332138
fn test_slice_out_of_bounds_4() {
21342139
let x: Vec<int> = vec![1, 2, 3, 4, 5];
2135-
x.index(&(1..6));
2140+
&x[1..6];
21362141
}
21372142

21382143
#[test]
21392144
#[should_fail]
21402145
fn test_slice_out_of_bounds_5() {
21412146
let x: Vec<int> = vec![1, 2, 3, 4, 5];
2142-
x.index(&(3..2));
2147+
&x[3..2];
21432148
}
21442149

21452150
#[test]
@@ -2385,7 +2390,7 @@ mod tests {
23852390
b.bytes = src_len as u64;
23862391

23872392
b.iter(|| {
2388-
let dst = src.clone().as_slice().to_vec();
2393+
let dst = src.clone()[].to_vec();
23892394
assert_eq!(dst.len(), src_len);
23902395
assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
23912396
});

src/libcore/array.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ macro_rules! array_impls {
5757
Rhs: Deref<Target=[B]>,
5858
{
5959
#[inline(always)]
60-
fn eq(&self, other: &Rhs) -> bool { PartialEq::eq(self.index(&FullRange), &**other) }
60+
fn eq(&self, other: &Rhs) -> bool {
61+
PartialEq::eq(self.index(&FullRange), &**other)
62+
}
6163
#[inline(always)]
62-
fn ne(&self, other: &Rhs) -> bool { PartialEq::ne(self.index(&FullRange), &**other) }
64+
fn ne(&self, other: &Rhs) -> bool {
65+
PartialEq::ne(self.index(&FullRange), &**other)
66+
}
6367
}
6468

6569
#[stable]
@@ -68,9 +72,13 @@ macro_rules! array_impls {
6872
Lhs: Deref<Target=[A]>
6973
{
7074
#[inline(always)]
71-
fn eq(&self, other: &[B; $N]) -> bool { PartialEq::eq(&**self, other.index(&FullRange)) }
75+
fn eq(&self, other: &[B; $N]) -> bool {
76+
PartialEq::eq(&**self, other.index(&FullRange))
77+
}
7278
#[inline(always)]
73-
fn ne(&self, other: &[B; $N]) -> bool { PartialEq::ne(&**self, other.index(&FullRange)) }
79+
fn ne(&self, other: &[B; $N]) -> bool {
80+
PartialEq::ne(&**self, other.index(&FullRange))
81+
}
7482
}
7583

7684
#[stable]

src/libcore/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ impl<'a> Formatter<'a> {
521521

522522
let mut fill = [0u8; 4];
523523
let len = self.fill.encode_utf8(&mut fill).unwrap_or(0);
524-
let fill = unsafe { str::from_utf8_unchecked(fill[..len]) };
524+
let fill = unsafe { str::from_utf8_unchecked(fill.index(&(..len))) };
525525

526526
for _ in range(0, pre_pad) {
527527
try!(self.buf.write_str(fill));

0 commit comments

Comments
 (0)