1. From a inline constant block (https://github.com/rust-lang/rust-clippy/issues/8348#issuecomment-1021303011). ```rust #![feature(inline_const)] #![forbid(clippy::indexing_slicing)] const FOO: [i32; 1] = [1]; const fn idx() -> usize { 0 } pub fn main() { assert_eq!(FOO[const { idx() }], 1); } ``` 2. From a `const` declaration (https://github.com/rust-lang/rust-clippy/issues/8348#issuecomment-1021359538). ```rust #![forbid(clippy::indexing_slicing)] const FOO: [i32; 1] = [1]; const REF: &i32 = &FOO[idx()]; const fn idx() -> usize { 0 } pub fn main() { assert_eq!(REF, &1); } ``` <!-- TRIAGEBOT_START --> <!-- TRIAGEBOT_ASSIGN_START --> <!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"pitaj"}$$TRIAGEBOT_ASSIGN_DATA_END --> <!-- TRIAGEBOT_ASSIGN_END --> <!-- TRIAGEBOT_END -->
indexing_slicingshould not fire if a valid array index comes from a constant function that is evaluated at compile-time #8348 (comment)).constdeclaration (indexing_slicingshould not fire if a valid array index comes from a constant function that is evaluated at compile-time #8348 (comment)).