]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs
Stabilize `param_attrs` in Rust 1.39.0
[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 }
55 trait RefTrait {
56     fn bar(
57         &self,
58         #[cfg(nothing)] a: i32,
59         #[cfg(something)] b: i32,
60         //~^ ERROR unused variable: `b`
61         #[cfg_attr(nothing, cfg(nothing))] c: i32,
62         //~^ ERROR unused variable: `c`
63         #[cfg_attr(something, cfg(nothing))] d: i32,
64     ) {}
65 }
66 impl RefTrait for RefStruct {
67     fn bar(
68         &self,
69         #[cfg(nothing)] a: i32,
70         #[cfg(something)] b: i32,
71         //~^ ERROR unused variable: `b`
72         #[cfg_attr(nothing, cfg(nothing))] c: i32,
73         //~^ ERROR unused variable: `c`
74         #[cfg_attr(something, cfg(nothing))] d: i32,
75     ) {}
76 }
77
78 fn main() {
79     let _: unsafe extern "C" fn(_, ...) = ffi;
80     let _: fn(_, _) = foo;
81     let _: FnType = |_, _| {};
82     let a = async move |
83         #[cfg(something)] a: i32,
84         //~^ ERROR unused variable: `a`
85         #[cfg(nothing)] b: i32,
86     | {};
87     let c = |
88         #[cfg(nothing)] a: i32,
89         #[cfg(something)] b: i32,
90         //~^ ERROR unused variable: `b`
91         #[cfg_attr(nothing, cfg(nothing))] c: i32,
92         //~^ ERROR unused variable: `c`
93         #[cfg_attr(something, cfg(nothing))] d: i32,
94     | {};
95     let _ = a(1);
96     let _ = c(1, 2);
97 }