redpen icon indicating copy to clipboard operation
redpen copied to clipboard

Indexing operations are not accurate on whether they panic

Open estebank opened this issue 2 years ago • 1 comments

rustc doesn't mark the internal APIs that it uses to determine the appropriate trait used by an indexing operation as public. For now, the dont_panic lint always treats indexing as a potentially panicking operation as a stop-gap.

estebank avatar Sep 01 '23 21:09 estebank

This does not seem to work with indexing that does not use usize as the index, for example it does not seem to catch the following panic:

fn main() {
    let mut map = std::collections::HashMap::new();
    map.insert("foo", "bar");
    map["baz"];
}

Erk- avatar Nov 21 '23 09:11 Erk-