Closed
Description
Now that we have ptr::addr_of_mut!
, the 2024 edition would be a great time to do @RalfJung's idea from #53639 (comment):
Disallow &MY_STATIC_MUT
and &mut MY_STATIC_MUT
entirely.
ptr::addr_of_mut!(MY_STATIC_MUT)
could even be safe -- unlike taking a reference which is unsafe
and often insta-UB -- and helps encourage avoiding races in the accesses, which is more practical than trying to avoid the UB from concurrent existence of references.
(Maybe people will end up just doing &mut *ptr::addr_of_mut!(MY_STATIC_MUT)
without thinking through all the safety requirements -- in particular, making sure that the reference stops being used before a second reference is created -- but we can't force them to drink.)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done