File tree Expand file tree Collapse file tree 3 files changed +13
-16
lines changed
compiler/rustc_error_codes/src/error_codes Expand file tree Collapse file tree 3 files changed +13
-16
lines changed Original file line number Diff line number Diff line change @@ -3,22 +3,20 @@ The `not` cfg-predicate was malformed.
3
3
Erroneous code example:
4
4
5
5
``` compile_fail,E0536
6
- #[cfg(not())] // error: expected 1 cfg-pattern
7
- pub fn something() {}
8
-
9
- pub fn main() {}
6
+ pub fn main() {
7
+ if cfg!(not()) { }
8
+ }
10
9
```
11
10
12
11
The ` not ` predicate expects one cfg-pattern. Example:
13
12
14
13
```
15
- #[cfg(not(target_os = "linux"))] // ok!
16
- pub fn something() {}
17
-
18
- pub fn main() {}
14
+ pub fn main() {
15
+ if cfg!(not(target_os = "linux")) { } // ok!
16
+ }
19
17
```
20
18
21
- For more information about the ` cfg ` attribute , read the section on
19
+ For more information about the ` cfg ` macro , read the section on
22
20
[ Conditional Compilation] [ conditional-compilation ] in the Reference.
23
21
24
22
[ conditional-compilation ] : https://doc.rust-lang.org/reference/conditional-compilation.html
Original file line number Diff line number Diff line change 1
- #[ cfg( not( ) ) ] //~ ERROR E0536
2
- pub fn something ( ) { }
3
-
4
- pub fn main ( ) { }
1
+ pub fn main ( ) {
2
+ if cfg ! ( not( ) ) { } //~ ERROR E0536
3
+ }
Original file line number Diff line number Diff line change 1
1
error[E0536]: expected 1 cfg-pattern
2
- --> $DIR/E0536.rs:1:7
2
+ --> $DIR/E0536.rs:2:13
3
3
|
4
- LL | #[ cfg(not())]
5
- | ^^^^^
4
+ LL | if cfg! (not()) { }
5
+ | ^^^^^
6
6
7
7
error: aborting due to 1 previous error
8
8
You can’t perform that action at this time.
0 commit comments