Skip to content

Commit

Permalink
Auto merge of #7977 - Jarcho:multi_needless_borrow, r=xFrednet
Browse files Browse the repository at this point in the history
Improve `needless_borrow` lint

fixes: #5327
fixes: #1726
fixes: #1212

This is merging `needless_borrow` into the `dereference` pass in preparation for `explicit_auto_deref`. `explicit_auto_deref` needs to implement most of what `needless_borrow` implements in order to work.

There is a minor regression here where `let x: &str = &x.deref()` will trigger `needless_borrow` without triggering `explicit_deref_methods`. Removing the redundant borrow will cause `explicit_deref_methods` to trigger. This will be fixed when `explicit_auto_deref` is implemented.

changelog: Lint `needless_borrow` when a borrow is auto-derefed more than once
changelog: Lint `needless_borrow` in the trailing expression of a block for a match arm
  • Loading branch information
bors committed Nov 18, 2021
2 parents 8dd1bce + 8ded385 commit 2776076
Show file tree
Hide file tree
Showing 11 changed files with 425 additions and 306 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
if (p == sym::iter || p == sym!(iter_mut)) && args.len() == 1 {
&args[0]
} else {
&filter_recv
filter_recv
}
} else {
&filter_recv
filter_recv
};
let mut applicability = Applicability::MaybeIncorrect;
span_lint_and_sugg(
Expand Down
Loading

0 comments on commit 2776076

Please sign in to comment.