fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// run-rustfix 2 3use std::ops::Index; 4struct X; 5impl Index<i32> for X { 6 type Output = (); 7 8 fn index(&self, _: i32) -> &() { 9 &() 10 } 11} 12 13fn main() { 14 let x = vec![1, 2, 3]; 15 x[x.len() -1]; //~ ERROR negative integers cannot be used to index on a 16 let x = [1, 2, 3]; 17 x[x.len() -1]; //~ ERROR negative integers cannot be used to index on a 18 let x = &[1, 2, 3]; 19 x[x.len() -1]; //~ ERROR negative integers cannot be used to index on a 20 let _ = x; 21 X[-1]; 22}