diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2024-06-12 03:57:23 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-12 03:57:23 -0700 |
| commit | 0805ab47c973def5efd672cd39d2e1de31ad4c3b (patch) | |
| tree | 3ff9f9b36ea081db360f484f6371d00b6d270d0f | |
| parent | 0ed474a6358f56a685a3ec22914bfa9af503df56 (diff) | |
| parent | 751143ef4031d06e718bcf859f1b3139716d043b (diff) | |
| download | rust-0805ab47c973def5efd672cd39d2e1de31ad4c3b.tar.gz rust-0805ab47c973def5efd672cd39d2e1de31ad4c3b.zip | |
Rollup merge of #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 #125937 being rejected.
| -rw-r--r-- | library/std/src/env.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 4d649f8a6f1..295e782639b 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -323,8 +323,10 @@ impl Error for VarError { /// This function is also always safe to call on Windows, in single-threaded /// and multi-threaded programs. /// -/// In multi-threaded programs on other operating systems, we strongly suggest -/// not using `set_var` or `remove_var` at all. The exact requirement is: you +/// In multi-threaded programs on other operating systems, the only safe option is +/// to not use `set_var` or `remove_var` at all. +/// +/// The exact requirement is: you /// must ensure that there are no other threads concurrently writing or /// *reading*(!) the environment through functions or global variables other /// 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) { /// This function is also always safe to call on Windows, in single-threaded /// and multi-threaded programs. /// -/// In multi-threaded programs on other operating systems, we strongly suggest -/// not using `set_var` or `remove_var` at all. The exact requirement is: you +/// In multi-threaded programs on other operating systems, the only safe option is +/// to not use `set_var` or `remove_var` at all. +/// +/// The exact requirement is: you /// must ensure that there are no other threads concurrently writing or /// *reading*(!) the environment through functions or global variables other /// than the ones in this module. The problem is that these operating systems |
