]> git.lizzy.rs Git - rust.git/blob - tests/ui/integral-indexing.rs
check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736)
[rust.git] / tests / ui / integral-indexing.rs
1 pub fn main() {
2     let v: Vec<isize> = vec![0, 1, 2, 3, 4, 5];
3     let s: String = "abcdef".to_string();
4     v[3_usize];
5     v[3];
6     v[3u8];  //~ERROR : the type `[isize]` cannot be indexed by `u8`
7     v[3i8];  //~ERROR : the type `[isize]` cannot be indexed by `i8`
8     v[3u32]; //~ERROR : the type `[isize]` cannot be indexed by `u32`
9     v[3i32]; //~ERROR : the type `[isize]` cannot be indexed by `i32`
10     s.as_bytes()[3_usize];
11     s.as_bytes()[3];
12     s.as_bytes()[3u8];  //~ERROR : the type `[u8]` cannot be indexed by `u8`
13     s.as_bytes()[3i8];  //~ERROR : the type `[u8]` cannot be indexed by `i8`
14     s.as_bytes()[3u32]; //~ERROR : the type `[u8]` cannot be indexed by `u32`
15     s.as_bytes()[3i32]; //~ERROR : the type `[u8]` cannot be indexed by `i32`
16 }