mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 00:53:31 +00:00
Stop visiting visibility.
This commit is contained in:
parent
60bb2a710e
commit
fabc26f7b7
8 changed files with 9 additions and 10 deletions
|
@ -82,7 +82,7 @@ impl CognitiveComplexity {
|
||||||
|
|
||||||
if rust_cc > self.limit.limit() {
|
if rust_cc > self.limit.limit() {
|
||||||
let fn_span = match kind {
|
let fn_span = match kind {
|
||||||
FnKind::ItemFn(ident, _, _, _) | FnKind::Method(ident, _, _) => ident.span,
|
FnKind::ItemFn(ident, _, _) | FnKind::Method(ident, _) => ident.span,
|
||||||
FnKind::Closure => {
|
FnKind::Closure => {
|
||||||
let header_span = body_span.with_hi(decl.output.span().lo());
|
let header_span = body_span.with_hi(decl.output.span().lo());
|
||||||
let pos = snippet_opt(cx, header_span).and_then(|snip| {
|
let pos = snippet_opt(cx, header_span).and_then(|snip| {
|
||||||
|
|
|
@ -17,8 +17,8 @@ pub(super) fn check_fn<'tcx>(
|
||||||
hir_id: hir::HirId,
|
hir_id: hir::HirId,
|
||||||
) {
|
) {
|
||||||
let unsafety = match kind {
|
let unsafety = match kind {
|
||||||
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }, _) => unsafety,
|
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }) => unsafety,
|
||||||
intravisit::FnKind::Method(_, sig, _) => sig.header.unsafety,
|
intravisit::FnKind::Method(_, sig) => sig.header.unsafety,
|
||||||
intravisit::FnKind::Closure => return,
|
intravisit::FnKind::Closure => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,8 @@ pub(super) fn check_fn(
|
||||||
header: hir::FnHeader { abi: Abi::Rust, .. },
|
header: hir::FnHeader { abi: Abi::Rust, .. },
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
_,
|
|
||||||
)
|
)
|
||||||
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }, _) => check_arg_number(
|
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }) => check_arg_number(
|
||||||
cx,
|
cx,
|
||||||
decl,
|
decl,
|
||||||
span.with_hi(decl.output.span().hi()),
|
span.with_hi(decl.output.span().hi()),
|
||||||
|
|
|
@ -85,7 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
match kind {
|
match kind {
|
||||||
FnKind::ItemFn(.., header, _) => {
|
FnKind::ItemFn(.., header) => {
|
||||||
let attrs = cx.tcx.hir().attrs(hir_id);
|
let attrs = cx.tcx.hir().attrs(hir_id);
|
||||||
if header.abi != Abi::Rust || requires_exact_signature(attrs) {
|
if header.abi != Abi::Rust || requires_exact_signature(attrs) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -251,7 +251,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
match kind {
|
match kind {
|
||||||
FnKind::ItemFn(.., header, _) => {
|
FnKind::ItemFn(.., header) => {
|
||||||
if header.abi != Abi::Rust {
|
if header.abi != Abi::Rust {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl<'tcx> LateLintPass<'tcx> for ReturnSelfNotMustUse {
|
||||||
) {
|
) {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
// We are only interested in methods, not in functions or associated functions.
|
// We are only interested in methods, not in functions or associated functions.
|
||||||
if matches!(kind, FnKind::Method(_, _, _));
|
if matches!(kind, FnKind::Method(_, _));
|
||||||
if let Some(fn_def) = cx.tcx.hir().opt_local_def_id(hir_id);
|
if let Some(fn_def) = cx.tcx.hir().opt_local_def_id(hir_id);
|
||||||
if let Some(impl_def) = cx.tcx.impl_of_method(fn_def.to_def_id());
|
if let Some(impl_def) = cx.tcx.impl_of_method(fn_def.to_def_id());
|
||||||
// We don't want this method to be te implementation of a trait because the
|
// We don't want this method to be te implementation of a trait because the
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync {
|
||||||
span: Span,
|
span: Span,
|
||||||
hir_id: HirId,
|
hir_id: HirId,
|
||||||
) {
|
) {
|
||||||
if let FnKind::ItemFn(_, _, FnHeader { asyncness, .. }, _) = &fn_kind {
|
if let FnKind::ItemFn(_, _, FnHeader { asyncness, .. }) = &fn_kind {
|
||||||
if matches!(asyncness, IsAsync::Async) {
|
if matches!(asyncness, IsAsync::Async) {
|
||||||
let mut visitor = AsyncFnVisitor { cx, found_await: false };
|
let mut visitor = AsyncFnVisitor { cx, found_await: false };
|
||||||
walk_fn(&mut visitor, fn_kind, fn_decl, body.id(), span, hir_id);
|
walk_fn(&mut visitor, fn_kind, fn_decl, body.id(), span, hir_id);
|
||||||
|
|
|
@ -1690,7 +1690,7 @@ pub fn if_sequence<'tcx>(mut expr: &'tcx Expr<'tcx>) -> (Vec<&'tcx Expr<'tcx>>,
|
||||||
|
|
||||||
/// Checks if the given function kind is an async function.
|
/// Checks if the given function kind is an async function.
|
||||||
pub fn is_async_fn(kind: FnKind<'_>) -> bool {
|
pub fn is_async_fn(kind: FnKind<'_>) -> bool {
|
||||||
matches!(kind, FnKind::ItemFn(_, _, header, _) if header.asyncness == IsAsync::Async)
|
matches!(kind, FnKind::ItemFn(_, _, header) if header.asyncness == IsAsync::Async)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Peels away all the compiler generated code surrounding the body of an async function,
|
/// Peels away all the compiler generated code surrounding the body of an async function,
|
||||||
|
|
Loading…
Reference in a new issue