diff options
| author | Jonathan Brouwer <jonathantbrouwer@gmail.com> | 2025-07-07 09:10:54 +0200 |
|---|---|---|
| committer | Jonathan Brouwer <jonathantbrouwer@gmail.com> | 2025-07-15 09:21:27 +0200 |
| commit | 7a7c74ad89df9f87824fa17fbbe0448d9ab6f7cc (patch) | |
| tree | 635bf7b454df9fe8fbb5d76d8f75102f59e33b6b /compiler/rustc_error_codes/src | |
| parent | c7f5ddc09871dc74c9f451435b042707eef5dc6c (diff) | |
| download | rust-7a7c74ad89df9f87824fa17fbbe0448d9ab6f7cc.tar.gz rust-7a7c74ad89df9f87824fa17fbbe0448d9ab6f7cc.zip | |
New example for E0536
Diffstat (limited to 'compiler/rustc_error_codes/src')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0536.md | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0536.md b/compiler/rustc_error_codes/src/error_codes/E0536.md index c081a3d9cfa..f00d1773944 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0536.md +++ b/compiler/rustc_error_codes/src/error_codes/E0536.md @@ -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 |
