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.
33Erroneous code example:
44
55``` 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+ }
109```
1110
1211The ` not ` predicate expects one cfg-pattern. Example:
1312
1413```
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+ }
1917```
2018
21- For more information about the ` cfg ` attribute , read the section on
19+ For more information about the ` cfg ` macro , read the section on
2220[ Conditional Compilation] [ conditional-compilation ] in the Reference.
2321
2422[ 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 11error[E0536]: expected 1 cfg-pattern
2- --> $DIR/E0536.rs:1:7
2+ --> $DIR/E0536.rs:2:13
33 |
4- LL | #[ cfg(not())]
5- | ^^^^^
4+ LL | if cfg! (not()) { }
5+ | ^^^^^
66
77error: aborting due to 1 previous error
88
You can’t perform that action at this time.
0 commit comments