Add note about safety of std::env::set_var on Windows · model-checking/verify-rust-std@2500719 (original) (raw)

Original file line number Diff line number Diff line change
@@ -320,11 +320,14 @@ impl Error for VarError {
320 320 ///
321 321 /// This function is safe to call in a single-threaded program.
322 322 ///
323 -/// In multi-threaded programs, you must ensure that are no other threads
324 -/// concurrently writing or *reading*(!) from the environment through functions
325 -/// other than the ones in this module. You are responsible for figuring out
326 -/// how to achieve this, but we strongly suggest not using `set_var` or
327 -/// `remove_var` in multi-threaded programs at all.
323 +/// This function is also always safe to call on Windows, in single-threaded
324 +/// and multi-threaded programs.
325 +///
326 +/// In multi-threaded programs on other operating systems, you must ensure that
327 +/// are no other threads concurrently writing or *reading*(!) from the
328 +/// environment through functions other than the ones in this module. You are
329 +/// responsible for figuring out how to achieve this, but we strongly suggest
330 +/// not using `set_var` or `remove_var` in multi-threaded programs at all.
328 331 ///
329 332 /// Most C libraries, including libc itself, do not advertise which functions
330 333 /// read from the environment. Even functions from the Rust standard library do
@@ -379,6 +382,9 @@ unsafe fn _set_var(key: &OsStr, value: &OsStr) {
379 382 ///
380 383 /// This function is safe to call in a single-threaded program.
381 384 ///
385 +/// This function is also always safe to call on Windows, in single-threaded
386 +/// and multi-threaded programs.
387 +///
382 388 /// In multi-threaded programs, you must ensure that are no other threads
383 389 /// concurrently writing or *reading*(!) from the environment through functions
384 390 /// other than the ones in this module. You are responsible for figuring out