]> git.lizzy.rs Git - rust.git/blob - tests/ui/rfc-2565-param-attrs/param-attrs-allowed.rs
Rollup merge of #106766 - GuillaumeGomez:rm-stripper-dead-code, r=notriddle
[rust.git] / tests / ui / rfc-2565-param-attrs / param-attrs-allowed.rs
1 // check-pass
2 // compile-flags: --cfg something
3
4 #![deny(unused_mut)]
5
6 extern "C" {
7     fn ffi(
8         #[allow(unused_mut)] a: i32,
9         #[cfg(something)] b: i32,
10         #[cfg_attr(something, cfg(nothing))] c: i32,
11         #[forbid(unused_mut)] d: i32,
12         #[deny(unused_mut)] #[warn(unused_mut)] ...
13     );
14 }
15
16 type FnType = fn(
17     #[allow(unused_mut)] a: i32,
18     #[cfg(something)] b: i32,
19     #[cfg_attr(something, cfg(nothing))] c: i32,
20     #[forbid(unused_mut)] d: i32,
21     #[deny(unused_mut)] #[warn(unused_mut)] e: i32
22 );
23
24 pub fn foo(
25     #[allow(unused_mut)] a: i32,
26     #[cfg(something)] b: i32,
27     #[cfg_attr(something, cfg(nothing))] c: i32,
28     #[forbid(unused_mut)] d: i32,
29     #[deny(unused_mut)] #[warn(unused_mut)] _e: i32
30 ) {}
31
32 // self
33
34 struct SelfStruct {}
35 impl SelfStruct {
36     fn foo(
37         #[allow(unused_mut)] self,
38         #[cfg(something)] a: i32,
39         #[cfg_attr(something, cfg(nothing))]
40         #[deny(unused_mut)] b: i32,
41     ) {}
42 }
43
44 struct RefStruct {}
45 impl RefStruct {
46     fn foo(
47         #[allow(unused_mut)] &self,
48         #[cfg(something)] a: i32,
49         #[cfg_attr(something, cfg(nothing))]
50         #[deny(unused_mut)] b: i32,
51     ) {}
52 }
53 trait RefTrait {
54     fn foo(
55         #[forbid(unused_mut)] &self,
56         #[warn(unused_mut)] a: i32
57     ) {}
58 }
59 impl RefTrait for RefStruct {
60     fn foo(
61         #[forbid(unused_mut)] &self,
62         #[warn(unused_mut)] a: i32
63     ) {}
64 }
65
66 // Box<Self>
67
68 struct BoxSelfStruct {}
69 impl BoxSelfStruct {
70     fn foo(
71         #[allow(unused_mut)] self: Box<Self>,
72         #[cfg(something)] a: i32,
73         #[cfg_attr(something, cfg(nothing))]
74         #[deny(unused_mut)] b: i32,
75     ) {}
76 }
77 trait BoxSelfTrait {
78     fn foo(
79         #[forbid(unused_mut)] self: Box<Self>,
80         #[warn(unused_mut)] a: i32
81     ) {}
82 }
83 impl BoxSelfTrait for BoxSelfStruct {
84     fn foo(
85         #[forbid(unused_mut)] self: Box<Self>,
86         #[warn(unused_mut)] a: i32
87     ) {}
88 }
89
90 fn main() {
91     let _: unsafe extern "C" fn(_, _, _, ...) = ffi;
92     let _: fn(_, _, _, _) = foo;
93     let _: FnType = |_, _, _, _| {};
94     let c = |
95         #[allow(unused_mut)] a: u32,
96         #[cfg(something)] b: i32,
97         #[cfg_attr(something, cfg(nothing))]
98         #[deny(unused_mut)] c: i32,
99     | {};
100     let _ = c(1, 2);
101 }