]> git.lizzy.rs Git - rust.git/blob - src/test/ui/suggestions/negative-literal-index.fixed
Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid
[rust.git] / src / test / ui / suggestions / negative-literal-index.fixed
1 // run-rustfix
2
3 use std::ops::Index;
4 struct X;
5 impl Index<i32> for X {
6     type Output = ();
7
8     fn index(&self, _: i32) -> &() {
9         &()
10     }
11 }
12
13 fn 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 }