From 7a7c74ad89df9f87824fa17fbbe0448d9ab6f7cc Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Mon, 7 Jul 2025 09:10:54 +0200 Subject: New example for E0536 --- compiler/rustc_error_codes/src/error_codes/E0536.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'compiler/rustc_error_codes/src') 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 -- cgit 1.4.1-3-g733a5