Skip to content

Commit 4c39aaf

Browse files
authored
feat: Stabilize Edition 2024 (#14828)
### What does this PR try to resolve? ### How should we test and review this PR? ### Additional information
2 parents f1767d0 + 81411ec commit 4c39aaf

File tree

66 files changed

+189
-312
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

+189
-312
lines changed

src/cargo/core/features.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub type AllowFeatures = BTreeSet<String>;
162162
/// - Set [`LATEST_UNSTABLE`] to None.
163163
/// - Set [`LATEST_STABLE`] to the new version.
164164
/// - Update [`is_stable`] to `true`.
165+
/// - Set [`first_version`] to the version it will be released.
165166
/// - Set the editionNNNN feature to stable in the [`features!`] macro invocation below.
166167
/// - Update any tests that are affected.
167168
/// - Update the man page for the `--edition` flag.
@@ -178,6 +179,7 @@ pub type AllowFeatures = BTreeSet<String>;
178179
/// [`LATEST_UNSTABLE`]: Edition::LATEST_UNSTABLE
179180
/// [`LATEST_STABLE`]: Edition::LATEST_STABLE
180181
/// [this example]: https://github.com/rust-lang/cargo/blob/3ebb5f15a940810f250b68821149387af583a79e/src/doc/src/reference/unstable.md?plain=1#L1238-L1264
182+
/// [`first_version`]: Edition::first_version
181183
/// [`is_stable`]: Edition::is_stable
182184
/// [`toml`]: crate::util::toml
183185
/// [`features!`]: macro.features.html
@@ -200,9 +202,9 @@ impl Edition {
200202
/// The latest edition that is unstable.
201203
///
202204
/// This is `None` if there is no next unstable edition.
203-
pub const LATEST_UNSTABLE: Option<Edition> = Some(Edition::Edition2024);
205+
pub const LATEST_UNSTABLE: Option<Edition> = None;
204206
/// The latest stable edition.
205-
pub const LATEST_STABLE: Edition = Edition::Edition2021;
207+
pub const LATEST_STABLE: Edition = Edition::Edition2024;
206208
pub const ALL: &'static [Edition] = &[
207209
Self::Edition2015,
208210
Self::Edition2018,
@@ -223,7 +225,7 @@ impl Edition {
223225
Edition2015 => None,
224226
Edition2018 => Some(semver::Version::new(1, 31, 0)),
225227
Edition2021 => Some(semver::Version::new(1, 56, 0)),
226-
Edition2024 => None,
228+
Edition2024 => Some(semver::Version::new(1, 85, 0)),
227229
}
228230
}
229231

@@ -234,7 +236,7 @@ impl Edition {
234236
Edition2015 => true,
235237
Edition2018 => true,
236238
Edition2021 => true,
237-
Edition2024 => false,
239+
Edition2024 => true,
238240
}
239241
}
240242

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

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

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

src/cargo/util/toml/embedded.rs

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)