Description
This issue tracks the release notes text for #129759.
Steps
- Proposed text is drafted by PR author (or team) making the noteworthy change.Issue is nominated for release team review of clarity for wider audience.Release team includes text in release notes/blog posts.
Release notes text
The responsible team for the underlying change should edit this section to replace the automatically generated link with a succinct description of what changed, drawing upon text proposed by the author (either in discussion or through direct editing).
# Language
- [Allow creating references to statics in `const` initializers.](https://github.com/rust-lang/rust/pull/129759)
Tip
Use the previous releases categories to help choose which one(s) to use.
The category will be de-duplicated with all the other ones by the release team.
More than one section can be included if needed.
Release blog section
If the change is notable enough for inclusion in the blog post, the responsible team should add content to this section.
Otherwise leave it empty.
cc @dingxiangfei2009, @RalfJung -- origin issue/PR authors and assignees for starting to draft text
Activity
RalfJung commentedon Sep 28, 2024
We'll have a big section on the const_mut_ref stuff (#130362), not sure if we want a dedicated section for this or just make it "more cool const stuff".
RalfJung commentedon Sep 28, 2024
Here's a draft of what IMO should be put in one overarching section with the text from #130362.
References to statics.
So far,
const
items andconst fn
were forbidden from referencingstatic items
.This limitation has now been lifted:
Note, however, that reading the value of a mutable or interior mutable static is still not permitted in const contexts.
Furthermore, the final value of a constant may not reference any mutable or interior mutable statics:
These limitations ensure that constants are still "constant": the value they evaluate to, and their meaning as a pattern (which can involve dereferencing references), will be the same throughout the entire program execution.
However, a constant is permitted to evaluate to a raw pointer that points to a mutable or interior mutable static:
const_refs_to_static
#130006