Skip to content

static_mut_refs: Need edition migration guide documentation #123059

Closed
rust-lang/edition-guide
#354
@ehuss

Description

@ehuss

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

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-edition-2024Area: The 2024 editionT-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions