mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 16:39:26 +00:00
3226e4b010
also share the code that emits the actual error
107 lines
3.1 KiB
Text
107 lines
3.1 KiB
Text
error: indexing may panic
|
|
--> $DIR/indexing_slicing_index.rs:14:20
|
|
|
|
|
LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-restriction-lint-in-const` default is false.
|
|
| ^^^^^^^^^^
|
|
|
|
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
|
= note: the suggestion might not be applicable in constant blocks
|
|
= note: `-D clippy::indexing-slicing` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]`
|
|
|
|
error: indexing may panic
|
|
--> $DIR/indexing_slicing_index.rs:16:24
|
|
|
|
|
LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts.
|
|
| ^^^^^^^^^^^
|
|
|
|
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
|
= note: the suggestion might not be applicable in constant blocks
|
|
|
|
error[E0080]: evaluation of `main::{constant#3}` failed
|
|
--> $DIR/indexing_slicing_index.rs:48:14
|
|
|
|
|
LL | const { &ARR[idx4()] };
|
|
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
|
|
|
|
note: erroneous constant encountered
|
|
--> $DIR/indexing_slicing_index.rs:48:5
|
|
|
|
|
LL | const { &ARR[idx4()] };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: indexing may panic
|
|
--> $DIR/indexing_slicing_index.rs:29:5
|
|
|
|
|
LL | x[index];
|
|
| ^^^^^^^^
|
|
|
|
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
|
|
|
error: indexing may panic
|
|
--> $DIR/indexing_slicing_index.rs:45:14
|
|
|
|
|
LL | const { &ARR[idx()] };
|
|
| ^^^^^^^^^^
|
|
|
|
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
|
= note: the suggestion might not be applicable in constant blocks
|
|
|
|
error: indexing may panic
|
|
--> $DIR/indexing_slicing_index.rs:48:14
|
|
|
|
|
LL | const { &ARR[idx4()] };
|
|
| ^^^^^^^^^^^
|
|
|
|
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
|
= note: the suggestion might not be applicable in constant blocks
|
|
|
|
error: indexing may panic
|
|
--> $DIR/indexing_slicing_index.rs:58:5
|
|
|
|
|
LL | v[0];
|
|
| ^^^^
|
|
|
|
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
|
|
|
error: indexing may panic
|
|
--> $DIR/indexing_slicing_index.rs:60:5
|
|
|
|
|
LL | v[10];
|
|
| ^^^^^
|
|
|
|
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
|
|
|
error: indexing may panic
|
|
--> $DIR/indexing_slicing_index.rs:62:5
|
|
|
|
|
LL | v[1 << 3];
|
|
| ^^^^^^^^^
|
|
|
|
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
|
|
|
error: indexing may panic
|
|
--> $DIR/indexing_slicing_index.rs:73:5
|
|
|
|
|
LL | v[N];
|
|
| ^^^^
|
|
|
|
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
|
|
|
error: indexing may panic
|
|
--> $DIR/indexing_slicing_index.rs:75:5
|
|
|
|
|
LL | v[M];
|
|
| ^^^^
|
|
|
|
|
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
|
|
|
error[E0080]: evaluation of constant value failed
|
|
--> $DIR/indexing_slicing_index.rs:16:24
|
|
|
|
|
LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts.
|
|
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
|
|
|
|
error: aborting due to 12 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0080`.
|