Skip to content

Commit

Permalink
feat: Stabilize Edition 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Nov 15, 2024
1 parent 88edf01 commit 25a84da
Show file tree
Hide file tree
Showing 49 changed files with 109 additions and 205 deletions.
10 changes: 5 additions & 5 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ impl Edition {
/// The latest edition that is unstable.
///
/// This is `None` if there is no next unstable edition.
pub const LATEST_UNSTABLE: Option<Edition> = Some(Edition::Edition2024);
pub const LATEST_UNSTABLE: Option<Edition> = None;
/// The latest stable edition.
pub const LATEST_STABLE: Edition = Edition::Edition2021;
pub const LATEST_STABLE: Edition = Edition::Edition2024;
pub const ALL: &'static [Edition] = &[
Self::Edition2015,
Self::Edition2018,
Expand All @@ -223,7 +223,7 @@ impl Edition {
Edition2015 => None,
Edition2018 => Some(semver::Version::new(1, 31, 0)),
Edition2021 => Some(semver::Version::new(1, 56, 0)),
Edition2024 => None,
Edition2024 => Some(semver::Version::new(1, 85, 0)),
}
}

Expand All @@ -234,7 +234,7 @@ impl Edition {
Edition2015 => true,
Edition2018 => true,
Edition2021 => true,
Edition2024 => false,
Edition2024 => true,
}
}

Expand Down Expand Up @@ -507,7 +507,7 @@ features! {
(stable, workspace_inheritance, "1.64", "reference/unstable.html#workspace-inheritance"),

/// Support for 2024 edition.
(unstable, edition2024, "", "reference/unstable.html#edition-2024"),
(stable, edition2024, "1.85", "reference/unstable.html#edition-2024"),

/// Allow setting trim-paths in a profile to control the sanitisation of file paths in build outputs.
(unstable, trim_paths, "", "reference/unstable.html#profile-trim-paths-option"),
Expand Down
4 changes: 1 addition & 3 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,9 +1217,7 @@ pub fn to_real_manifest(
// features.require(Feature::edition20xx())?;
// }
// ```
if edition == Edition::Edition2024 {
features.require(Feature::edition2024())?;
} else if !edition.is_stable() {
if !edition.is_stable() {
// Guard in case someone forgets to add .require()
return Err(util::errors::internal(format!(
"edition {} should be gated",
Expand Down
2 changes: 1 addition & 1 deletion src/doc/src/reference/resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ resolver = "2"
- `"2"` ([`edition = "2021"`](manifest.md#the-edition-field) default): Introduces changes in [feature
unification](#features). See the [features chapter][features-2] for more
details.
- `"3"` (requires Rust 1.84+): Change the default for [`resolver.incompatible-rust-versions`] from `allow` to `fallback`
- `"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`

The resolver is a global option that affects the entire workspace. The
`resolver` version in dependencies is ignored, only the value in the top-level
Expand Down
34 changes: 7 additions & 27 deletions src/doc/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ Each new feature described below should explain how to use it.
* [codegen-backend](#codegen-backend) --- Select the codegen backend used by rustc.
* [per-package-target](#per-package-target) --- Sets the `--target` to use for each individual package.
* [artifact dependencies](#artifact-dependencies) --- Allow build artifacts to be included into other build artifacts and build them for different targets.
* [Edition 2024](#edition-2024) — Adds support for the 2024 Edition.
* [Profile `trim-paths` option](#profile-trim-paths-option) --- Control the sanitization of file paths in build outputs.
* [`[lints.cargo]`](#lintscargo) --- Allows configuring lints for Cargo.
* [path bases](#path-bases) --- Named base directories for path dependencies.
Expand Down Expand Up @@ -1363,32 +1362,6 @@ Differences between `cargo run --manifest-path <path>` and `cargo <path>`

### Documentation Updates

## Edition 2024
* Tracking Issue: (none created yet)
* RFC: [rust-lang/rfcs#3501](https://github.com/rust-lang/rfcs/pull/3501)

Support for the 2024 [edition] can be enabled by adding the `edition2024`
unstable feature to the top of `Cargo.toml`:

```toml
cargo-features = ["edition2024"]

[package]
name = "my-package"
version = "0.1.0"
edition = "2024"
```

If you want to transition an existing project from a previous edition, then
`cargo fix --edition` can be used on the nightly channel. After running `cargo
fix`, you can switch the edition to 2024 as illustrated above.

This feature is very unstable, and is only intended for early testing and
experimentation. Future nightly releases may introduce changes for the 2024
edition that may break your build.

[edition]: ../../edition-guide/index.html

## Profile `trim-paths` option

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

See the [build script documentation](build-scripts.md#rustc-check-cfg) for information
about specifying custom cfgs.

## Edition 2024

The 2024 edition has been stabilized in the 1.85 release.
See the [`edition` field](manifest.md#the-edition-field) for more information on setting the edition.
See [`cargo fix --edition`](../commands/cargo-fix.md) and [The Edition Guide](../../edition-guide/index.html) for more information on migrating existing projects.

Loading

0 comments on commit 25a84da

Please sign in to comment.