Skip to content

Commit 81411ec

Browse files
committed
feat: Stabilize Edition 2024
1 parent 52c62ee commit 81411ec

File tree

66 files changed

+165
-259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+165
-259
lines changed

src/cargo/core/features.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ impl Edition {
202202
/// The latest edition that is unstable.
203203
///
204204
/// This is `None` if there is no next unstable edition.
205-
pub const LATEST_UNSTABLE: Option<Edition> = Some(Edition::Edition2024);
205+
pub const LATEST_UNSTABLE: Option<Edition> = None;
206206
/// The latest stable edition.
207-
pub const LATEST_STABLE: Edition = Edition::Edition2021;
207+
pub const LATEST_STABLE: Edition = Edition::Edition2024;
208208
pub const ALL: &'static [Edition] = &[
209209
Self::Edition2015,
210210
Self::Edition2018,
@@ -225,7 +225,7 @@ impl Edition {
225225
Edition2015 => None,
226226
Edition2018 => Some(semver::Version::new(1, 31, 0)),
227227
Edition2021 => Some(semver::Version::new(1, 56, 0)),
228-
Edition2024 => None,
228+
Edition2024 => Some(semver::Version::new(1, 85, 0)),
229229
}
230230
}
231231

@@ -236,7 +236,7 @@ impl Edition {
236236
Edition2015 => true,
237237
Edition2018 => true,
238238
Edition2021 => true,
239-
Edition2024 => false,
239+
Edition2024 => true,
240240
}
241241
}
242242

