indexing_slicing
displays error when indexing reference to array
#6021
Labels
C-bug
Category: Clippy is not doing the correct thing
C-enhancement
Category: Enhancement of lints, like adding more cases or adding help messages
E-medium
Call for participation: Medium difficulty level problem and requires some initial experience.
I tried this code:
Playground
I expected to see this happen:
No warning displayed, as
arr[0]
is known to exist, becausearr
has 2 elements.Instead, this happened:
I got the warning:
At first I thought that perhaps
arr[0]
would use<[u8]>::index
and so it could panic and clippy was correct, but when building the assembly, even in debug mode, there is no panic code, and using an invalid index triggers arustc
error about the operation always panicking at runtime, so I believe clippy should also detect when this is valid.Meta
cargo clippy -V
: e.g. clippy 0.0.212 (2020-09-08 5099914)As this is on the playground, I am unable to run
rustc -Vv
or provide a backtrace.The text was updated successfully, but these errors were encountered: