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