mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-03 18:09:42 +00:00
Rustup rust-lang/rust#66188
This commit is contained in:
parent
4192dbedcb
commit
d4758420e6
9 changed files with 22 additions and 22 deletions
|
@ -355,7 +355,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
|
|||
}
|
||||
|
||||
fn is_relevant_item(cx: &LateContext<'_, '_>, item: &Item) -> bool {
|
||||
if let ItemKind::Fn(_, _, _, eid) = item.kind {
|
||||
if let ItemKind::Fn(_, _, eid) = item.kind {
|
||||
is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value)
|
||||
} else {
|
||||
true
|
||||
|
|
|
@ -126,8 +126,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown {
|
|||
}
|
||||
// no safety header
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(_, ref header, ..) => {
|
||||
if cx.access_levels.is_exported(item.hir_id) && header.unsafety == hir::Unsafety::Unsafe {
|
||||
hir::ItemKind::Fn(ref sig, ..) => {
|
||||
if cx.access_levels.is_exported(item.hir_id) && sig.header.unsafety == hir::Unsafety::Unsafe {
|
||||
span_lint(
|
||||
cx,
|
||||
MISSING_SAFETY_DOC,
|
||||
|
|
|
@ -208,7 +208,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
|
|||
match kind {
|
||||
hir::intravisit::FnKind::Method(
|
||||
_,
|
||||
&hir::MethodSig {
|
||||
&hir::FnSig {
|
||||
header: hir::FnHeader { abi: Abi::Rust, .. },
|
||||
..
|
||||
},
|
||||
|
@ -228,20 +228,20 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
|
|||
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
|
||||
let attr = must_use_attr(&item.attrs);
|
||||
if let hir::ItemKind::Fn(ref decl, ref _header, ref _generics, ref body_id) = item.kind {
|
||||
if let hir::ItemKind::Fn(ref sig, ref _generics, ref body_id) = item.kind {
|
||||
if let Some(attr) = attr {
|
||||
let fn_header_span = item.span.with_hi(decl.output.span().hi());
|
||||
check_needless_must_use(cx, decl, item.hir_id, item.span, fn_header_span, attr);
|
||||
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
|
||||
check_needless_must_use(cx, &sig.decl, item.hir_id, item.span, fn_header_span, attr);
|
||||
return;
|
||||
}
|
||||
if cx.access_levels.is_exported(item.hir_id) && !is_proc_macro(&item.attrs) {
|
||||
check_must_use_candidate(
|
||||
cx,
|
||||
decl,
|
||||
&sig.decl,
|
||||
cx.tcx.hir().body(*body_id),
|
||||
item.span,
|
||||
item.hir_id,
|
||||
item.span.with_hi(decl.output.span().hi()),
|
||||
item.span.with_hi(sig.decl.output.span().hi()),
|
||||
"this function could have a `#[must_use]` attribute",
|
||||
);
|
||||
}
|
||||
|
|
|
@ -59,8 +59,8 @@ declare_lint_pass!(Lifetimes => [NEEDLESS_LIFETIMES, EXTRA_UNUSED_LIFETIMES]);
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Lifetimes {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let ItemKind::Fn(ref decl, _, ref generics, id) = item.kind {
|
||||
check_fn_inner(cx, decl, Some(id), generics, item.span, true);
|
||||
if let ItemKind::Fn(ref sig, ref generics, id) = item.kind {
|
||||
check_fn_inner(cx, &sig.decl, Some(id), generics, item.span, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -352,8 +352,8 @@ impl<'a, 'tcx> Visitor<'tcx> for SimilarNamesLocalVisitor<'a, 'tcx> {
|
|||
|
||||
impl EarlyLintPass for NonExpressiveNames {
|
||||
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
|
||||
if let ItemKind::Fn(ref decl, _, _, ref blk) = item.kind {
|
||||
do_check(self, cx, &item.attrs, decl, blk);
|
||||
if let ItemKind::Fn(ref sig, _, ref blk) = item.kind {
|
||||
do_check(self, cx, &item.attrs, &sig.decl, blk);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,8 +101,8 @@ declare_lint_pass!(Ptr => [PTR_ARG, CMP_NULL, MUT_FROM_REF]);
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let ItemKind::Fn(ref decl, _, _, body_id) = item.kind {
|
||||
check_fn(cx, decl, item.hir_id, Some(body_id));
|
||||
if let ItemKind::Fn(ref sig, _, body_id) = item.kind {
|
||||
check_fn(cx, &sig.decl, item.hir_id, Some(body_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1408,7 +1408,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(MethodSig { ref decl, .. }, TraitMethod::Required(_)) => self.check_fndecl(cx, decl),
|
||||
TraitItemKind::Method(FnSig { ref decl, .. }, TraitMethod::Required(_)) => self.check_fndecl(cx, decl),
|
||||
// methods with default impl are covered by check_fn
|
||||
_ => (),
|
||||
}
|
||||
|
@ -2118,10 +2118,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher {
|
|||
);
|
||||
}
|
||||
},
|
||||
ItemKind::Fn(ref decl, .., ref generics, body_id) => {
|
||||
ItemKind::Fn(ref sig, ref generics, body_id) => {
|
||||
let body = cx.tcx.hir().body(body_id);
|
||||
|
||||
for ty in &decl.inputs {
|
||||
for ty in &sig.decl.inputs {
|
||||
let mut vis = ImplicitHasherTypeVisitor::new(cx);
|
||||
vis.visit_ty(ty);
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
|
|||
if let Some(impl_trait_ref) = impl_trait_ref {
|
||||
for impl_item_ref in refs {
|
||||
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
|
||||
if let ImplItemKind::Method(MethodSig{ decl: impl_decl, .. }, impl_body_id)
|
||||
if let ImplItemKind::Method(FnSig{ decl: impl_decl, .. }, impl_body_id)
|
||||
= &impl_item.kind {
|
||||
let item_type = cx.tcx.type_of(impl_def_id);
|
||||
check_trait_method_impl_decl(cx, item_type, impl_item, impl_decl, &impl_trait_ref);
|
||||
|
|
|
@ -87,9 +87,9 @@ pub fn in_constant(cx: &LateContext<'_, '_>, id: HirId) -> bool {
|
|||
..
|
||||
}) => true,
|
||||
Node::Item(&Item {
|
||||
kind: ItemKind::Fn(_, header, ..),
|
||||
kind: ItemKind::Fn(ref sig, ..),
|
||||
..
|
||||
}) => header.constness == Constness::Const,
|
||||
}) => sig.header.constness == Constness::Const,
|
||||
Node::ImplItem(&ImplItem {
|
||||
kind: ImplItemKind::Method(ref sig, _),
|
||||
..
|
||||
|
@ -635,7 +635,7 @@ pub fn get_enclosing_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, hir_id: HirId)
|
|||
match node {
|
||||
Node::Block(block) => Some(block),
|
||||
Node::Item(&Item {
|
||||
kind: ItemKind::Fn(_, _, _, eid),
|
||||
kind: ItemKind::Fn(_, _, eid),
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(&ImplItem {
|
||||
|
|
Loading…
Reference in a new issue