Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Mar 12, 2020
1 parent fdce47b commit 3e37766
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ fn is_relevant_impl(cx: &LateContext<'_, '_>, item: &ImplItem<'_>) -> bool {

fn is_relevant_trait(cx: &LateContext<'_, '_>, item: &TraitItem<'_>) -> bool {
match item.kind {
TraitItemKind::Method(_, TraitMethod::Required(_)) => true,
TraitItemKind::Method(_, TraitMethod::Provided(eid)) => {
TraitItemKind::Fn(_, TraitMethod::Required(_)) => true,
TraitItemKind::Fn(_, TraitMethod::Provided(eid)) => {
is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value)
},
_ => false,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown {

fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem<'_>) {
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
if let hir::TraitItemKind::Method(ref sig, ..) = item.kind {
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
if !in_external_macro(cx.tcx.sess, item.span) {
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
}

fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem<'_>) {
if let hir::TraitItemKind::Method(ref sig, ref eid) = item.kind {
if let hir::TraitItemKind::Fn(ref sig, ref eid) = item.kind {
// don't lint extern functions decls, it's not their fault
if sig.header.abi == Abi::Rust {
self.check_arg_number(cx, &sig.decl, item.span.with_hi(sig.decl.output.span().hi()));
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/inline_fn_without_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ declare_lint_pass!(InlineFnWithoutBody => [INLINE_FN_WITHOUT_BODY]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InlineFnWithoutBody {
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
if let TraitItemKind::Method(_, TraitMethod::Required(_)) = item.kind {
if let TraitItemKind::Fn(_, TraitMethod::Required(_)) = item.kind {
check_attrs(cx, item.ident.name, &item.attrs);
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Lifetimes {
}

fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
if let TraitItemKind::Method(ref sig, ref body) = item.kind {
if let TraitItemKind::Fn(ref sig, ref body) = item.kind {
let body = match *body {
TraitMethod::Required(_) => None,
TraitMethod::Provided(id) => Some(id),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ fn lint_expect_fun_call(
if let hir::ExprKind::Path(ref p) = fun.kind {
match cx.tables.qpath_res(p, fun.hir_id) {
hir::def::Res::Def(hir::def::DefKind::Fn, def_id)
| hir::def::Res::Def(hir::def::DefKind::Method, def_id) => matches!(
| hir::def::Res::Def(hir::def::DefKind::AssocFn, def_id) => matches!(
cx.tcx.fn_sig(def_id).output().skip_binder().kind,
ty::Ref(ty::ReStatic, ..)
),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir::TraitItem<'_>) {
let desc = match trait_item.kind {
hir::TraitItemKind::Const(..) => "an associated constant",
hir::TraitItemKind::Method(..) => "a trait method",
hir::TraitItemKind::Fn(..) => "a trait method",
hir::TraitItemKind::Type(..) => "an associated type",
};

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/missing_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
let tit_ = cx.tcx.hir().trait_item(tit.id);
match tit_.kind {
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
hir::TraitItemKind::Method(..) => {
hir::TraitItemKind::Fn(..) => {
if tit.defaultness.has_value() {
// trait method with default body needs inline in case
// an impl is not provided
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/mut_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableKeyType {
}

fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem<'tcx>) {
if let hir::TraitItemKind::Method(ref sig, ..) = item.kind {
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
check_sig(cx, item.hir_id, &sig.decl);
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr {
}

fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
if let TraitItemKind::Method(ref sig, ref trait_method) = item.kind {
if let TraitItemKind::Fn(ref sig, ref trait_method) = item.kind {
let body_id = if let TraitMethod::Provided(b) = *trait_method {
Some(b)
} else {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/trivially_copy_pass_by_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
return;
}

if let hir::TraitItemKind::Method(method_sig, _) = &item.kind {
if let hir::TraitItemKind::Fn(method_sig, _) = &item.kind {
self.check_poly_fn(cx, item.hir_id, &*method_sig.decl, None);
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Types {
fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &TraitItem<'_>) {
match item.kind {
TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => self.check_ty(cx, ty, false),
TraitItemKind::Method(ref sig, _) => self.check_fn_decl(cx, &sig.decl),
TraitItemKind::Fn(ref sig, _) => self.check_fn_decl(cx, &sig.decl),
_ => (),
}
}
Expand Down Expand Up @@ -1457,7 +1457,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexity {
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
match item.kind {
TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => self.check_type(cx, ty),
TraitItemKind::Method(FnSig { ref decl, .. }, TraitMethod::Required(_)) => self.check_fndecl(cx, decl),
TraitItemKind::Fn(FnSig { ref decl, .. }, TraitMethod::Required(_)) => self.check_fndecl(cx, decl),
// methods with default impl are covered by check_fn
_ => (),
}
Expand Down

0 comments on commit 3e37766

Please sign in to comment.