-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-edition-2024Area: The 2024 editionArea: The 2024 editionA-maybe-future-editionSomething we may consider for a future edition.Something we may consider for a future edition.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-langRelevant to the language teamRelevant to the language team
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.)
RalfJung, lukas-code, mati865, joboet, est31 and 26 moreKolsky, blueglyph, IndigoLily, MusaMahmood, zfphex and 3 moreMolotovCherry, dyslexicsteak and lvyitian
Metadata
Metadata
Assignees
Labels
A-edition-2024Area: The 2024 editionArea: The 2024 editionA-maybe-future-editionSomething we may consider for a future edition.Something we may consider for a future edition.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-langRelevant to the language teamRelevant to the language team
Type
Projects
Status
Done