Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should_impl_trait - ignore methods with lifetime params #5725

Merged
merged 6 commits into from
Aug 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
should_implement_trait - pr remarks
  • Loading branch information
tnielens committed Aug 9, 2020
commit e6b2254f9e55743dbace44cc73c6447b6bda58e5
10 changes: 5 additions & 5 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,10 +1498,10 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
// check missing trait implementations
for &(method_name, n_args, fn_header, self_kind, out_type, trait_name) in &TRAIT_METHODS {
let no_lifetime_params = || {
impl_item.generics.params.iter().filter(|p| match p.kind {
hir::GenericParamKind::Lifetime { .. } => true,
_ => false,
}).count() == 0
!impl_item.generics.params.iter()
.any(|p| matches!(
p.kind,
hir::GenericParamKind::Lifetime { .. }))
};
if name == method_name &&
sig.decl.inputs.len() == n_args &&
Expand All @@ -1510,7 +1510,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
fn_header_equals(*fn_header, sig.header) &&
// ignore methods with lifetime params, risk of false positive
flip1995 marked this conversation as resolved.
Show resolved Hide resolved
no_lifetime_params()
{
{
span_lint(cx, SHOULD_IMPLEMENT_TRAIT, impl_item.span, &format!(
"defining a method called `{}` on this type; consider implementing \
the `{}` trait or choosing a less ambiguous name", name, trait_name));
Expand Down