Closed
Description
See also the perf improvement in rustc: rust-lang/rust#78508.
Currently, or_fun_call
lint doesn't lint on indexing to HashMap types.
I tried this code:
#![warn(clippy::or_fun_call)]
use std::collections::HashMap;
pub fn foo(opt: Option<u32>, map: HashMap<u32, u32>, idx: u32) -> u32 {
opt.unwrap_or(map[&idx])
}
I expected to see this happen: A warning to unwrap_or
method call because
map[&idx]
maybe expensive (indexing to a hashmap).
Instead, this happened: No warning at all.
Meta
Maybe a duplicate of #5821 .