-
Notifications
You must be signed in to change notification settings - Fork 301
Announcing Rust 1.83.0 #1432
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
Merged
Merged
Announcing Rust 1.83.0 #1432
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
--- | ||
layout: post | ||
title: "Announcing Rust 1.83.0" | ||
author: The Rust Release Team | ||
release: true | ||
--- | ||
|
||
The Rust team is happy to announce a new version of Rust, 1.83.0. Rust is a programming language empowering everyone to build reliable and efficient software. | ||
|
||
If you have a previous version of Rust installed via `rustup`, you can get 1.83.0 with: | ||
|
||
```console | ||
$ rustup update stable | ||
``` | ||
|
||
If you don't have it already, you can [get `rustup`](https://www.rust-lang.org/install.html) from the appropriate page on our website, and check out the [detailed release notes for 1.83.0](TODO). | ||
BoxyUwU marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
If you'd like to help us out by testing future releases, you might consider updating locally to use the beta channel (`rustup default beta`) or the nightly channel (`rustup default nightly`). Please [report](https://github.com/rust-lang/rust/issues/new/choose) any bugs you might come across! | ||
|
||
## What's in 1.83.0 stable | ||
|
||
### 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`). | ||
|
||
**References to statics.** | ||
So far, `const` items and `const fn` were forbidden from referencing `static items`. | ||
BoxyUwU marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This limitation has now been lifted: | ||
```rust | ||
static S: i32 = 25; | ||
const C: &i32 = &S; | ||
``` | ||
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: | ||
traviscross marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```rust | ||
static mut S: i32 = 0; | ||
|
||
const C1: i32 = unsafe { S }; | ||
// error: constant accesses mutable global memory | ||
|
||
const C2: &i32 = unsafe { &S }; | ||
// error: encountered reference to mutable memory in `const` | ||
``` | ||
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: | ||
BoxyUwU marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```rust | ||
static mut S: i32 = 64; | ||
const C: *mut i32 = &raw mut S; | ||
``` | ||
|
||
**Mutable references and pointers.** | ||
It is now possible to use mutable references in const contexts: | ||
```rust | ||
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: | ||
```rust | ||
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: | ||
```rust | ||
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 (see the end of the "Stabilized APIs" section). | ||
|
||
These new capabilities and stabilized APIs unblock 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! | ||
|
||
### Stabilized APIs | ||
|
||
TODO | ||
BoxyUwU marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
These APIs are now stable in const contexts: | ||
|
||
TODO | ||
BoxyUwU marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Other changes | ||
|
||
Check out everything that changed in [Rust](https://github.com/rust-lang/rust/releases/tag/1.83.0), [Cargo](https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-183-2024-11-28), and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-183). | ||
|
||
## Contributors to 1.83.0 | ||
|
||
Many people came together to create Rust 1.83.0. We couldn't have done it without all of you. [Thanks!](https://thanks.rust-lang.org/rust/1.83.0/) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.