Skip to content

Commit 251a475

Browse files
committed
Auto merge of #11511 - Jarcho:split_borrow, r=llogiq
Split `needless_borrow` into two lints Splits off the case where the borrow is used as a generic argument to a function. I think the two cases are different enough to warrant a separate lint. The tests for the new lint have been reordered to group related parts together. Two warning have been dropped, one looked like it was testing the generic argument form, but it ends up triggering the auto-deref variant. The second was just a redundant test that didn't do anything interesting. An issue with cycle detection is also included. The old version was checking if a cycle was reachable from a block when it should have been checking if the block is part or a cycle. As a side note, I'm liking the style of just jamming all the tests into separate scopes in main. changelog: Split off `needless_borrows_for_generic_args` from `needless_borrow`
2 parents 7b5e019 + 79247d9 commit 251a475

16 files changed

+1140
-1070
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5171,6 +5171,7 @@ Released 2018-09-13
51715171
[`needless_bool_assign`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_bool_assign
51725172
[`needless_borrow`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
51735173
[`needless_borrowed_reference`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
5174+
[`needless_borrows_for_generic_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
51745175
[`needless_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_collect
51755176
[`needless_continue`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_continue
51765177
[`needless_doctest_main`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_doctest_main

clippy_lints/src/declared_lints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
480480
crate::needless_bool::NEEDLESS_BOOL_INFO,
481481
crate::needless_bool::NEEDLESS_BOOL_ASSIGN_INFO,
482482
crate::needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE_INFO,
483+
crate::needless_borrows_for_generic_args::NEEDLESS_BORROWS_FOR_GENERIC_ARGS_INFO,
483484
crate::needless_continue::NEEDLESS_CONTINUE_INFO,
484485
crate::needless_else::NEEDLESS_ELSE_INFO,
485486
crate::needless_for_each::NEEDLESS_FOR_EACH_INFO,

clippy_lints/src/dereference.rs

+5-369
Large diffs are not rendered by default.

clippy_lints/src/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ mod mutex_atomic;
228228
mod needless_arbitrary_self_type;
229229
mod needless_bool;
230230
mod needless_borrowed_ref;
231+
mod needless_borrows_for_generic_args;
231232
mod needless_continue;
232233
mod needless_else;
233234
mod needless_for_each;
@@ -887,7 +888,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
887888
store.register_late_pass(move |_| Box::new(wildcard_imports::WildcardImports::new(warn_on_all_wildcard_imports)));
888889
store.register_late_pass(|_| Box::<redundant_pub_crate::RedundantPubCrate>::default());
889890
store.register_late_pass(|_| Box::new(unnamed_address::UnnamedAddress));
890-
store.register_late_pass(move |_| Box::new(dereference::Dereferencing::new(msrv())));
891+
store.register_late_pass(|_| Box::<dereference::Dereferencing<'_>>::default());
891892
store.register_late_pass(|_| Box::new(option_if_let_else::OptionIfLetElse));
892893
store.register_late_pass(|_| Box::new(future_not_send::FutureNotSend));
893894
let future_size_threshold = conf.future_size_threshold;
@@ -1111,6 +1112,11 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11111112
store.register_late_pass(|_| Box::new(implied_bounds_in_impls::ImpliedBoundsInImpls));
11121113
store.register_late_pass(|_| Box::new(missing_asserts_for_indexing::MissingAssertsForIndexing));
11131114
store.register_late_pass(|_| Box::new(unnecessary_map_on_constructor::UnnecessaryMapOnConstructor));
1115+
store.register_late_pass(move |_| {
1116+
Box::new(needless_borrows_for_generic_args::NeedlessBorrowsForGenericArgs::new(
1117+
msrv(),
1118+
))
1119+
});
11141120
// add lints here, do not remove this comment, it's used in `new_lint`
11151121
}
11161122

0 commit comments

Comments
 (0)