]> git.lizzy.rs Git - rust.git/blob - tests/ui/indexing-requires-a-uint.rs
Rollup merge of #107015 - cuviper:ra-riscv64, r=Mark-Simulacrum
[rust.git] / tests / ui / indexing-requires-a-uint.rs
1 // Make sure that indexing an array is only valid with a `usize`, not any other
2 // integral type.
3
4 fn main() {
5     fn bar<T>(_: T) {}
6     [0][0u8]; //~ ERROR: the type `[{integer}]` cannot be indexed by `u8`
7
8     [0][0]; // should infer to be a usize
9
10     let i = 0;      // i is an IntVar
11     [0][i];         // i should be locked to usize
12     bar::<isize>(i);  // i should not be re-coerced back to an isize
13     //~^ ERROR: mismatched types
14 }