diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index 8bce51535f84..ce15db2f572c 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -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"), diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index c0f6df61d905..bd1fcf142c9e 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -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", diff --git a/src/doc/src/reference/resolver.md b/src/doc/src/reference/resolver.md index bc41517b21f4..f080509fc58c 100644 --- a/src/doc/src/reference/resolver.md +++ b/src/doc/src/reference/resolver.md @@ -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 diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index 57fc0e030406..200285f1a252 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -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. @@ -1363,32 +1362,6 @@ Differences between `cargo run --manifest-path ` and `cargo ` ### 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) @@ -2010,3 +1983,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. + diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index ace08f4392f5..bf1b0da2a34c 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -831,14 +831,12 @@ fn dev_dependencies2() { "#]]).run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn dev_dependencies2_2024() { let p = project() .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "foo" version = "0.1.0" @@ -861,7 +859,6 @@ fn dev_dependencies2_2024() { .file("a/src/lib.rs", "") .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` @@ -949,14 +946,12 @@ fn build_dependencies2() { "#]]).run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn build_dependencies2_2024() { let p = project() .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "foo" version = "0.1.0" @@ -979,7 +974,6 @@ fn build_dependencies2_2024() { .file("a/src/lib.rs", "") .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` @@ -1060,14 +1054,12 @@ fn lib_crate_type2() { .run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn lib_crate_type2_2024() { let p = project() .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "foo" version = "0.5.0" @@ -1082,7 +1074,6 @@ fn lib_crate_type2_2024() { .file("src/lib.rs", "pub fn foo() {}") .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` @@ -1154,14 +1145,12 @@ fn bin_crate_type2() { .run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn bin_crate_type2_2024() { let p = project() .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "foo" version = "0.5.0" @@ -1177,7 +1166,6 @@ fn bin_crate_type2_2024() { .file("src/main.rs", "fn main() {}") .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` @@ -1268,14 +1256,12 @@ fn examples_crate_type2() { .run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn examples_crate_type2_2024() { let p = project() .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "foo" version = "0.5.0" @@ -1307,7 +1293,6 @@ fn examples_crate_type2_2024() { ) .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` @@ -1411,7 +1396,7 @@ fn cargo_platform_build_dependencies2() { .run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn cargo_platform_build_dependencies2_2024() { let host = rustc_host(); let p = project() @@ -1419,8 +1404,6 @@ fn cargo_platform_build_dependencies2_2024() { "Cargo.toml", &format!( r#" - cargo-features = ["edition2024"] - [package] name = "foo" version = "0.5.0" @@ -1444,7 +1427,6 @@ fn cargo_platform_build_dependencies2_2024() { .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` @@ -1543,7 +1525,7 @@ fn cargo_platform_dev_dependencies2() { .run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn cargo_platform_dev_dependencies2_2024() { let host = rustc_host(); let p = project() @@ -1551,8 +1533,6 @@ fn cargo_platform_dev_dependencies2_2024() { "Cargo.toml", &format!( r#" - cargo-features = ["edition2024"] - [package] name = "foo" version = "0.5.0" @@ -1575,7 +1555,6 @@ fn cargo_platform_dev_dependencies2_2024() { .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` @@ -1675,14 +1654,12 @@ fn default_features2() { "#]]).run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn default_features2_2024() { let p = project() .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "foo" version = "0.1.0" @@ -1712,7 +1689,6 @@ fn default_features2_2024() { .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` @@ -1852,7 +1828,7 @@ fn workspace_default_features2() { .run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn workspace_default_features2_2024() { let p = project() .file( @@ -1869,8 +1845,6 @@ fn workspace_default_features2_2024() { .file( "workspace_only/Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "workspace_only" version = "0.1.0" @@ -1885,8 +1859,6 @@ fn workspace_default_features2_2024() { .file( "dep_workspace_only/Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "dep_workspace_only" version = "0.1.0" @@ -1898,8 +1870,6 @@ fn workspace_default_features2_2024() { .file( "package_only/Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "package_only" version = "0.1.0" @@ -1914,8 +1884,6 @@ fn workspace_default_features2_2024() { .file( "dep_package_only/Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "dep_package_only" version = "0.1.0" @@ -1927,7 +1895,6 @@ fn workspace_default_features2_2024() { .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to load manifest for workspace member `[ROOT]/foo/workspace_only` @@ -1972,14 +1939,12 @@ fn lib_proc_macro2() { .run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn lib_proc_macro2_2024() { let foo = project() .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "foo" version = "0.1.0" @@ -1992,7 +1957,6 @@ fn lib_proc_macro2_2024() { .build(); foo.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` @@ -2063,14 +2027,12 @@ fn bin_proc_macro2() { .run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn bin_proc_macro2_2024() { let foo = project() .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "foo" version = "0.5.0" @@ -2087,7 +2049,6 @@ fn bin_proc_macro2_2024() { .build(); foo.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index c719fce55e67..9e4f56416c0e 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -1077,14 +1077,12 @@ fn warn_manifest_with_project() { .run(); } -#[cargo_test(nightly, reason = "edition2024")] +#[cargo_test] fn error_manifest_with_project_on_2024() { let p = project() .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [project] name = "foo" version = "0.0.1" @@ -1095,7 +1093,6 @@ fn error_manifest_with_project_on_2024() { .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` diff --git a/tests/testsuite/fix.rs b/tests/testsuite/fix.rs index 15fb306342cf..df60abcfba77 100644 --- a/tests/testsuite/fix.rs +++ b/tests/testsuite/fix.rs @@ -2361,8 +2361,6 @@ fn migrate_project_to_package() { .file( "Cargo.toml", r#" -cargo-features = ["edition2024"] - # Before project [ project ] # After project header # After project header line @@ -2375,7 +2373,6 @@ edition = "2021" .build(); p.cargo("fix --edition --allow-no-vcs") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_stderr_data(str![[r#" [MIGRATING] Cargo.toml from 2021 edition to 2024 [FIXED] Cargo.toml (1 fix) @@ -2389,8 +2386,6 @@ edition = "2021" p.read_file("Cargo.toml"), str![[r#" -cargo-features = ["edition2024"] - # Before project [ package ] # After project header # After project header line @@ -2408,8 +2403,6 @@ fn migrate_removes_project() { .file( "Cargo.toml", r#" -cargo-features = ["edition2024"] - # Before package [ package ] # After package header # After package header line @@ -2429,7 +2422,6 @@ edition = "2021" .build(); p.cargo("fix --edition --allow-no-vcs") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_stderr_data(str![[r#" [MIGRATING] Cargo.toml from 2021 edition to 2024 [FIXED] Cargo.toml (1 fix) @@ -2443,8 +2435,6 @@ edition = "2021" p.read_file("Cargo.toml"), str![[r#" -cargo-features = ["edition2024"] - # Before package [ package ] # After package header # After package header line @@ -2462,8 +2452,6 @@ fn migrate_rename_underscore_fields() { .file( "Cargo.toml", r#" -cargo-features = ["edition2024"] - [workspace.dependencies] # Before default_features a = {path = "a", default_features = false} # After default_features value @@ -2531,7 +2519,6 @@ a = {path = "a", default_features = false} .build(); p.cargo("fix --edition --allow-no-vcs") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_stderr_data(str![[r#" [MIGRATING] Cargo.toml from 2021 edition to 2024 [FIXED] Cargo.toml (11 fixes) @@ -2547,8 +2534,6 @@ a = {path = "a", default_features = false} p.read_file("Cargo.toml"), str![[r#" -cargo-features = ["edition2024"] - [workspace.dependencies] # Before default_features a = {path = "a", default-features = false} # After default_features value @@ -2691,7 +2676,6 @@ dep_df_false = { version = "0.1.0", default-features = false } .build(); p.cargo("fix --all --edition --allow-no-vcs") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_stderr_data( str![[r#" [MIGRATING] pkg_default/Cargo.toml from 2021 edition to 2024 diff --git a/tests/testsuite/inheritable_workspace_fields.rs b/tests/testsuite/inheritable_workspace_fields.rs index 7ac3252eb2ea..14e02aa831d5 100644 --- a/tests/testsuite/inheritable_workspace_fields.rs +++ b/tests/testsuite/inheritable_workspace_fields.rs @@ -1549,7 +1549,7 @@ fn warn_inherit_def_feat_true_member_def_feat_false() { "#]]).run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn warn_inherit_def_feat_true_member_def_feat_false_2024_edition() { Package::new("dep", "0.1.0") .feature("default", &["fancy_dep"]) @@ -1563,8 +1563,6 @@ fn warn_inherit_def_feat_true_member_def_feat_false_2024_edition() { .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "bar" version = "0.2.0" @@ -1583,7 +1581,6 @@ fn warn_inherit_def_feat_true_member_def_feat_false_2024_edition() { .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` @@ -1644,7 +1641,7 @@ fn warn_inherit_simple_member_def_feat_false() { "#]]).run(); } -#[cargo_test(nightly, reason = "edition2024 is not stable")] +#[cargo_test] fn warn_inherit_simple_member_def_feat_false_2024_edition() { Package::new("dep", "0.1.0") .feature("default", &["fancy_dep"]) @@ -1658,8 +1655,6 @@ fn warn_inherit_simple_member_def_feat_false_2024_edition() { .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "bar" version = "0.2.0" @@ -1678,7 +1673,6 @@ fn warn_inherit_simple_member_def_feat_false_2024_edition() { .build(); p.cargo("check") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_status(101) .with_stderr_data(str![[r#" [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` diff --git a/tests/testsuite/rust_version.rs b/tests/testsuite/rust_version.rs index a1af79b6b601..ad8a20071ff3 100644 --- a/tests/testsuite/rust_version.rs +++ b/tests/testsuite/rust_version.rs @@ -515,7 +515,7 @@ higher v0.0.1 ([ROOT]/foo) .run(); } -#[cargo_test(nightly, reason = "edition2024 in rustc is unstable")] +#[cargo_test] fn resolve_edition2024() { Package::new("only-newer", "1.6.0") .rust_version("1.65.0") @@ -534,8 +534,6 @@ fn resolve_edition2024() { .file( "Cargo.toml", r#" - cargo-features = ["edition2024"] - [package] name = "foo" version = "0.0.1" @@ -553,7 +551,6 @@ fn resolve_edition2024() { // Edition2024 should resolve for MSRV p.cargo("generate-lockfile") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [LOCKING] 2 packages to latest Rust 1.60.0 compatible versions @@ -563,7 +560,6 @@ fn resolve_edition2024() { "#]]) .run(); p.cargo("tree") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_stdout_data(str![[r#" foo v0.0.1 ([ROOT]/foo) ├── newer-and-older v1.5.0 @@ -579,10 +575,8 @@ foo v0.0.1 ([ROOT]/foo) [LOCKING] 2 packages to latest compatible versions "#]]) - .masquerade_as_nightly_cargo(&["edition2024"]) .run(); p.cargo("tree") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_stdout_data(str![[r#" foo v0.0.1 ([ROOT]/foo) ├── newer-and-older v1.6.0 @@ -599,10 +593,8 @@ foo v0.0.1 ([ROOT]/foo) [LOCKING] 2 packages to latest compatible versions "#]]) - .masquerade_as_nightly_cargo(&["edition2024"]) .run(); p.cargo("tree") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_stdout_data(str![[r#" foo v0.0.1 ([ROOT]/foo) ├── newer-and-older v1.6.0 @@ -961,7 +953,7 @@ fn cargo_install_ignores_resolver_v3_msrv_change() { .run(); } -#[cargo_test(nightly, reason = "edition2024 in rustc is unstable")] +#[cargo_test] fn cargo_install_ignores_edition_2024_msrv_change() { Package::new("dep", "1.0.0") .rust_version("1.50") @@ -973,14 +965,12 @@ fn cargo_install_ignores_edition_2024_msrv_change() { .publish(); Package::new("foo", "0.0.1") .rust_version("1.60") - .cargo_feature("edition2024") .edition("2024") .file("src/main.rs", "fn main() {}") .dep("dep", "1") .publish(); cargo_process("install foo") - .masquerade_as_nightly_cargo(&["edition2024"]) .with_stderr_data(str![[r#" [UPDATING] `dummy-registry` index [DOWNLOADING] crates ...