Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5760a4e

Browse files
authoredJun 12, 2024
Rollup merge of rust-lang#126281 - ChrisDenton:env, r=jhpratt
set_env: State the conclusion upfront People tend to skim or skip over long explanations so we should be very upfront that `set_var` and `remove_var` are being made unsafe for a very good reason. This is just the conclusion restated almost verbatim but earlier in the docs and separated from the explanation: https://github.com/rust-lang/rust/blob/0c960618b56f662d933e8b864cd9632a99174e87/library/std/src/env.rs#L338-L339 I think this may help with people who may not be entirely comfortable with rust-lang#125937 being rejected.
2 parents 439c2ae + b3dcee6 commit 5760a4e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎std/src/env.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,10 @@ impl Error for VarError {
323323
/// This function is also always safe to call on Windows, in single-threaded
324324
/// and multi-threaded programs.
325325
///
326-
/// In multi-threaded programs on other operating systems, we strongly suggest
327-
/// not using `set_var` or `remove_var` at all. The exact requirement is: you
326+
/// In multi-threaded programs on other operating systems, the only safe option is
327+
/// to not use `set_var` or `remove_var` at all.
328+
///
329+
/// The exact requirement is: you
328330
/// must ensure that there are no other threads concurrently writing or
329331
/// *reading*(!) the environment through functions or global variables other
330332
/// than the ones in this module. The problem is that these operating systems
@@ -390,8 +392,10 @@ unsafe fn _set_var(key: &OsStr, value: &OsStr) {
390392
/// This function is also always safe to call on Windows, in single-threaded
391393
/// and multi-threaded programs.
392394
///
393-
/// In multi-threaded programs on other operating systems, we strongly suggest
394-
/// not using `set_var` or `remove_var` at all. The exact requirement is: you
395+
/// In multi-threaded programs on other operating systems, the only safe option is
396+
/// to not use `set_var` or `remove_var` at all.
397+
///
398+
/// The exact requirement is: you
395399
/// must ensure that there are no other threads concurrently writing or
396400
/// *reading*(!) the environment through functions or global variables other
397401
/// than the ones in this module. The problem is that these operating systems

0 commit comments

Comments
 (0)
Failed to load comments.