RS.CLIPPY.OUT_OF_BOUNDS_INDEXING

Out of bounds constant indexing

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: out_of_bounds_indexing. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for out of bounds array indexing with a constant index.

Why is this bad?

This will always panic at runtime.

Example

let x = [1, 2, 3, 4];

x[9];
&x[2..9];

Use instead:

// Index within bounds

x[0];
x[3];