Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking issue for release notes of #129195: Stabilize &mut (and *mut) as well as &Cell (and *const Cell) in const #130362

Closed
3 tasks
rustbot opened this issue Sep 14, 2024 · 2 comments
Labels
relnotes Marks issues that should be documented in the release notes of the next release. relnotes-tracking-issue Marks issues tracking what text to put in release notes. T-lang Relevant to the language team, which will review and decide on the PR/issue. WG-const-eval Working group: Const evaluation
Milestone

Comments

@rustbot
Copy link
Collaborator

rustbot commented Sep 14, 2024

This issue tracks the release notes text for #129195.

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
- [Stabilize `&mut`, `*mut`, `&Cell`, and `*const Cell` in const.](https://github.com/rust-lang/rust/pull/129195)

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 @RalfJung, @fee1-dead -- origin issue/PR authors and assignees for starting to draft text

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc relnotes Marks issues that should be documented in the release notes of the next release. relnotes-tracking-issue Marks issues tracking what text to put in release notes. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Sep 14, 2024
@rustbot rustbot added this to the 1.83.0 milestone Sep 14, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 14, 2024
@saethlin saethlin added WG-const-eval Working group: Const evaluation and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 14, 2024
@RalfJung
Copy link
Member

I am hoping there'll be a bunch of const fn API stabilizations as well to go with this (t-libs-api FCP has been proposed in a bunch of tracking issues). Then we can have one section in the release notes about creating mutable references / raw pointers and doing stuff with them.

@RalfJung
Copy link
Member

RalfJung commented Sep 28, 2024

So here's a draft for the release notes section for this.
Cc @rust-lang/wg-const-eval

New const capabilities

This release includes several large extensions to what code running in const contexts can do.
This refers to all code that the compiler has to evaluate at compile-time: the initial value of const and static items,
array lengths, enum discriminant values, const generic arguments, and functions callable from such contexts (const fn).

Mutable references and pointers.
It is now possible to use mutable references in const contexts:

const fn inc(x: &mut i32) {
    *x += 1;
}

const C: i32 = {
    let mut c = 41;
    inc(&mut c);
    c
};

Mutable raw pointers and interior mutability are also supported:

use std::cell::UnsafeCell;

const C: i32 = {
    let c = UnsafeCell::new(41);
    unsafe { *c.get() += 1 };
    c.into_inner()
};

However, mutable references and pointers can only be used inside the computation of a constant, they cannot become a part of the final value of the constant:

const C: &mut i32 = &mut 4;
// error[E0764]: mutable references are not allowed in the final value of constants

This release also ships with a whole bag of new functions that are now stable in const contexts: TODO put a list here, or just reference the list at the end of the release notes?

This unblocks an entire new category of code to be executed inside const contexts, and we are excited to see how the Rust ecosystem will make use of this!

@jieyouxu jieyouxu removed A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release. relnotes-tracking-issue Marks issues tracking what text to put in release notes. T-lang Relevant to the language team, which will review and decide on the PR/issue. WG-const-eval Working group: Const evaluation
Projects
None yet
Development

No branches or pull requests

5 participants