Warn when a borrow expression is unused #76264
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-help-wanted
Call for participation: Help is requested to fix this issue.
Borrowing an expression is side-effect free, so there should never be a reason to write the first instead of the second.
If you really wanted to do this you could assign the result to an unused variable:
Therefore, we should add a lint for unused borrows to the compiler. Why is this important? A misplaced semi-colon before an
&&
operator in a multi-line boolean expression causes subsequent clauses to be silently ignored.The text was updated successfully, but these errors were encountered: