Overload get{,_mut}{,_unchecked}
This commit is contained in:
parent
a31ad75bde
commit
5377b5e9c4
7 changed files with 407 additions and 188 deletions
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
fn main() {
|
||||
fn bar<T>(_: T) {}
|
||||
[0][0u8]; //~ ERROR: `[{integer}]: std::ops::Index<u8>` is not satisfied
|
||||
[0][0u8]; //~ ERROR: the trait bound `u8: std::slice::SliceIndex<{integer}>` is not satisfied
|
||||
|
||||
[0][0]; // should infer to be a usize
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ pub fn main() {
|
|||
v[3i32]; //~ERROR : std::ops::Index<i32>` is not satisfied
|
||||
s.as_bytes()[3_usize];
|
||||
s.as_bytes()[3];
|
||||
s.as_bytes()[3u8]; //~ERROR : std::ops::Index<u8>` is not satisfied
|
||||
s.as_bytes()[3i8]; //~ERROR : std::ops::Index<i8>` is not satisfied
|
||||
s.as_bytes()[3u32]; //~ERROR : std::ops::Index<u32>` is not satisfied
|
||||
s.as_bytes()[3i32]; //~ERROR : std::ops::Index<i32>` is not satisfied
|
||||
s.as_bytes()[3u8]; //~ERROR : std::slice::SliceIndex<u8>` is not satisfied
|
||||
s.as_bytes()[3i8]; //~ERROR : std::slice::SliceIndex<u8>` is not satisfied
|
||||
s.as_bytes()[3u32]; //~ERROR : std::slice::SliceIndex<u8>` is not satisfied
|
||||
s.as_bytes()[3i32]; //~ERROR : std::slice::SliceIndex<u8>` is not satisfied
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
// Test new Index error message for slices
|
||||
// ignore-tidy-linelength
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
|
|
@ -17,12 +18,12 @@ use std::ops::Index;
|
|||
#[rustc_error]
|
||||
fn main() {
|
||||
let x = &[1, 2, 3] as &[i32];
|
||||
x[1i32];
|
||||
//~^ ERROR E0277
|
||||
//~| NOTE the trait `std::ops::Index<i32>` is not implemented for `[i32]`
|
||||
//~| NOTE slice indices are of type `usize`
|
||||
x[..1i32];
|
||||
//~^ ERROR E0277
|
||||
//~| NOTE the trait `std::ops::Index<std::ops::RangeTo<i32>>` is not implemented for `[i32]`
|
||||
//~| NOTE slice indices are of type `usize`
|
||||
x[1i32]; //~ ERROR E0277
|
||||
//~| NOTE slice indices are of type `usize` or ranges of `usize`
|
||||
//~| NOTE trait `std::slice::SliceIndex<i32>` is not implemented for `i32`
|
||||
//~| NOTE required because of the requirements on the impl of `std::ops::Index<i32>`
|
||||
x[..1i32]; //~ ERROR E0277
|
||||
//~| NOTE slice indices are of type `usize` or ranges of `usize`
|
||||
//~| NOTE trait `std::slice::SliceIndex<i32>` is not implemented for `std::ops::RangeTo<i32>`
|
||||
//~| NOTE requirements on the impl of `std::ops::Index<std::ops::RangeTo<i32>>`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue