about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorbeetrees <b@beetr.ee>2024-03-18 00:02:49 +0000
committerbeetrees <b@beetr.ee>2024-10-13 02:10:19 +0100
commitfeecfaa18d87e3f5dc9258fafa9d9ab9c1ebe5f6 (patch)
treee1f4f9b7e0596e818ca632001db6692ca0cc9ad6 /library/core/src
parent6b9676b45431a1e531b9c5f7bd289fc36a312749 (diff)
Fix bug where `option_env!` would return `None` when env var is present but not valid Unicode
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/macros/mod.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index aa0646846e4..2839a242a90 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -1107,17 +1107,19 @@ pub(crate) mod builtin {
     ///
     /// If the named environment variable is present at compile time, this will
     /// expand into an expression of type `Option<&'static str>` whose value is
-    /// `Some` of the value of the environment variable. If the environment
-    /// variable is not present, then this will expand to `None`. See
-    /// [`Option<T>`][Option] for more information on this type.  Use
-    /// [`std::env::var`] instead if you want to read the value at runtime.
+    /// `Some` of the value of the environment variable (a compilation error
+    /// will be emitted if the environment variable is not a valid Unicode
+    /// string). If the environment variable is not present, then this will
+    /// expand to `None`. See [`Option<T>`][Option] for more information on this
+    /// type.  Use [`std::env::var`] instead if you want to read the value at
+    /// runtime.
     ///
     /// [`std::env::var`]: ../std/env/fn.var.html
     ///
-    /// A compile time error is never emitted when using this macro regardless
-    /// of whether the environment variable is present or not.
-    /// To emit a compile error if the environment variable is not present,
-    /// use the [`env!`] macro instead.
+    /// A compile time error is only emitted when using this macro if the
+    /// environment variable exists and is not a valid Unicode string. To also
+    /// emit a compile error if the environment variable is not present, use the
+    /// [`env!`] macro instead.
     ///
     /// # Examples
     ///