about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-03-04 12:30:27 +0000
committerbors <bors@rust-lang.org>2018-03-04 12:30:27 +0000
commit1e1bfc715f8dfe36a38d8fae36fcbe92e7463a3f (patch)
treef918a6637865c6e3ad5e775fc2a96ea988e24a03 /src/test
parent9ff5cb5aea98d3f5ccc5a66aa8fd36fb43dcb55d (diff)
parent370df40dab8df9f3c0b10bb7396225b8d24869b3 (diff)
Auto merge of #47832 - fintelia:vec-index, r=kennytm
Have Vec use slice's implementations of Index<I> and IndexMut<I>

This PR simplifies the implementation of Index and IndexMut on Vec, and in the process enables indexing Vec by any user types that implement SliceIndex.

The stability annotations probably need to be changed, but I wasn't sure of the right way to do that. It also wasn't completely clear to me if this change could break any existing code.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/integral-indexing.rs8
-rw-r--r--src/test/ui/index-help.stderr7
2 files changed, 8 insertions, 7 deletions
diff --git a/src/test/compile-fail/integral-indexing.rs b/src/test/compile-fail/integral-indexing.rs
index 659b08b55a0..4b01afb8131 100644
--- a/src/test/compile-fail/integral-indexing.rs
+++ b/src/test/compile-fail/integral-indexing.rs
@@ -13,10 +13,10 @@ pub fn main() {
     let s: String = "abcdef".to_string();
     v[3_usize];
     v[3];
-    v[3u8];  //~ERROR : std::ops::Index<u8>` is not satisfied
-    v[3i8];  //~ERROR : std::ops::Index<i8>` is not satisfied
-    v[3u32]; //~ERROR : std::ops::Index<u32>` is not satisfied
-    v[3i32]; //~ERROR : std::ops::Index<i32>` is not satisfied
+    v[3u8];  //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied
+    v[3i8];  //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied
+    v[3u32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied
+    v[3i32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied
     s.as_bytes()[3_usize];
     s.as_bytes()[3];
     s.as_bytes()[3u8];  //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied
diff --git a/src/test/ui/index-help.stderr b/src/test/ui/index-help.stderr
index f4dde95b104..ae3cd529ac4 100644
--- a/src/test/ui/index-help.stderr
+++ b/src/test/ui/index-help.stderr
@@ -1,10 +1,11 @@
-error[E0277]: the trait bound `std::vec::Vec<{integer}>: std::ops::Index<i32>` is not satisfied
+error[E0277]: the trait bound `i32: std::slice::SliceIndex<[{integer}]>` is not satisfied
   --> $DIR/index-help.rs:13:5
    |
 LL |     x[0i32]; //~ ERROR E0277
-   |     ^^^^^^^ vector indices are of type `usize` or ranges of `usize`
+   |     ^^^^^^^ slice indices are of type `usize` or ranges of `usize`
    |
-   = help: the trait `std::ops::Index<i32>` is not implemented for `std::vec::Vec<{integer}>`
+   = help: the trait `std::slice::SliceIndex<[{integer}]>` is not implemented for `i32`
+   = note: required because of the requirements on the impl of `std::ops::Index<i32>` for `std::vec::Vec<{integer}>`
 
 error: aborting due to previous error