Skip to content

Commit 476c528

Browse files
committed
Do not store attrs in FnKind.
1 parent 8d5e0f5 commit 476c528

10 files changed

+19
-20
lines changed

clippy_lints/src/cognitive_complexity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ impl CognitiveComplexity {
7676

7777
if rust_cc > self.limit.limit() {
7878
let fn_span = match kind {
79-
FnKind::ItemFn(ident, _, _, _, _) | FnKind::Method(ident, _, _, _) => ident.span,
80-
FnKind::Closure(_) => {
79+
FnKind::ItemFn(ident, _, _, _) | FnKind::Method(ident, _, _) => ident.span,
80+
FnKind::Closure => {
8181
let header_span = body_span.with_hi(decl.output.span().lo());
8282
let pos = snippet_opt(cx, header_span).and_then(|snip| {
8383
let low_offset = snip.find('|')?;

clippy_lints/src/functions.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
251251
hir_id: hir::HirId,
252252
) {
253253
let unsafety = match kind {
254-
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }, _, _) => unsafety,
255-
intravisit::FnKind::Method(_, sig, _, _) => sig.header.unsafety,
256-
intravisit::FnKind::Closure(_) => return,
254+
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }, _) => unsafety,
255+
intravisit::FnKind::Method(_, sig, _) => sig.header.unsafety,
256+
intravisit::FnKind::Closure => return,
257257
};
258258

259259
// don't warn for implementations, it's not their fault
@@ -267,9 +267,8 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
267267
..
268268
},
269269
_,
270-
_,
271270
)
272-
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }, _, _) => {
271+
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }, _) => {
273272
self.check_arg_number(cx, decl, span.with_hi(decl.output.span().hi()))
274273
},
275274
_ => {},

clippy_lints/src/future_not_send.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
5858
_: Span,
5959
hir_id: HirId,
6060
) {
61-
if let FnKind::Closure(_) = kind {
61+
if let FnKind::Closure = kind {
6262
return;
6363
}
6464
let ret_ty = utils::return_ty(cx, hir_id);

clippy_lints/src/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl<'tcx> LateLintPass<'tcx> for MiscLints {
278278
span: Span,
279279
_: HirId,
280280
) {
281-
if let FnKind::Closure(_) = k {
281+
if let FnKind::Closure = k {
282282
// Does not apply to closures
283283
return;
284284
}

clippy_lints/src/missing_const_for_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
133133
return;
134134
}
135135
},
136-
FnKind::Closure(..) => return,
136+
FnKind::Closure => return,
137137
}
138138

139139
let mir = cx.tcx.optimized_mir(def_id);

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
8080
}
8181

8282
match kind {
83-
FnKind::ItemFn(.., header, _, attrs) => {
83+
FnKind::ItemFn(.., header, _) => {
84+
let attrs = cx.tcx.hir().attrs(hir_id);
8485
if header.abi != Abi::Rust || requires_exact_signature(attrs) {
8586
return;
8687
}
8788
},
8889
FnKind::Method(..) => (),
89-
FnKind::Closure(..) => return,
90+
FnKind::Closure => return,
9091
}
9192

9293
// Exclude non-inherent impls

clippy_lints/src/panic_in_result_fn.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicInResultFn {
4343
span: Span,
4444
hir_id: hir::HirId,
4545
) {
46-
if !matches!(fn_kind, FnKind::Closure(_))
47-
&& is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym::result_type)
48-
{
46+
if !matches!(fn_kind, FnKind::Closure) && is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym::result_type) {
4947
lint_impl_body(cx, span, body);
5048
}
5149
}

clippy_lints/src/pass_by_ref_or_value.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,11 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
224224
}
225225

226226
match kind {
227-
FnKind::ItemFn(.., header, _, attrs) => {
227+
FnKind::ItemFn(.., header, _) => {
228228
if header.abi != Abi::Rust {
229229
return;
230230
}
231+
let attrs = cx.tcx.hir().attrs(hir_id);
231232
for a in attrs {
232233
if let Some(meta_items) = a.meta_item_list() {
233234
if a.has_name(sym::proc_macro_derive)
@@ -239,7 +240,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
239240
}
240241
},
241242
FnKind::Method(..) => (),
242-
FnKind::Closure(..) => return,
243+
FnKind::Closure => return,
243244
}
244245

245246
// Exclude non-inherent impls

clippy_lints/src/returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl<'tcx> LateLintPass<'tcx> for Return {
131131
_: HirId,
132132
) {
133133
match kind {
134-
FnKind::Closure(_) => {
134+
FnKind::Closure => {
135135
// when returning without value in closure, replace this `return`
136136
// with an empty block to prevent invalid suggestion (see #6501)
137137
let replacement = if let ExprKind::Ret(None) = &body.value.kind {

clippy_lints/src/unnecessary_wraps.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps {
6666
) {
6767
// Abort if public function/method or closure.
6868
match fn_kind {
69-
FnKind::ItemFn(.., visibility, _) | FnKind::Method(.., Some(visibility), _) => {
69+
FnKind::ItemFn(.., visibility) | FnKind::Method(.., Some(visibility)) => {
7070
if visibility.node.is_pub() {
7171
return;
7272
}
7373
},
74-
FnKind::Closure(..) => return,
74+
FnKind::Closure => return,
7575
_ => (),
7676
}
7777

0 commit comments

Comments
 (0)