manual_unwrap_or_default
fails to consider deref type coercion
#12666
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
L-suspicious
Lint: Belongs in the suspicious lint group
Summary
clippy::manual_unwrap_or_default
fails to consider deref type coercion for the returned valuesLint Name
manual_unwrap_or_default
Reproducer
Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=b8497c471fa7991f62cb1ef29fe18e31
Clippy suggests the code
s.unwrap_or_default()
and then rust suggests&s.unwrap_or_default()
, which naturally will not work due to returning a reference to a temporary local value.A way to simplify
foo
would be to useas_deref()
first:A way to simplify
bar
would be to deref the inner value usingmap
first:Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: