File: param-attrs-cfg.rs

package info (click to toggle)
rustc-web 1.78.0%2Bdfsg1-2~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,245,420 kB
  • sloc: xml: 147,985; javascript: 18,022; sh: 11,083; python: 10,265; ansic: 6,172; cpp: 5,023; asm: 4,390; makefile: 4,269
file content (121 lines) | stat: -rw-r--r-- 3,383 bytes parent folder | download | duplicates (2)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//@ compile-flags: --cfg something
//@ edition:2018

#![feature(async_closure)]
#![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,
);

async fn foo_async(
    #[cfg(something)] a: i32,
    //~^ ERROR unused variable: `a`
    #[cfg(nothing)] b: i32,
) {}
fn foo(
    #[cfg(nothing)] a: i32,
    #[cfg(something)] b: i32,
    //~^ ERROR unused variable: `b`
    #[cfg_attr(nothing, cfg(nothing))] c: i32,
    //~^ ERROR unused variable: `c`
    #[cfg_attr(something, cfg(nothing))] d: i32,
) {}

struct RefStruct {}
impl RefStruct {
    async fn bar_async(
        &self,
        #[cfg(something)] a: i32,
        //~^ ERROR unused variable: `a`
        #[cfg(nothing)] b: i32,
    ) {}
    fn bar(
        &self,
        #[cfg(nothing)] a: i32,
        #[cfg(something)] b: i32,
        //~^ ERROR unused variable: `b`
        #[cfg_attr(nothing, cfg(nothing))] c: i32,
        //~^ ERROR unused variable: `c`
        #[cfg_attr(something, cfg(nothing))] d: i32,
    ) {}
    fn issue_64682_associated_fn(
        #[cfg(nothing)] a: i32,
        #[cfg(something)] b: i32,
        //~^ ERROR unused variable: `b`
        #[cfg_attr(nothing, cfg(nothing))] c: i32,
        //~^ ERROR unused variable: `c`
        #[cfg_attr(something, cfg(nothing))] d: i32,
    ) {}
}
trait RefTrait {
    fn bar(
        &self,
        #[cfg(nothing)] a: i32,
        #[cfg(something)] b: i32,
        //~^ ERROR unused variable: `b`
        #[cfg_attr(nothing, cfg(nothing))] c: i32,
        //~^ ERROR unused variable: `c`
        #[cfg_attr(something, cfg(nothing))] d: i32,
    ) {}
    fn issue_64682_associated_fn(
        #[cfg(nothing)] a: i32,
        #[cfg(something)] b: i32,
        //~^ ERROR unused variable: `b`
        #[cfg_attr(nothing, cfg(nothing))] c: i32,
        //~^ ERROR unused variable: `c`
        #[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`
        #[cfg_attr(nothing, cfg(nothing))] c: i32,
        //~^ ERROR unused variable: `c`
        #[cfg_attr(something, cfg(nothing))] d: i32,
    ) {}
    fn issue_64682_associated_fn(
        #[cfg(nothing)] a: i32,
        #[cfg(something)] b: i32,
        //~^ ERROR unused variable: `b`
        #[cfg_attr(nothing, cfg(nothing))] c: i32,
        //~^ ERROR unused variable: `c`
        #[cfg_attr(something, cfg(nothing))] d: i32,
    ) {}
}

fn main() {
    let _: unsafe extern "C" fn(_, ...) = ffi;
    let _: fn(_, _) = foo;
    let _: FnType = |_, _| {};
    let a = async move |
        #[cfg(something)] a: i32,
        //~^ ERROR unused variable: `a`
        #[cfg(nothing)] b: i32,
    | {};
    let c = |
        #[cfg(nothing)] a: i32,
        #[cfg(something)] b: i32,
        //~^ ERROR unused variable: `b`
        #[cfg_attr(nothing, cfg(nothing))] c: i32,
        //~^ ERROR unused variable: `c`
        #[cfg_attr(something, cfg(nothing))] d: i32,
    | {};
    a(1);
    c(1, 2);
}