mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Auto merge of #5307 - JohnTitor:rename-method, r=flip1995
Rustup to rust-lang/rust#69674 changelog: none
This commit is contained in:
commit
b064ea8096
12 changed files with 14 additions and 14 deletions
|
@ -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,
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()));
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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),
|
||||||
|
|
|
@ -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, ..)
|
||||||
),
|
),
|
||||||
|
|
|
@ -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",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue