Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f416f26

Browse files
committed
turn hir::ItemKind::Fn into a named-field variant
1 parent 1cc5051 commit f416f26

23 files changed

+50
-26
lines changed

clippy_lints/src/arbitrary_source_item_ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ fn convert_module_item_kind(value: &ItemKind<'_>) -> SourceItemOrderingModuleIte
464464
ItemKind::Use(..) => Use,
465465
ItemKind::Static(..) => Static,
466466
ItemKind::Const(..) => Const,
467-
ItemKind::Fn(..) => Fn,
467+
ItemKind::Fn{ .. } => Fn,
468468
ItemKind::Macro(..) => Macro,
469469
ItemKind::Mod(..) => Mod,
470470
ItemKind::ForeignMod { .. } => ForeignMod,

clippy_lints/src/attrs/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(super) fn is_lint_level(symbol: Symbol, attr_id: AttrId) -> bool {
2121
}
2222

2323
pub(super) fn is_relevant_item(cx: &LateContext<'_>, item: &Item<'_>) -> bool {
24-
if let ItemKind::Fn(_, _, eid) = item.kind {
24+
if let ItemKind::Fn { body: eid, .. } = item.kind {
2525
is_relevant_expr(cx, cx.tcx.typeck_body(eid), cx.tcx.hir().body(eid).value)
2626
} else {
2727
true

clippy_lints/src/doc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
639639
self.check_private_items,
640640
);
641641
match item.kind {
642-
ItemKind::Fn(sig, _, body_id) => {
642+
ItemKind::Fn { sig, body: body_id, .. } => {
643643
if !(is_entrypoint_fn(cx, item.owner_id.to_def_id())
644644
|| in_external_macro(cx.tcx.sess, item.span))
645645
{

clippy_lints/src/doc/too_long_first_doc_paragraph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(super) fn check(
2525
// page. So associated items or impl blocks are not part of this list.
2626
ItemKind::Static(..)
2727
| ItemKind::Const(..)
28-
| ItemKind::Fn(..)
28+
| ItemKind::Fn{ .. }
2929
| ItemKind::Macro(..)
3030
| ItemKind::Mod(..)
3131
| ItemKind::TyAlias(..)

clippy_lints/src/exit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'tcx> LateLintPass<'tcx> for Exit {
4848
&& let Some(def_id) = cx.qpath_res(path, path_expr.hir_id).opt_def_id()
4949
&& cx.tcx.is_diagnostic_item(sym::process_exit, def_id)
5050
&& let parent = cx.tcx.hir().get_parent_item(e.hir_id)
51-
&& let OwnerNode::Item(Item{kind: ItemKind::Fn(..), ..}) = cx.tcx.hir_owner_node(parent)
51+
&& let OwnerNode::Item(Item{kind: ItemKind::Fn{ .. }, ..}) = cx.tcx.hir_owner_node(parent)
5252
// If the next item up is a function we check if it is an entry point
5353
// and only then emit a linter warning
5454
&& !is_entrypoint_fn(cx, parent.to_def_id())

clippy_lints/src/extra_unused_type_parameters.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,11 @@ fn is_empty_body(cx: &LateContext<'_>, body: BodyId) -> bool {
253253

254254
impl<'tcx> LateLintPass<'tcx> for ExtraUnusedTypeParameters {
255255
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
256-
if let ItemKind::Fn(_, generics, body_id) = item.kind
256+
if let ItemKind::Fn {
257+
generics,
258+
body: body_id,
259+
..
260+
} = item.kind
257261
&& !generics.params.is_empty()
258262
&& !is_empty_body(cx, body_id)
259263
&& (!self.avoid_breaking_exported_api || !cx.effective_visibilities.is_exported(item.owner_id.def_id))

clippy_lints/src/functions/must_use.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ use super::{DOUBLE_MUST_USE, MUST_USE_CANDIDATE, MUST_USE_UNIT};
2424
pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
2525
let attrs = cx.tcx.hir().attrs(item.hir_id());
2626
let attr = cx.tcx.get_attr(item.owner_id, sym::must_use);
27-
if let hir::ItemKind::Fn(ref sig, _generics, ref body_id) = item.kind {
27+
if let hir::ItemKind::Fn {
28+
ref sig,
29+
body: ref body_id,
30+
..
31+
} = item.kind
32+
{
2833
let is_public = cx.effective_visibilities.is_exported(item.owner_id.def_id);
2934
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
3035
if let Some(attr) = attr {

clippy_lints/src/functions/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn result_err_ty<'tcx>(
3636
}
3737

3838
pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &hir::Item<'tcx>, large_err_threshold: u64, msrv: &Msrv) {
39-
if let hir::ItemKind::Fn(ref sig, _generics, _) = item.kind
39+
if let hir::ItemKind::Fn { ref sig, .. } = item.kind
4040
&& let Some((hir_ty, err_ty)) = result_err_ty(cx, sig.decl, item.owner_id.def_id, item.span)
4141
{
4242
if cx.effective_visibilities.is_exported(item.owner_id.def_id) {

clippy_lints/src/implicit_hasher.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
149149
);
150150
}
151151
},
152-
ItemKind::Fn(ref sig, generics, body_id) => {
152+
ItemKind::Fn {
153+
ref sig,
154+
generics,
155+
body: body_id,
156+
..
157+
} => {
153158
let body = cx.tcx.hir().body(body_id);
154159

155160
for ty in sig.decl.inputs {

clippy_lints/src/lifetimes.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ declare_lint_pass!(Lifetimes => [NEEDLESS_LIFETIMES, EXTRA_UNUSED_LIFETIMES]);
9595

9696
impl<'tcx> LateLintPass<'tcx> for Lifetimes {
9797
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
98-
if let ItemKind::Fn(ref sig, generics, id) = item.kind {
98+
if let ItemKind::Fn {
99+
ref sig,
100+
generics,
101+
body: id,
102+
..
103+
} = item.kind
104+
{
99105
check_fn_inner(cx, sig, Some(id), None, generics, item.span, true);
100106
} else if let ItemKind::Impl(impl_) = item.kind {
101107
if !item.span.from_expansion() {

0 commit comments

Comments
 (0)