Auto merge of #7215 - ThibsG:WrongSelfFix7179, r=Manishearth

Trigger [`wrong_self_convention`] only if it has implicit self

Lint [`wrong_self_convention`] only if the impl or trait has `self` _per sé_.

Fixes: #7179

changelog: trigger [`wrong_self_convention`] only if it has implicit self
This commit is contained in:
bors 2021-05-13 16:00:58 +00:00
commit 08ce8bb703
3 changed files with 56 additions and 10 deletions

View file

@ -1838,16 +1838,18 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
}
}
wrong_self_convention::check(
cx,
&name,
item.vis.node.is_pub(),
self_ty,
first_arg_ty,
first_arg.pat.span,
implements_trait,
false
);
if sig.decl.implicit_self.has_implicit_self() {
wrong_self_convention::check(
cx,
&name,
item.vis.node.is_pub(),
self_ty,
first_arg_ty,
first_arg.pat.span,
implements_trait,
false
);
}
}
}
@ -1903,7 +1905,9 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
if_chain! {
if let TraitItemKind::Fn(ref sig, _) = item.kind;
if sig.decl.implicit_self.has_implicit_self();
if let Some(first_arg_ty) = sig.decl.inputs.iter().next();
then {
let first_arg_span = first_arg_ty.span;
let first_arg_ty = hir_ty_to_ty(cx.tcx, first_arg_ty);