]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs
Rollup merge of #60772 - timvermeulen:slice_iter_nth_back, r=scottmcm
[rust.git] / src / test / ui / rfc-2565-param-attrs / param-attrs-cfg.rs
1 // compile-flags: --cfg something
2
3 #![feature(param_attrs)]
4 #![deny(unused_variables)]
5
6 extern "C" {
7     fn ffi(
8         #[cfg(nothing)] a: i32,
9         #[cfg(something)] b: i32,
10         #[cfg_attr(something, cfg(nothing))] c: i32,
11         #[cfg_attr(nothing, cfg(nothing))] ...
12     );
13 }
14
15 type FnType = fn(
16     #[cfg(nothing)] a: i32,
17     #[cfg(something)] b: i32,
18     #[cfg_attr(nothing, cfg(nothing))] c: i32,
19     #[cfg_attr(something, cfg(nothing))] d: i32,
20 );
21
22 fn foo(
23     #[cfg(nothing)] a: i32,
24     #[cfg(something)] b: i32,
25     //~^ ERROR unused variable: `b` [unused_variables]
26     #[cfg_attr(nothing, cfg(nothing))] c: i32,
27     //~^ ERROR unused variable: `c` [unused_variables]
28     #[cfg_attr(something, cfg(nothing))] d: i32,
29 ) {}
30
31 struct RefStruct {}
32 impl RefStruct {
33     fn bar(
34         &self,
35         #[cfg(nothing)] a: i32,
36         #[cfg(something)] b: i32,
37         //~^ ERROR unused variable: `b` [unused_variables]
38         #[cfg_attr(nothing, cfg(nothing))] c: i32,
39         //~^ ERROR unused variable: `c` [unused_variables]
40         #[cfg_attr(something, cfg(nothing))] d: i32,
41     ) {}
42 }
43 trait RefTrait {
44     fn bar(
45         &self,
46         #[cfg(nothing)] a: i32,
47         #[cfg(something)] b: i32,
48         //~^ ERROR unused variable: `b` [unused_variables]
49         #[cfg_attr(nothing, cfg(nothing))] c: i32,
50         //~^ ERROR unused variable: `c` [unused_variables]
51         #[cfg_attr(something, cfg(nothing))] d: i32,
52     ) {}
53 }
54 impl RefTrait for RefStruct {
55     fn bar(
56         &self,
57         #[cfg(nothing)] a: i32,
58         #[cfg(something)] b: i32,
59         //~^ ERROR unused variable: `b` [unused_variables]
60         #[cfg_attr(nothing, cfg(nothing))] c: i32,
61         //~^ ERROR unused variable: `c` [unused_variables]
62         #[cfg_attr(something, cfg(nothing))] d: i32,
63     ) {}
64 }
65
66 fn main() {
67     let _: unsafe extern "C" fn(_, ...) = ffi;
68     let _: fn(_, _) = foo;
69     let _: FnType = |_, _| {};
70     let c = |
71         #[cfg(nothing)] a: i32,
72         #[cfg(something)] b: i32,
73         //~^ ERROR unused variable: `b` [unused_variables]
74         #[cfg_attr(nothing, cfg(nothing))] c: i32,
75         //~^ ERROR unused variable: `c` [unused_variables]
76         #[cfg_attr(something, cfg(nothing))] d: i32,
77     | {};
78     let _ = c(1, 2);
79 }