use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::symbol::{kw, Ident};
use rustc_span::Span;
+use std::iter;
declare_clippy_lint! {
/// ### What it does
})) => (
def_id.to_def_id(),
FnKind::TraitFn,
- if sig.decl.implicit_self.has_implicit_self() {
- 1
- } else {
- 0
- },
+ usize::from(sig.decl.implicit_self.has_implicit_self()),
),
Some(Node::ImplItem(&ImplItem {
kind: ImplItemKind::Fn(ref sig, _),
(
trait_item_id,
FnKind::ImplTraitFn(cx.tcx.erase_regions(trait_ref.substs) as *const _ as usize),
- if sig.decl.implicit_self.has_implicit_self() {
- 1
- } else {
- 0
- },
+ usize::from(sig.decl.implicit_self.has_implicit_self()),
)
} else {
(def_id.to_def_id(), FnKind::Fn, 0)
}
return;
},
- ExprKind::MethodCall(_, args, _)
+ ExprKind::MethodCall(_, receiver, args, _)
if typeck.type_dependent_def_id(parent.hir_id).map_or(false, |id| {
id == param.fn_id
&& has_matching_substs(param.fn_kind, typeck.node_substs(parent.hir_id))
}) =>
{
- if let Some(idx) = args.iter().position(|arg| arg.hir_id == child_id) {
+ if let Some(idx) = iter::once(receiver).chain(args).position(|arg| arg.hir_id == child_id) {
param.uses.push(Usage::new(span, idx));
}
return;