From 4813a81432da746d9094438760bcac5c161c75fe Mon Sep 17 00:00:00 2001 From: David Freese Date: Wed, 29 Apr 2020 11:50:23 -0700 Subject: [PATCH 1/2] Add clarification on std::cfg macro docs v. #[cfg] attribute The wording was discussed, to a limited degree in #71679. This tries to address some confusion I as well as someone else had independently when looking at this macro. Fixes #71679 --- src/libcore/macros/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcore/macros/mod.rs b/src/libcore/macros/mod.rs index 18d5eaa964849..8de6be86e34ba 100644 --- a/src/libcore/macros/mod.rs +++ b/src/libcore/macros/mod.rs @@ -1159,6 +1159,10 @@ pub(crate) mod builtin { /// The syntax given to this macro is the same syntax as the [`cfg`] /// attribute. /// + /// `cfg!`, unlike `#[cfg]`, does not remove any code and only evaluates to true or false. For + /// example, this means all code in an if/else block needs to be valid when `cfg!` is used for + /// the condition, regardless of what `cfg!` is evaluating. + /// /// [`cfg`]: ../reference/conditional-compilation.html#the-cfg-attribute /// /// # Examples From 610f94423100b9ec6b5190032c9e213af5c099de Mon Sep 17 00:00:00 2001 From: David Freese Date: Wed, 29 Apr 2020 12:16:32 -0700 Subject: [PATCH 2/2] Update src/libcore/macros/mod.rs Co-Authored-By: kennytm --- src/libcore/macros/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/macros/mod.rs b/src/libcore/macros/mod.rs index 8de6be86e34ba..14bfa8bab8939 100644 --- a/src/libcore/macros/mod.rs +++ b/src/libcore/macros/mod.rs @@ -1160,7 +1160,7 @@ pub(crate) mod builtin { /// attribute. /// /// `cfg!`, unlike `#[cfg]`, does not remove any code and only evaluates to true or false. For - /// example, this means all code in an if/else block needs to be valid when `cfg!` is used for + /// example, all blocks in an if/else expression need to be valid when `cfg!` is used for /// the condition, regardless of what `cfg!` is evaluating. /// /// [`cfg`]: ../reference/conditional-compilation.html#the-cfg-attribute