Summary
The lint should recognize Option::as_ref and Option::as_mut methods and suggest code with if let, matching on &foo/&mut foo, or alternatively with ref/ref mut in the pattern.
Lint Name
unnecessary_unwrap
Reproducer
I tried this code:
let a = Some(1);
if a.is_some() {
let x = a.as_ref().unwrap();
println!("{x}");
}
I expected to see this happen:
The lint would trigger and suggest the following code:
let a = Some(1);
if let Some(x) = &a {
println!("{x}");
}
Instead, the lint didn't trigger.
Version
0.1.73 (2023-08-20 5c6a7e7) on playground