should_implement_trait - pr remarks

This commit is contained in:
Tim Nielens 2020-06-21 00:12:09 +02:00
parent 2bc0ecd44b
commit e6b2254f9e

View File

@ -1498,10 +1498,10 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
// check missing trait implementations // check missing trait implementations
for &(method_name, n_args, fn_header, self_kind, out_type, trait_name) in &TRAIT_METHODS { for &(method_name, n_args, fn_header, self_kind, out_type, trait_name) in &TRAIT_METHODS {
let no_lifetime_params = || { let no_lifetime_params = || {
impl_item.generics.params.iter().filter(|p| match p.kind { !impl_item.generics.params.iter()
hir::GenericParamKind::Lifetime { .. } => true, .any(|p| matches!(
_ => false, p.kind,
}).count() == 0 hir::GenericParamKind::Lifetime { .. }))
}; };
if name == method_name && if name == method_name &&
sig.decl.inputs.len() == n_args && sig.decl.inputs.len() == n_args &&
@ -1510,7 +1510,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
fn_header_equals(*fn_header, sig.header) && fn_header_equals(*fn_header, sig.header) &&
// ignore methods with lifetime params, risk of false positive // ignore methods with lifetime params, risk of false positive
no_lifetime_params() no_lifetime_params()
{ {
span_lint(cx, SHOULD_IMPLEMENT_TRAIT, impl_item.span, &format!( span_lint(cx, SHOULD_IMPLEMENT_TRAIT, impl_item.span, &format!(
"defining a method called `{}` on this type; consider implementing \ "defining a method called `{}` on this type; consider implementing \
the `{}` trait or choosing a less ambiguous name", name, trait_name)); the `{}` trait or choosing a less ambiguous name", name, trait_name));