-
Notifications
You must be signed in to change notification settings - Fork 12.7k
/
param-attrs-cfg.rs
79 lines (73 loc) · 2.21 KB
/
param-attrs-cfg.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// compile-flags: --cfg something
#![feature(param_attrs)]
#![deny(unused_variables)]
extern "C" {
fn ffi(
#[cfg(nothing)] a: i32,
#[cfg(something)] b: i32,
#[cfg_attr(something, cfg(nothing))] c: i32,
#[cfg_attr(nothing, cfg(nothing))] ...
);
}
type FnType = fn(
#[cfg(nothing)] a: i32,
#[cfg(something)] b: i32,
#[cfg_attr(nothing, cfg(nothing))] c: i32,
#[cfg_attr(something, cfg(nothing))] d: i32,
);
fn foo(
#[cfg(nothing)] a: i32,
#[cfg(something)] b: i32,
//~^ ERROR unused variable: `b` [unused_variables]
#[cfg_attr(nothing, cfg(nothing))] c: i32,
//~^ ERROR unused variable: `c` [unused_variables]
#[cfg_attr(something, cfg(nothing))] d: i32,
) {}
struct RefStruct {}
impl RefStruct {
fn bar(
&self,
#[cfg(nothing)] a: i32,
#[cfg(something)] b: i32,
//~^ ERROR unused variable: `b` [unused_variables]
#[cfg_attr(nothing, cfg(nothing))] c: i32,
//~^ ERROR unused variable: `c` [unused_variables]
#[cfg_attr(something, cfg(nothing))] d: i32,
) {}
}
trait RefTrait {
fn bar(
&self,
#[cfg(nothing)] a: i32,
#[cfg(something)] b: i32,
//~^ ERROR unused variable: `b` [unused_variables]
#[cfg_attr(nothing, cfg(nothing))] c: i32,
//~^ ERROR unused variable: `c` [unused_variables]
#[cfg_attr(something, cfg(nothing))] d: i32,
) {}
}
impl RefTrait for RefStruct {
fn bar(
&self,
#[cfg(nothing)] a: i32,
#[cfg(something)] b: i32,
//~^ ERROR unused variable: `b` [unused_variables]
#[cfg_attr(nothing, cfg(nothing))] c: i32,
//~^ ERROR unused variable: `c` [unused_variables]
#[cfg_attr(something, cfg(nothing))] d: i32,
) {}
}
fn main() {
let _: unsafe extern "C" fn(_, ...) = ffi;
let _: fn(_, _) = foo;
let _: FnType = |_, _| {};
let c = |
#[cfg(nothing)] a: i32,
#[cfg(something)] b: i32,
//~^ ERROR unused variable: `b` [unused_variables]
#[cfg_attr(nothing, cfg(nothing))] c: i32,
//~^ ERROR unused variable: `c` [unused_variables]
#[cfg_attr(something, cfg(nothing))] d: i32,
| {};
let _ = c(1, 2);
}