]> git.proxmox.com Git - rustc.git/blame - src/test/ui/rfc-2565-param-attrs/param-attrs-cfg.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / rfc-2565-param-attrs / param-attrs-cfg.rs
CommitLineData
dc9dc135 1// compile-flags: --cfg something
416331ca 2// edition:2018
dc9dc135 3
e1599b0c 4#![feature(async_closure)]
dc9dc135
XL
5#![deny(unused_variables)]
6
7extern "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
16type 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
416331ca
XL
23async fn foo_async(
24 #[cfg(something)] a: i32,
25 //~^ ERROR unused variable: `a`
26 #[cfg(nothing)] b: i32,
27) {}
dc9dc135
XL
28fn foo(
29 #[cfg(nothing)] a: i32,
30 #[cfg(something)] b: i32,
416331ca 31 //~^ ERROR unused variable: `b`
dc9dc135 32 #[cfg_attr(nothing, cfg(nothing))] c: i32,
416331ca 33 //~^ ERROR unused variable: `c`
dc9dc135
XL
34 #[cfg_attr(something, cfg(nothing))] d: i32,
35) {}
36
37struct RefStruct {}
38impl RefStruct {
416331ca
XL
39 async fn bar_async(
40 &self,
41 #[cfg(something)] a: i32,
42 //~^ ERROR unused variable: `a`
43 #[cfg(nothing)] b: i32,
44 ) {}
dc9dc135
XL
45 fn bar(
46 &self,
47 #[cfg(nothing)] a: i32,
48 #[cfg(something)] b: i32,
416331ca 49 //~^ ERROR unused variable: `b`
dc9dc135 50 #[cfg_attr(nothing, cfg(nothing))] c: i32,
416331ca 51 //~^ ERROR unused variable: `c`
dc9dc135
XL
52 #[cfg_attr(something, cfg(nothing))] d: i32,
53 ) {}
e1599b0c
XL
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 ) {}
dc9dc135
XL
62}
63trait RefTrait {
64 fn bar(
65 &self,
66 #[cfg(nothing)] a: i32,
67 #[cfg(something)] b: i32,
416331ca 68 //~^ ERROR unused variable: `b`
dc9dc135 69 #[cfg_attr(nothing, cfg(nothing))] c: i32,
416331ca 70 //~^ ERROR unused variable: `c`
dc9dc135
XL
71 #[cfg_attr(something, cfg(nothing))] d: i32,
72 ) {}
e1599b0c
XL
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 ) {}
dc9dc135
XL
81}
82impl RefTrait for RefStruct {
83 fn bar(
84 &self,
85 #[cfg(nothing)] a: i32,
86 #[cfg(something)] b: i32,
416331ca 87 //~^ ERROR unused variable: `b`
dc9dc135 88 #[cfg_attr(nothing, cfg(nothing))] c: i32,
416331ca 89 //~^ ERROR unused variable: `c`
dc9dc135
XL
90 #[cfg_attr(something, cfg(nothing))] d: i32,
91 ) {}
e1599b0c
XL
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 ) {}
dc9dc135
XL
100}
101
102fn main() {
103 let _: unsafe extern "C" fn(_, ...) = ffi;
104 let _: fn(_, _) = foo;
105 let _: FnType = |_, _| {};
416331ca
XL
106 let a = async move |
107 #[cfg(something)] a: i32,
108 //~^ ERROR unused variable: `a`
109 #[cfg(nothing)] b: i32,
110 | {};
dc9dc135
XL
111 let c = |
112 #[cfg(nothing)] a: i32,
113 #[cfg(something)] b: i32,
416331ca 114 //~^ ERROR unused variable: `b`
dc9dc135 115 #[cfg_attr(nothing, cfg(nothing))] c: i32,
416331ca 116 //~^ ERROR unused variable: `c`
dc9dc135
XL
117 #[cfg_attr(something, cfg(nothing))] d: i32,
118 | {};
416331ca 119 let _ = a(1);
dc9dc135
XL
120 let _ = c(1, 2);
121}