]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs
Rollup merge of #103159 - cuviper:check_pow-final-try_opt, r=Mark-Simulacrum
[rust.git] / src / test / ui / rfc-2565-param-attrs / param-attrs-cfg.rs
1 // compile-flags: --cfg something
2 // edition:2018
3
4 #![feature(async_closure)]
5 #![deny(unused_variables)]
6
7 extern "C" {
8     fn ffi(
9         #[cfg(nothing)] a: i32,
10         #[cfg(something)] b: i32,
11         #[cfg_attr(something, cfg(nothing))] c: i32,
12         #[cfg_attr(nothing, cfg(nothing))] ...
13     );
14 }
15
16 type FnType = fn(
17     #[cfg(nothing)] a: i32,
18     #[cfg(something)] b: i32,
19     #[cfg_attr(nothing, cfg(nothing))] c: i32,
20     #[cfg_attr(something, cfg(nothing))] d: i32,
21 );
22
23 async fn foo_async(
24     #[cfg(something)] a: i32,
25     //~^ ERROR unused variable: `a`
26     #[cfg(nothing)] b: i32,
27 ) {}
28 fn foo(
29     #[cfg(nothing)] a: i32,
30     #[cfg(something)] b: i32,
31     //~^ ERROR unused variable: `b`
32     #[cfg_attr(nothing, cfg(nothing))] c: i32,
33     //~^ ERROR unused variable: `c`
34     #[cfg_attr(something, cfg(nothing))] d: i32,
35 ) {}
36
37 struct RefStruct {}
38 impl RefStruct {
39     async fn bar_async(
40         &self,
41         #[cfg(something)] a: i32,
42         //~^ ERROR unused variable: `a`
43         #[cfg(nothing)] b: i32,
44     ) {}
45     fn bar(
46         &self,
47         #[cfg(nothing)] a: i32,
48         #[cfg(something)] b: i32,
49         //~^ ERROR unused variable: `b`
50         #[cfg_attr(nothing, cfg(nothing))] c: i32,
51         //~^ ERROR unused variable: `c`
52         #[cfg_attr(something, cfg(nothing))] d: i32,
53     ) {}
54     fn issue_64682_associated_fn(
55         #[cfg(nothing)] a: i32,
56         #[cfg(something)] b: i32,
57         //~^ ERROR unused variable: `b`
58         #[cfg_attr(nothing, cfg(nothing))] c: i32,
59         //~^ ERROR unused variable: `c`
60         #[cfg_attr(something, cfg(nothing))] d: i32,
61     ) {}
62 }
63 trait RefTrait {
64     fn bar(
65         &self,
66         #[cfg(nothing)] a: i32,
67         #[cfg(something)] b: i32,
68         //~^ ERROR unused variable: `b`
69         #[cfg_attr(nothing, cfg(nothing))] c: i32,
70         //~^ ERROR unused variable: `c`
71         #[cfg_attr(something, cfg(nothing))] d: i32,
72     ) {}
73     fn issue_64682_associated_fn(
74         #[cfg(nothing)] a: i32,
75         #[cfg(something)] b: i32,
76         //~^ ERROR unused variable: `b`
77         #[cfg_attr(nothing, cfg(nothing))] c: i32,
78         //~^ ERROR unused variable: `c`
79         #[cfg_attr(something, cfg(nothing))] d: i32,
80     ) {}
81 }
82 impl RefTrait for RefStruct {
83     fn bar(
84         &self,
85         #[cfg(nothing)] a: i32,
86         #[cfg(something)] b: i32,
87         //~^ ERROR unused variable: `b`
88         #[cfg_attr(nothing, cfg(nothing))] c: i32,
89         //~^ ERROR unused variable: `c`
90         #[cfg_attr(something, cfg(nothing))] d: i32,
91     ) {}
92     fn issue_64682_associated_fn(
93         #[cfg(nothing)] a: i32,
94         #[cfg(something)] b: i32,
95         //~^ ERROR unused variable: `b`
96         #[cfg_attr(nothing, cfg(nothing))] c: i32,
97         //~^ ERROR unused variable: `c`
98         #[cfg_attr(something, cfg(nothing))] d: i32,
99     ) {}
100 }
101
102 fn main() {
103     let _: unsafe extern "C" fn(_, ...) = ffi;
104     let _: fn(_, _) = foo;
105     let _: FnType = |_, _| {};
106     let a = async move |
107         #[cfg(something)] a: i32,
108         //~^ ERROR unused variable: `a`
109         #[cfg(nothing)] b: i32,
110     | {};
111     let c = |
112         #[cfg(nothing)] a: i32,
113         #[cfg(something)] b: i32,
114         //~^ ERROR unused variable: `b`
115         #[cfg_attr(nothing, cfg(nothing))] c: i32,
116         //~^ ERROR unused variable: `c`
117         #[cfg_attr(something, cfg(nothing))] d: i32,
118     | {};
119     let _ = a(1);
120     let _ = c(1, 2);
121 }