needless_borrowed_reference makes invalid suggestions #13035
Labels
C-bug
Category: Clippy is not doing the correct thing
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
Summary
&ref
in a match arm can perform dereferencing, andclippy::needless_borrowed_reference
does not seem to take this into consideration.Lint Name
clippy::needless_borrowed_reference
Reproducer
I tried this code:
cargo clippy --fix
output:Expected behavior
Add a deref to
val
and then remove the&ref
More complex cases
More complex cases should not be corrected or the following corrections should be applied.
Other match variables
ref
should be added to other matched variables.The following example
should be corrected to:
Multiple references
The matched value should be dereferenced until it is bare.
The following example
should be corrected to:
Version
Additional Labels
@rustbot label +I-suggestion-causes-error
@rustbot label -I-false-positive
The text was updated successfully, but these errors were encountered: