File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,9 +17,10 @@ const WEAK_COUNT: usize = 1 << STRONG_WIDTH;
1717#[ cold]
1818fn refcount_overflow ( ) -> ! {
1919 #[ cfg( feature = "std" ) ]
20+ // SAFETY: abort terminates the process immediately and does not return.
2021 unsafe {
2122 libc:: abort ( )
22- }
23+ } ;
2324 #[ cfg( not( feature = "std" ) ) ]
2425 core:: panic!( "refcount overflow" ) ;
2526}
Original file line number Diff line number Diff line change @@ -48,11 +48,17 @@ pub fn vars_os() -> env::VarsOs {
4848 env:: vars_os ( )
4949}
5050
51- pub fn set_var ( key : impl AsRef < OsStr > , value : impl AsRef < OsStr > ) {
51+ /// # Safety
52+ /// The caller must ensure no other threads can concurrently read or write
53+ /// the process environment while this mutation is performed.
54+ pub unsafe fn set_var ( key : impl AsRef < OsStr > , value : impl AsRef < OsStr > ) {
5255 unsafe { env:: set_var ( key, value) } ;
5356}
5457
55- pub fn remove_var ( key : impl AsRef < OsStr > ) {
58+ /// # Safety
59+ /// The caller must ensure no other threads can concurrently read or write
60+ /// the process environment while this mutation is performed.
61+ pub unsafe fn remove_var ( key : impl AsRef < OsStr > ) {
5662 unsafe { env:: remove_var ( key) } ;
5763}
5864
Original file line number Diff line number Diff line change @@ -544,7 +544,7 @@ pub(super) mod _os {
544544 let key = super :: bytes_as_os_str ( key, vm) ?;
545545 let value = super :: bytes_as_os_str ( value, vm) ?;
546546 // SAFETY: requirements forwarded from the caller
547- crate :: host_env:: os:: set_var ( key, value) ;
547+ unsafe { crate :: host_env:: os:: set_var ( key, value) } ;
548548 Ok ( ( ) )
549549 }
550550
@@ -596,7 +596,7 @@ pub(super) mod _os {
596596 }
597597 let key = super :: bytes_as_os_str ( key, vm) ?;
598598 // SAFETY: requirements forwarded from the caller
599- crate :: host_env:: os:: remove_var ( key) ;
599+ unsafe { crate :: host_env:: os:: remove_var ( key) } ;
600600 Ok ( ( ) )
601601 }
602602
You can’t perform that action at this time.
0 commit comments