]> git.lizzy.rs Git - rust.git/blob - tests/ui/fn_params_excessive_bools.rs
Auto merge of #9698 - kraktus:xc_bool, r=xFrednet
[rust.git] / tests / ui / fn_params_excessive_bools.rs
1 #![warn(clippy::fn_params_excessive_bools)]
2 #![allow(clippy::too_many_arguments)]
3
4 extern "C" {
5     // Should not lint, most of the time users have no control over extern function signatures
6     fn f(_: bool, _: bool, _: bool, _: bool);
7 }
8
9 macro_rules! foo {
10     () => {
11         fn fff(_: bool, _: bool, _: bool, _: bool) {}
12     };
13 }
14
15 foo!();
16
17 #[no_mangle]
18 extern "C" fn k(_: bool, _: bool, _: bool, _: bool) {}
19 fn g(_: bool, _: bool, _: bool, _: bool) {}
20 fn h(_: bool, _: bool, _: bool) {}
21 fn e(_: S, _: S, _: Box<S>, _: Vec<u32>) {}
22 fn t(_: S, _: S, _: Box<S>, _: Vec<u32>, _: bool, _: bool, _: bool, _: bool) {}
23
24 struct S;
25 trait Trait {
26     // should warn for trait functions with and without body
27     fn f(_: bool, _: bool, _: bool, _: bool);
28     fn g(_: bool, _: bool, _: bool, _: Vec<u32>);
29     #[allow(clippy::fn_params_excessive_bools)]
30     fn h(_: bool, _: bool, _: bool, _: bool, _: bool, _: bool);
31     fn i(_: bool, _: bool, _: bool, _: bool) {}
32 }
33
34 impl S {
35     fn f(&self, _: bool, _: bool, _: bool, _: bool) {}
36     fn g(&self, _: bool, _: bool, _: bool) {}
37     #[no_mangle]
38     extern "C" fn h(_: bool, _: bool, _: bool, _: bool) {}
39 }
40
41 impl Trait for S {
42     // Should not lint because the trait might not be changeable by the user
43     // We only lint in the trait definition
44     fn f(_: bool, _: bool, _: bool, _: bool) {}
45     fn g(_: bool, _: bool, _: bool, _: Vec<u32>) {}
46     fn h(_: bool, _: bool, _: bool, _: bool, _: bool, _: bool) {}
47 }
48
49 fn main() {
50     fn n(_: bool, _: u32, _: bool, _: Box<u32>, _: bool, _: bool) {
51         fn nn(_: bool, _: bool, _: bool, _: bool) {}
52     }
53 }