2020-02-01 17:49:52 -06:00
|
|
|
#![warn(clippy::fn_params_excessive_bools)]
|
2021-07-20 22:23:22 -05:00
|
|
|
#![allow(clippy::too_many_arguments)]
|
2020-02-01 17:49:52 -06:00
|
|
|
|
|
|
|
extern "C" {
|
2022-10-28 07:54:59 -05:00
|
|
|
// Should not lint, most of the time users have no control over extern function signatures
|
2020-02-01 17:49:52 -06:00
|
|
|
fn f(_: bool, _: bool, _: bool, _: bool);
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! foo {
|
|
|
|
() => {
|
|
|
|
fn fff(_: bool, _: bool, _: bool, _: bool) {}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
foo!();
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
extern "C" fn k(_: bool, _: bool, _: bool, _: bool) {}
|
|
|
|
fn g(_: bool, _: bool, _: bool, _: bool) {}
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: more than 3 bools in function parameters
|
2020-02-01 17:49:52 -06:00
|
|
|
fn h(_: bool, _: bool, _: bool) {}
|
|
|
|
fn e(_: S, _: S, _: Box<S>, _: Vec<u32>) {}
|
|
|
|
fn t(_: S, _: S, _: Box<S>, _: Vec<u32>, _: bool, _: bool, _: bool, _: bool) {}
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: more than 3 bools in function parameters
|
2020-02-01 17:49:52 -06:00
|
|
|
|
2022-03-27 07:41:09 -05:00
|
|
|
struct S;
|
2020-02-01 17:49:52 -06:00
|
|
|
trait Trait {
|
2022-11-07 14:00:37 -06:00
|
|
|
// should warn for trait functions with and without body
|
2020-02-01 17:49:52 -06:00
|
|
|
fn f(_: bool, _: bool, _: bool, _: bool);
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: more than 3 bools in function parameters
|
2020-02-01 17:49:52 -06:00
|
|
|
fn g(_: bool, _: bool, _: bool, _: Vec<u32>);
|
2022-10-29 10:43:43 -05:00
|
|
|
#[allow(clippy::fn_params_excessive_bools)]
|
|
|
|
fn h(_: bool, _: bool, _: bool, _: bool, _: bool, _: bool);
|
2022-11-07 14:00:37 -06:00
|
|
|
fn i(_: bool, _: bool, _: bool, _: bool) {}
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: more than 3 bools in function parameters
|
2020-02-01 17:49:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl S {
|
|
|
|
fn f(&self, _: bool, _: bool, _: bool, _: bool) {}
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: more than 3 bools in function parameters
|
2020-02-01 17:49:52 -06:00
|
|
|
fn g(&self, _: bool, _: bool, _: bool) {}
|
|
|
|
#[no_mangle]
|
|
|
|
extern "C" fn h(_: bool, _: bool, _: bool, _: bool) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Trait for S {
|
2022-10-29 09:12:41 -05:00
|
|
|
// Should not lint because the trait might not be changeable by the user
|
|
|
|
// We only lint in the trait definition
|
2020-02-01 17:49:52 -06:00
|
|
|
fn f(_: bool, _: bool, _: bool, _: bool) {}
|
|
|
|
fn g(_: bool, _: bool, _: bool, _: Vec<u32>) {}
|
2022-10-29 10:43:43 -05:00
|
|
|
fn h(_: bool, _: bool, _: bool, _: bool, _: bool, _: bool) {}
|
2020-02-01 17:49:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
fn n(_: bool, _: u32, _: bool, _: Box<u32>, _: bool, _: bool) {
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: more than 3 bools in function parameters
|
2020-02-01 17:49:52 -06:00
|
|
|
fn nn(_: bool, _: bool, _: bool, _: bool) {}
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: more than 3 bools in function parameters
|
2020-02-01 17:49:52 -06:00
|
|
|
}
|
|
|
|
}
|