This commit is contained in:
Yuki Okushi 2020-03-13 04:56:55 +09:00
parent fdce47ba7d
commit 3e3776666e
No known key found for this signature in database
GPG key ID: B0986C85C0E2DAA1
12 changed files with 14 additions and 14 deletions

View file

@ -379,8 +379,8 @@ fn is_relevant_impl(cx: &LateContext<'_, '_>, item: &ImplItem<'_>) -> bool {
fn is_relevant_trait(cx: &LateContext<'_, '_>, item: &TraitItem<'_>) -> bool { fn is_relevant_trait(cx: &LateContext<'_, '_>, item: &TraitItem<'_>) -> bool {
match item.kind { match item.kind {
TraitItemKind::Method(_, TraitMethod::Required(_)) => true, TraitItemKind::Fn(_, TraitMethod::Required(_)) => true,
TraitItemKind::Method(_, TraitMethod::Provided(eid)) => { TraitItemKind::Fn(_, TraitMethod::Provided(eid)) => {
is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value) is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value)
}, },
_ => false, _ => false,

View file

@ -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<'_>) { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem<'_>) {
let headers = check_attrs(cx, &self.valid_idents, &item.attrs); 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) { if !in_external_macro(cx.tcx.sess, item.span) {
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None); lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None);
} }

View file

@ -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<'_>) { 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 // don't lint extern functions decls, it's not their fault
if sig.header.abi == Abi::Rust { if sig.header.abi == Abi::Rust {
self.check_arg_number(cx, &sig.decl, item.span.with_hi(sig.decl.output.span().hi())); self.check_arg_number(cx, &sig.decl, item.span.with_hi(sig.decl.output.span().hi()));

View file

@ -32,7 +32,7 @@ declare_lint_pass!(InlineFnWithoutBody => [INLINE_FN_WITHOUT_BODY]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InlineFnWithoutBody { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InlineFnWithoutBody {
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) { 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); check_attrs(cx, item.ident.name, &item.attrs);
} }
} }

View file

@ -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<'_>) { 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 { let body = match *body {
TraitMethod::Required(_) => None, TraitMethod::Required(_) => None,
TraitMethod::Provided(id) => Some(id), TraitMethod::Provided(id) => Some(id),

View file

@ -1738,7 +1738,7 @@ fn lint_expect_fun_call(
if let hir::ExprKind::Path(ref p) = fun.kind { if let hir::ExprKind::Path(ref p) = fun.kind {
match cx.tables.qpath_res(p, fun.hir_id) { 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::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, cx.tcx.fn_sig(def_id).output().skip_binder().kind,
ty::Ref(ty::ReStatic, ..) ty::Ref(ty::ReStatic, ..)
), ),

View file

@ -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<'_>) { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir::TraitItem<'_>) {
let desc = match trait_item.kind { let desc = match trait_item.kind {
hir::TraitItemKind::Const(..) => "an associated constant", hir::TraitItemKind::Const(..) => "an associated constant",
hir::TraitItemKind::Method(..) => "a trait method", hir::TraitItemKind::Fn(..) => "a trait method",
hir::TraitItemKind::Type(..) => "an associated type", hir::TraitItemKind::Type(..) => "an associated type",
}; };

View file

@ -100,7 +100,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
let tit_ = cx.tcx.hir().trait_item(tit.id); let tit_ = cx.tcx.hir().trait_item(tit.id);
match tit_.kind { match tit_.kind {
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {}, hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
hir::TraitItemKind::Method(..) => { hir::TraitItemKind::Fn(..) => {
if tit.defaultness.has_value() { if tit.defaultness.has_value() {
// trait method with default body needs inline in case // trait method with default body needs inline in case
// an impl is not provided // an impl is not provided

View file

@ -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>) { 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); check_sig(cx, item.hir_id, &sig.decl);
} }
} }

View file

@ -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<'_>) { 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 { let body_id = if let TraitMethod::Provided(b) = *trait_method {
Some(b) Some(b)
} else { } else {

View file

@ -132,7 +132,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
return; 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); self.check_poly_fn(cx, item.hir_id, &*method_sig.decl, None);
} }
} }

View file

@ -204,7 +204,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Types {
fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &TraitItem<'_>) { fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &TraitItem<'_>) {
match item.kind { match item.kind {
TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => self.check_ty(cx, ty, false), 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),
_ => (), _ => (),
} }
} }
@ -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<'_>) { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
match item.kind { match item.kind {
TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => self.check_type(cx, ty), 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 // methods with default impl are covered by check_fn
_ => (), _ => (),
} }