@@ -509,7 +509,7 @@ features! {
509509
(stable, workspace_inheritance, "1.64", "reference/unstable.html#workspace-inheritance"),
510510

511511
/// Support for 2024 edition.
512-
(unstable, edition2024, "", "reference/unstable.html#edition-2024"),
512+
(stable, edition2024, "1.85", "reference/manifest.html#the-edition-field"),
513513

514514
/// Allow setting trim-paths in a profile to control the sanitisation of file paths in build outputs.
515515
(unstable, trim_paths, "", "reference/unstable.html#profile-trim-paths-option"),

src/cargo/util/toml/embedded.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ autoexamples = false
567567
autolib = false
568568
autotests = false
569569
build = false
570-
edition = "2021"
570+
edition = "2024"
571571
name = "test-"
572572
573573
[profile.release]
@@ -605,7 +605,7 @@ autoexamples = false
605605
autolib = false
606606
autotests = false
607607
build = false
608-
edition = "2021"
608+
edition = "2024"
609609
name = "test-"
610610
611611
[profile.release]

src/cargo/util/toml/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1217,9 +1217,7 @@ pub fn to_real_manifest(
12171217
// features.require(Feature::edition20xx())?;
12181218
// }
12191219
// ```
1220-
if edition == Edition::Edition2024 {
1221-
features.require(Feature::edition2024())?;
1222-
} else if !edition.is_stable() {
1220+
if !edition.is_stable() {
12231221
// Guard in case someone forgets to add .require()
12241222
return Err(util::errors::internal(format!(
12251223
"edition {} should be gated",

src/doc/man/generated_txt/cargo-init.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ OPTIONS
3030
Create a package with a library target (src/lib.rs).
3131

3232
--edition edition
33-
Specify the Rust edition to use. Default is 2021. Possible values:
33+
Specify the Rust edition to use. Default is 2024. Possible values:
3434
2015, 2018, 2021, 2024
3535

3636
--name name

src/doc/man/generated_txt/cargo-new.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ OPTIONS
2525
Create a package with a library target (src/lib.rs).
2626

2727
--edition edition
28-
Specify the Rust edition to use. Default is 2021. Possible values:
28+
Specify the Rust edition to use. Default is 2024. Possible values:
2929
2015, 2018, 2021, 2024
3030

3131
--name name

src/doc/man/includes/options-new.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Create a package with a library target (`src/lib.rs`).
1010
{{/option}}
1111

1212
{{#option "`--edition` _edition_" }}
13-
Specify the Rust edition to use. Default is 2021.
13+
Specify the Rust edition to use. Default is 2024.
1414
Possible values: 2015, 2018, 2021, 2024
1515
{{/option}}
1616

src/doc/src/commands/cargo-init.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This is the default behavior.</dd>
3939

4040

4141
<dt class="option-term" id="option-cargo-init---edition"><a class="option-anchor" href="#option-cargo-init---edition"></a><code>--edition</code> <em>edition</em></dt>
42-
<dd class="option-desc">Specify the Rust edition to use. Default is 2021.
42+
<dd class="option-desc">Specify the Rust edition to use. Default is 2024.
4343
Possible values: 2015, 2018, 2021, 2024</dd>
4444

4545

src/doc/src/commands/cargo-new.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This is the default behavior.</dd>
3434

3535

3636
<dt class="option-term" id="option-cargo-new---edition"><a class="option-anchor" href="#option-cargo-new---edition"></a><code>--edition</code> <em>edition</em></dt>
37-
<dd class="option-desc">Specify the Rust edition to use. Default is 2021.
37+
<dd class="option-desc">Specify the Rust edition to use. Default is 2024.
3838
Possible values: 2015, 2018, 2021, 2024</dd>
3939

4040

src/doc/src/getting-started/first-steps.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This is all we need to get started. First, let’s check out `Cargo.toml`:
3333
[package]
3434
name = "hello_world"
3535
version = "0.1.0"
36-
edition = "2021"
36+
edition = "2024"
3737

3838
[dependencies]
3939
```

src/doc/src/guide/creating-a-new-project.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Let’s take a closer look at `Cargo.toml`:
2929
[package]
3030
name = "hello_world"
3131
version = "0.1.0"
32-
edition = "2021"
32+
edition = "2024"
3333

3434
[dependencies]
3535

src/doc/src/guide/dependencies.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ crates:
3535
[package]
3636
name = "hello_world"
3737
version = "0.1.0"
38-
edition = "2021"
38+
edition = "2024"
3939

4040
[dependencies]
4141
time = "0.1.12"

src/doc/src/reference/build-script-examples.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Here we can see that we have a `build.rs` build script and our binary in
4949
[package]
5050
name = "hello-from-generated-code"
5151
version = "0.1.0"
52-
edition = "2021"
52+
edition = "2024"
5353
```
5454

5555
Let’s see what’s inside the build script:
@@ -148,7 +148,7 @@ Pretty similar to before! Next, the manifest:
148148
[package]
149149
name = "hello-world-from-c"
150150
version = "0.1.0"
151-
edition = "2021"
151+
edition = "2024"
152152
```
153153

154154
For now we’re not going to use any build dependencies, so let’s take a look at
@@ -298,7 +298,7 @@ with `pkg-config` installed. Let's start by setting up the manifest:
298298
[package]
299299
name = "libz-sys"
300300
version = "0.1.0"
301-
edition = "2021"
301+
edition = "2024"
302302
links = "z"
303303

304304
[build-dependencies]
@@ -385,7 +385,7 @@ Here's an example:
385385
[package]
386386
name = "zuser"
387387
version = "0.1.0"
388-
edition = "2021"
388+
edition = "2024"
389389

390390
[dependencies]
391391
libz-sys = "1.0.25"

src/doc/src/reference/manifest.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ examples, etc.
151151
```toml
152152
[package]
153153
# ...
154-
edition = '2021'
154+
edition = '2024'
155155
```
156156

157157
Most manifests have the `edition` field filled in automatically by [`cargo new`]
158158
with the latest stable edition. By default `cargo new` creates a manifest with
159-
the 2021 edition currently.
159+
the 2024 edition currently.
160160

161161
If the `edition` field is not present in `Cargo.toml`, then the 2015 edition is
162162
assumed for backwards compatibility. Note that all manifests

src/doc/src/reference/registries.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ in `Cargo.toml`:
3838
[package]
3939
name = "my-project"
4040
version = "0.1.0"
41-
edition = "2021"
41+
edition = "2024"
4242

4343
[dependencies]
4444
other-crate = { version = "1.0", registry = "my-registry" }

src/doc/src/reference/resolver.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ resolver = "2"
507507
- `"2"` ([`edition = "2021"`](manifest.md#the-edition-field) default): Introduces changes in [feature
508508
unification](#features). See the [features chapter][features-2] for more
509509
details.
510-
- `"3"` (requires Rust 1.84+): Change the default for [`resolver.incompatible-rust-versions`] from `allow` to `fallback`
510+
- `"3"` ([`edition = "2024"`](manifest.md#the-edition-field) default, requires Rust 1.84+): Change the default for [`resolver.incompatible-rust-versions`] from `allow` to `fallback`
511511

512512
The resolver is a global option that affects the entire workspace. The
513513
`resolver` version in dependencies is ignored, only the value in the top-level

src/doc/src/reference/unstable.md

+7-27
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ Each new feature described below should explain how to use it.
100100
* [codegen-backend](#codegen-backend) --- Select the codegen backend used by rustc.
101101
* [per-package-target](#per-package-target) --- Sets the `--target` to use for each individual package.
102102
* [artifact dependencies](#artifact-dependencies) --- Allow build artifacts to be included into other build artifacts and build them for different targets.
103-
* [Edition 2024](#edition-2024) — Adds support for the 2024 Edition.
104103
* [Profile `trim-paths` option](#profile-trim-paths-option) --- Control the sanitization of file paths in build outputs.
105104
* [`[lints.cargo]`](#lintscargo) --- Allows configuring lints for Cargo.
106105
* [path bases](#path-bases) --- Named base directories for path dependencies.
@@ -1363,32 +1362,6 @@ Differences between `cargo run --manifest-path <path>` and `cargo <path>`
13631362

13641363
### Documentation Updates
13651364

1366-
## Edition 2024
1367-
* Tracking Issue: (none created yet)
1368-
* RFC: [rust-lang/rfcs#3501](https://github.com/rust-lang/rfcs/pull/3501)
1369-
1370-
Support for the 2024 [edition] can be enabled by adding the `edition2024`
1371-
unstable feature to the top of `Cargo.toml`:
1372-
1373-
```toml
1374-
cargo-features = ["edition2024"]
1375-
1376-
[package]
1377-
name = "my-package"
1378-
version = "0.1.0"
1379-
edition = "2024"
1380-
```
1381-
1382-
If you want to transition an existing project from a previous edition, then
1383-
`cargo fix --edition` can be used on the nightly channel. After running `cargo
1384-
fix`, you can switch the edition to 2024 as illustrated above.
1385-
1386-
This feature is very unstable, and is only intended for early testing and
1387-
experimentation. Future nightly releases may introduce changes for the 2024
1388-
edition that may break your build.
1389-
1390-
[edition]: ../../edition-guide/index.html
1391-
13921365
## Profile `trim-paths` option
13931366

13941367
* Tracking Issue: [rust-lang/cargo#12137](https://github.com/rust-lang/cargo/issues/12137)
@@ -2013,3 +1986,10 @@ default behavior.
20131986

20141987
See the [build script documentation](build-scripts.md#rustc-check-cfg) for information
20151988
about specifying custom cfgs.
1989+
1990+
## Edition 2024
1991+
1992+
The 2024 edition has been stabilized in the 1.85 release.
1993+
See the [`edition` field](manifest.md#the-edition-field) for more information on setting the edition.
1994+
See [`cargo fix --edition`](../commands/cargo-fix.md) and [The Edition Guide](../../edition-guide/index.html) for more information on migrating existing projects.
1995+

src/doc/src/reference/workspaces.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ resolver = "2"
7676
[package]
7777
name = "hello_world" # the name of the package
7878
version = "0.1.0" # the current version, obeying semver
79-
edition = "2021" # the edition, will have no effect on a resolver used in the workspace
79+
edition = "2024" # the edition, will have no effect on a resolver used in the workspace
8080
authors = ["Alice <[email protected]>", "Bob <[email protected]>"]
8181
```
8282

src/etc/man/cargo-init.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Create a package with a library target (\fBsrc/lib.rs\fR).
3636
.sp
3737
\fB\-\-edition\fR \fIedition\fR
3838
.RS 4
39-
Specify the Rust edition to use. Default is 2021.
39+
Specify the Rust edition to use. Default is 2024.
4040
Possible values: 2015, 2018, 2021, 2024
4141
.RE
4242
.sp

src/etc/man/cargo-new.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Create a package with a library target (\fBsrc/lib.rs\fR).
3131
.sp
3232
\fB\-\-edition\fR \fIedition\fR
3333
.RS 4
34-
Specify the Rust edition to use. Default is 2021.
34+
Specify the Rust edition to use. Default is 2024.
3535
Possible values: 2015, 2018, 2021, 2024
3636
.RE
3737
.sp

0 commit comments

Comments
 (0)