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

Update for 2024 stabilization #338

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

## Rust 2024

- [Rust 2024 🚧](rust-2024/index.md)
- [Rust 2024](rust-2024/index.md)
- [Language](rust-2024/language.md)
- [RPIT lifetime capture rules](rust-2024/rpit-lifetime-capture.md)
- [`if let` temporary scope](rust-2024/temporary-if-let-scope.md)
Expand Down
6 changes: 3 additions & 3 deletions src/editions/creating-a-new-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ $ cat foo/Cargo.toml
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
edition = "2024"

[dependencies]
```

That `edition = "2021"` setting configures your package to be built using the
Rust 2021 edition. No further configuration needed!
That `edition = "2024"` setting configures your package to be built using the
Rust 2024 edition. No further configuration needed!

You can use the `--edition <YEAR>` option of `cargo new` to create the project
using some specific edition. For example, creating a new project to use the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ It will update your source code so that it is compatible with the next edition.
Briefly, the steps to update to the next edition are:

1. Run `cargo fix --edition`
2. Edit `Cargo.toml` and set the `edition` field to the next edition, for example `edition = "2021"`
2. Edit `Cargo.toml` and set the `edition` field to the next edition, for example `edition = "2024"`
3. Run `cargo build` or `cargo test` to verify the fixes worked.

The following sections dig into the details of these steps, and some of the issues you may encounter along the way.
Expand Down Expand Up @@ -93,7 +93,7 @@ The steps are roughly similar to the stable channel:

1. Install the most recent nightly: `rustup update nightly`.
2. Run `cargo +nightly fix --edition`.
3. Edit `Cargo.toml` and place `cargo-features = ["edition2024"]` at the top (above `[package]`), and change the edition field to say `edition = "2024"`.
3. Edit `Cargo.toml` and place `cargo-features = ["edition20xx"]` at the top (above `[package]`), and change the edition field to say `edition = "20xx"` where `20xx` is the edition you are upgrading to.
4. Run `cargo +nightly check` to verify it now works in the new edition.

> **⚠ Caution**: Features implemented in the next edition may not have automatic migrations implemented with `cargo fix`, and the features themselves may not be finished.
Expand Down
2 changes: 0 additions & 2 deletions src/rust-2024/cargo-inherited-default-features.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Cargo: Reject unused inherited default-features

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

## Summary

- `default-features = false` is no longer allowed in an inherited workspace dependency if the workspace dependency specifies `default-features = true` (or does not specify `default-features`).
Expand Down
2 changes: 0 additions & 2 deletions src/rust-2024/cargo-resolver.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Cargo: Rust-version aware resolver

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

## Summary

- `edition = "2024"` implies `resolver = "3"` in `Cargo.toml` which enables a Rust-version aware dependency resolver.
Expand Down
2 changes: 0 additions & 2 deletions src/rust-2024/cargo-table-key-names.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Cargo: Table and key name consistency

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

## Summary

- Several table and key names in `Cargo.toml` have been removed where there were previously two ways to specify the same thing.
Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/gen-keyword.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# `gen` keyword

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/123904>.

## Summary

- `gen` is a [reserved keyword].
Expand Down
26 changes: 1 addition & 25 deletions src/rust-2024/index.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
# Rust 2024

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

| Info | |
| --- | --- |
| RFC | [#3501](https://rust-lang.github.io/rfcs/3501-edition-2024.html) |
| Release version | 1.85.0 (anticipated) |

The Rust 2024 Edition is scheduled to be frozen on 2024-10-17, stabilized on nightly on 2024-11-28, and released as stable with Rust 1.85.0 on 2025-02-20. In more detail, the currently anticipated release schedule is:

| Date | Version | Edition stage |
|------------|---------------|--------------------------------|
| 2024-10-11 | Branch v1.83 | Go / no go on all items |
| 2024-10-17 | Release v1.82 | Rust 2024 nightly beta |
| 2024-11-22 | Branch v1.84 | Prepare to stabilize... |
| 2024-11-28 | Release v1.83 | Stabilize Rust 2024 on master |
| 2025-01-03 | Branch v1.85 | Cut Rust 2024 to beta |
| 2025-01-09 | Release v1.84 | Announce Rust 2024 is pending! |
| 2025-02-20 | Release v1.85 | Release Rust 2024 |

Our motivating priorities for this edition are to:

- Make *this* edition a success.
- Do so without requiring heroics from anyone.
- ...or stressing anyone or everyone out.

Consequently, it's possible that things could change if needed so as to better adhere to those guiding priorities. This is a project run by volunteers.

However, at the moment, **the edition is on track**.
| Release version | 1.85.0 |
6 changes: 1 addition & 5 deletions src/rust-2024/intoiterator-box-slice.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Add `IntoIterator` for `Box<[T]>`

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/123759>.

## Summary

- Boxed slices implement [`IntoIterator`] in *all* editions.
Expand Down Expand Up @@ -39,8 +36,7 @@ This example is allowed on all editions because previously this was an error sin

However, this would normally be a breaking change because existing code that manually called `.into_iter()` on a boxed slice would change from having an iterator over references to an iterator over values. To resolve this problem, method calls of `.into_iter()` on boxed slices have edition-dependent behavior. In editions before 2024, it continues to return an iterator over references, and starting in Edition 2024 it returns an iterator over values.

<!-- TODO: edition2024 -->
```rust
```rust,edition2024
// Example of changed behavior in Edition 2024
let my_boxed_slice: Box<[u32]> = vec![1, 2, 3].into_boxed_slice();
// Example of old code that still manually calls .into_iter()
Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/macro-fragment-specifiers.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Macro Fragment Specifiers

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/123742>.

## Summary

- The `expr` [fragment specifier] now also supports `const` and `_` expressions.
Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/match-ergonomics.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Match ergonomics

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/131414>.

**This is a placeholder, docs coming soon!**

## Summary
Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/missing-macro-fragment-specifiers.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Missing macro fragment specifiers

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/128143>.

## Summary

- The [`missing_fragment_specifier`] lint is now a hard error.
Expand Down
11 changes: 3 additions & 8 deletions src/rust-2024/never-type-fallback.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Never type fallback change

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

## Summary

- Never type (`!`) to any type ("never-to-any") coercions fall back to never type (`!`) rather than to unit type (`()`).
Expand Down Expand Up @@ -85,8 +83,7 @@ You might think that, in this example, type `T` can't be inferred. However, due

To fix the issue you need to specify the `T` type explicitly:

<!-- TODO: edition2024 -->
```rust
```rust,edition2024
# #![deny(dependency_on_unit_never_type_fallback)]
# fn outer<T>(x: T) -> Result<T, ()> {
# fn f<T: Default>() -> Result<T, ()> {
Expand Down Expand Up @@ -115,8 +112,7 @@ run(|| panic!());

Previously `!` from the `panic!` coerced to `()` which implements `Unit`. However now the `!` is kept as `!` so this code fails because `!` doesn't implement `Unit`. To fix this you can specify the return type of the closure:

<!-- TODO: edition2024 -->
```rust,should_panic
```rust,edition2024,should_panic
# #![deny(dependency_on_unit_never_type_fallback)]
# trait Unit {}
# impl Unit for () {}
Expand All @@ -142,8 +138,7 @@ Previously `()` was inferred as the return type of `Default::default()` because

Again, this can be fixed by specifying the type explicitly:

<!-- TODO: edition2024 -->
```rust
```rust,edition2024
# #![deny(dependency_on_unit_never_type_fallback)]
() = if true {
Default::default()
Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/newly-unsafe-functions.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Unsafe functions

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/124866>.

## Summary

- The following functions are now marked [`unsafe`]:
Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/prelude.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Additions to the prelude

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/121042>.

## Summary

- The [`Future`] and [`IntoFuture`] traits are now part of the prelude.
Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/reserved-syntax.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Reserved syntax

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/123735>.

## Summary

- Unprefixed guarded strings of the form `#"foo"#` are reserved for future use.
Expand Down
8 changes: 2 additions & 6 deletions src/rust-2024/rpit-lifetime-capture.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# RPIT lifetime capture rules

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

This chapter describes changes related to the **Lifetime Capture Rules 2024** introduced in [RFC 3498], including how to use opaque type *precise capturing* (introduced in [RFC 3617]) to migrate your code.

[RFC 3498]: https://github.com/rust-lang/rfcs/pull/3498
Expand Down Expand Up @@ -237,8 +235,7 @@ fn f<'a, T>(x: &'a (), y: T) -> impl Sized + use<'a, T> {

In Rust 2024, the `use<..>` bound can often be omitted entirely, and the above can be written simply as:

<!-- TODO: edition2024 -->
```rust
```rust,edition2024
# #![feature(lifetime_capture_rules_2024)]
fn f<'a, T>(x: &'a (), y: T) -> impl Sized {
(x, y)
Expand Down Expand Up @@ -284,8 +281,7 @@ fn f<T>(x: &(), y: T) -> impl Sized + use<'_, T> {

In Rust 2024, the `use<..>` bound can often be omitted entirely, and the above can be written simply as:

<!-- TODO: edition2024 -->
```rust
```rust,edition2024
# #![feature(precise_capturing)]
# #![feature(lifetime_capture_rules_2024)]
fn f<T>(x: &(), y: T) -> impl Sized {
Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/rustdoc-doctests.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Rustdoc combined tests

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/124853>.

## Summary

- [Doctests] are now combined into a single binary which should result in a significant performance improvement.
Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/rustdoc-nested-includes.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Rustdoc nested `include!` change

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/132230>.

## Summary

When a doctest is included with `include_str!`, if that doctest itself also uses `include!`, `include_str!`, or `include_bytes!`, the path is resolved relative to the Markdown file, rather than to the Rust source file.
Expand Down
2 changes: 0 additions & 2 deletions src/rust-2024/rustfmt-overflow-delimited-expr.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Rustfmt: Combine all delimited exprs as last argument

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

This feature is not yet implemented.
More information may be found in <https://github.com/rust-lang/rust/pull/114764>.

Expand Down
4 changes: 0 additions & 4 deletions src/rust-2024/rustfmt-raw-identifier-sorting.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Rustfmt: Raw identifier sorting

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/124764>.

## Summary

`rustfmt` now properly sorts [raw identifiers].
Expand Down
4 changes: 0 additions & 4 deletions src/rust-2024/rustfmt-style-edition.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Rustfmt: Style edition

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/123799>.

## Summary

User can now control which style edition to use with `rustfmt`.
Expand Down
4 changes: 0 additions & 4 deletions src/rust-2024/rustfmt-version-sorting.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Rustfmt: Version sorting

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

More information may be found in the tracking issues at <https://github.com/rust-lang/rust/issues/123800> and <https://github.com/rust-lang/rust/issues/123802>.

## Summary

`rustfmt` utilizes a new sorting algorithm.
Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/static-mut-references.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Disallow references to static mut

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/123758>.

## Summary

- The [`static_mut_refs`] lint level is now `deny` by default.
Expand Down
6 changes: 1 addition & 5 deletions src/rust-2024/temporary-if-let-scope.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# `if let` temporary scope

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/124085>.

## Summary

- In an `if let $pat = $expr { .. } else { .. }` expression, the temporary values generated from evaluating `$expr` will be dropped before the program enters the `else` branch instead of after.
Expand Down Expand Up @@ -34,8 +31,7 @@ In this example, the temporary read lock generated by the call to `value.read()`

The 2024 Edition shortens the lifetime of the temporaries to the point where the then-block is completely evaluated or the program control enters the `else` block.

<!-- TODO: edition2024 -->
```rust
```rust,edition2024
// Starting with 2024
# use std::sync::RwLock;

Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/temporary-tail-expr-scope.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Tail expression temporary scope

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/123739>.

## Summary

- Temporary values generated in evaluation of the tail expression of a [function] or closure body, or a [block] are now dropped before local variables.
Expand Down
6 changes: 1 addition & 5 deletions src/rust-2024/unsafe-attributes.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Unsafe attributes

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/123757>.

## Summary

- The following attributes must now be marked as `unsafe`:
Expand Down Expand Up @@ -49,8 +46,7 @@ fn foo() -> usize { 1 }

In the 2024 Edition, it is now required to mark these attributes as unsafe to emphasize that it is required to ensure that the symbol is defined correctly:

<!-- TODO: edition2024 -->
```rust
```rust,edition2024
// SAFETY: There should only be a single definition of the loop symbol.
#[unsafe(export_name="loop")]
fn arduino_loop() {
Expand Down
3 changes: 0 additions & 3 deletions src/rust-2024/unsafe-extern.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Unsafe `extern` blocks

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/123743>.

## Summary

- [`extern` blocks] must now be marked with the `unsafe` keyword.
Expand Down
2 changes: 0 additions & 2 deletions src/rust-2024/unsafe-op-in-unsafe-fn.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# unsafe_op_in_unsafe_fn warning

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".

## Summary

- The [`unsafe_op_in_unsafe_fn`] lint now warns by default.
Expand Down