File tree Expand file tree Collapse file tree 2 files changed +77
-0
lines changed Expand file tree Collapse file tree 2 files changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ allow( unused) ]
2
+ #![ warn( clippy:: cfg_not_test) ]
3
+
4
+ fn important_check ( ) { }
5
+
6
+ fn main ( ) {
7
+ // Statement
8
+ #[ cfg( not( test) ) ]
9
+ let answer = 42 ;
10
+
11
+ // Expression
12
+ #[ cfg( not( test) ) ]
13
+ important_check ( ) ;
14
+
15
+ // Make sure only not(test) are checked, not other attributes
16
+ #[ cfg( not( foo) ) ]
17
+ important_check ( ) ;
18
+ }
19
+
20
+ #[ cfg( not( not( test) ) ) ]
21
+ struct CfgNotTest ;
22
+
23
+ // Deeply nested `not(test)`
24
+ #[ cfg( not( test) ) ]
25
+ fn foo ( ) { }
26
+ #[ cfg( all( debug_assertions, not( test) ) ) ]
27
+ fn bar ( ) { }
28
+ #[ cfg( not( any( not( debug_assertions) , test) ) ) ]
29
+ fn baz ( ) { }
30
+
31
+ #[ cfg( test) ]
32
+ mod tests { }
Original file line number Diff line number Diff line change
1
+ error: code is excluded from test builds
2
+ --> tests/ui/cfg_not_test.rs:8:5
3
+ |
4
+ LL | #[cfg(not(test))]
5
+ | ^^^^^^^^^^^^^^^^^
6
+ |
7
+ = help: consider not excluding any code from test builds
8
+ = note: this could increase code coverage despite not actually being tested
9
+ = note: `-D clippy::cfg-not-test` implied by `-D warnings`
10
+ = help: to override `-D warnings` add `#[allow(clippy::cfg_not_test)]`
11
+
12
+ error: code is excluded from test builds
13
+ --> tests/ui/cfg_not_test.rs:12:5
14
+ |
15
+ LL | #[cfg(not(test))]
16
+ | ^^^^^^^^^^^^^^^^^
17
+ |
18
+ = help: consider not excluding any code from test builds
19
+
20
+ error: code is excluded from test builds
21
+ --> tests/ui/cfg_not_test.rs:24:1
22
+ |
23
+ LL | #[cfg(not(test))]
24
+ | ^^^^^^^^^^^^^^^^^
25
+ |
26
+ = help: consider not excluding any code from test builds
27
+
28
+ error: code is excluded from test builds
29
+ --> tests/ui/cfg_not_test.rs:26:1
30
+ |
31
+ LL | #[cfg(all(debug_assertions, not(test)))]
32
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33
+ |
34
+ = help: consider not excluding any code from test builds
35
+
36
+ error: code is excluded from test builds
37
+ --> tests/ui/cfg_not_test.rs:28:1
38
+ |
39
+ LL | #[cfg(not(any(not(debug_assertions), test)))]
40
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41
+ |
42
+ = help: consider not excluding any code from test builds
43
+
44
+ error: aborting due to 5 previous errors
45
+
You can’t perform that action at this time.
0 commit comments