Skip to content

#[allow(clippy::fn_params_excessive_bools)] doesn't work on methods #9687

Closed
@xFrednet

Description

@xFrednet

Description

Lint: clippy::fn_params_excessive_bools

#[allow(clippy::fn_params_excessive_bools)] works on functions and impl blocks, but not on individual methods inside an impl blocks. The problem seams to be, that methods are checked from the impl block, which doesn't process the lint attributes on special functions. See:

ItemKind::Impl(box Impl {
of_trait: None, items, ..
})
| ItemKind::Trait(box Trait { items, .. }) => {
for item in items {
if let AssocItemKind::Fn(box Fn { sig, .. }) = &item.kind {
self.check_fn_sig(cx, sig, item.span);
}
}
},

Example:

Playground

#![deny(clippy::fn_params_excessive_bools)]
#![allow(dead_code)]

pub struct Test;

impl Test {
    #[allow(clippy::fn_params_excessive_bools)]
    fn new(
        is_const: bool,
        is_async: bool,
        is_unsafe: bool,
        is_extern: bool,
        is_awesome: bool,
        is_special: bool,
    ) -> Self {
        let _b = is_const || is_async || is_unsafe || is_extern || is_awesome || is_special;
        todo!()
    }
}

Version

rustc 1.66.0-nightly (9062b780b 2022-09-21)
binary: rustc
commit-hash: 9062b780b32d2eab060b4432863e085d9504ca5c
commit-date: 2022-09-21
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.0

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions