-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
rust-lang/edition-guide
#354Closed
Copy link
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-edition-2024Area: The 2024 editionArea: The 2024 editionT-langRelevant to the language teamRelevant to the language team
Description
The change for static_mut_refs
in the 2024 Edition needs to have documentation (here) for how a user can perform a manual migration.
This documentation should have a more complete explanation of why it is forbidden. Currently it just mentions use in multiple threads, but I don't think that is a complete description.
It also needs to explain to the user how to rewrite their code to make it work. My understanding is that someone can convert &STATIC
to &*addr_of!(STATIC)
, which is equivalent, but still runs afoul of the exact same aliasing problems and undefined behavior, so I don't know if it makes sense to recommend that.
- Why is
&*addr_of!(…)
allowed? - What situations are there where
addr_of!
is appropriate? - If
addr_of!
isn't the correct route, what should a user do to update their code?- Do they have to switch to interior mutability? How? What other options are there?
See also discussion at #114447 and
https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/static_mut_refs
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-edition-2024Area: The 2024 editionArea: The 2024 editionT-langRelevant to the language teamRelevant to the language team