mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
23 lines
495 B
Rust
23 lines
495 B
Rust
//@ run-rustfix
|
|
|
|
use std::ops::Index;
|
|
struct X;
|
|
impl Index<i32> for X {
|
|
type Output = ();
|
|
|
|
fn index(&self, _: i32) -> &() {
|
|
&()
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let x = vec![1, 2, 3];
|
|
x[x.len() -1]; //~ ERROR negative integers cannot be used to index on a
|
|
let x = [1, 2, 3];
|
|
x[x.len() -1]; //~ ERROR negative integers cannot be used to index on a
|
|
let x = &[1, 2, 3];
|
|
x[x.len() -1]; //~ ERROR negative integers cannot be used to index on a
|
|
let _ = x;
|
|
X[-1];
|
|
}
|