False positive: useless_asref when used to go from &&T
to &T
#12785
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
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
Summary
Normally,
&&T
will automatically and silently behave like&T
and usingfoo.map(|t| t.as_ref())
is unneeded. However theuseless_asref
lint has a false positive in the case where types need to line up, e.g. the return types ofif
andelse
, the arms ofmatch
brackets, or in this case,Option<T>
and the result ofOption::unwrap_or(...)
.Lint Name
useless_asref
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
The
useless_asref
lint is incorrect here since without the call rustc (1.80.0-nightly
) will complain about mismatched types:Version
Additional Labels
@rustbot label +I-suggestion-causes-error
The text was updated successfully, but these errors were encountered: