New example for E0536

This commit is contained in:
Jonathan Brouwer
2025-07-07 09:10:54 +02:00
parent c7f5ddc098
commit 7a7c74ad89
3 changed files with 13 additions and 16 deletions

View File

@@ -3,22 +3,20 @@ The `not` cfg-predicate was malformed.
Erroneous code example:
```compile_fail,E0536
#[cfg(not())] // error: expected 1 cfg-pattern
pub fn something() {}
pub fn main() {}
pub fn main() {
if cfg!(not()) { }
}
```
The `not` predicate expects one cfg-pattern. Example:
```
#[cfg(not(target_os = "linux"))] // ok!
pub fn something() {}
pub fn main() {}
pub fn main() {
if cfg!(not(target_os = "linux")) { } // ok!
}
```
For more information about the `cfg` attribute, read the section on
For more information about the `cfg` macro, read the section on
[Conditional Compilation][conditional-compilation] in the Reference.
[conditional-compilation]: https://doc.rust-lang.org/reference/conditional-compilation.html