]> git.proxmox.com Git - cargo.git/commitdiff
Stabilize 2021 edition
authorEric Huss <eric@huss.org>
Tue, 17 Aug 2021 15:43:11 +0000 (08:43 -0700)
committerEric Huss <eric@huss.org>
Wed, 1 Sep 2021 05:24:00 +0000 (22:24 -0700)
12 files changed:
src/cargo/core/features.rs
src/doc/man/generated_txt/cargo-init.txt
src/doc/man/generated_txt/cargo-new.txt
src/doc/man/includes/options-new.md
src/doc/src/commands/cargo-init.md
src/doc/src/commands/cargo-new.md
src/doc/src/reference/manifest.md
src/doc/src/reference/resolver.md
src/doc/src/reference/unstable.md
src/etc/man/cargo-init.1
src/etc/man/cargo-new.1
tests/testsuite/new.rs

index d2661eaef1741076f856776d816cd0ea67d57cce..fc1d6f78312d430802d605c51c5d1d3694eb4704 100644 (file)
@@ -150,9 +150,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::Edition2021);
+    pub const LATEST_UNSTABLE: Option<Edition> = None;
     /// The latest stable edition.
-    pub const LATEST_STABLE: Edition = Edition::Edition2018;
+    pub const LATEST_STABLE: Edition = Edition::Edition2021;
     /// Possible values allowed for the `--edition` CLI flag.
     ///
     /// This requires a static value due to the way clap works, otherwise I
@@ -176,7 +176,7 @@ impl Edition {
         match self {
             Edition2015 => true,
             Edition2018 => true,
-            Edition2021 => false,
+            Edition2021 => true,
         }
     }
 
@@ -398,7 +398,7 @@ features! {
     (stable, rust_version, "1.56", "reference/manifest.html#the-rust-version-field"),
 
     // Support for 2021 edition.
-    (unstable, edition2021, "", "reference/unstable.html#edition-2021"),
+    (stable, edition2021, "1.56", "reference/manifest.html#the-edition-field"),
 
     // Allow to specify per-package targets (compile kinds)
     (unstable, per_package_target, "", "reference/unstable.html#per-package-target"),
index e96abbb28dec8695de338b719c486268265ea61b..443f8fa0b9e22ebe606e4ab814b37055f322804e 100644 (file)
@@ -30,7 +30,7 @@ OPTIONS
            Create a package with a library target (src/lib.rs).
 
        --edition edition
-           Specify the Rust edition to use. Default is 2018. Possible values:
+           Specify the Rust edition to use. Default is 2021. Possible values:
            2015, 2018, 2021
 
        --name name
index 69ccfe3752129657082fb523ea1cb55daeb657b1..4ea0ccba83dd7134b83dfcf512905805d368e47d 100644 (file)
@@ -25,7 +25,7 @@ OPTIONS
            Create a package with a library target (src/lib.rs).
 
        --edition edition
-           Specify the Rust edition to use. Default is 2018. Possible values:
+           Specify the Rust edition to use. Default is 2021. Possible values:
            2015, 2018, 2021
 
        --name name
index 30e2b34269d3894431153529a366c0b82e2b233e..e9792f05e6a3902c9d57641584d39ab3fd4b56cc 100644 (file)
@@ -10,7 +10,7 @@ Create a package with a library target (`src/lib.rs`).
 {{/option}}
 
 {{#option "`--edition` _edition_" }}
-Specify the Rust edition to use. Default is 2018.
+Specify the Rust edition to use. Default is 2021.
 Possible values: 2015, 2018, 2021
 {{/option}}
 
index 4e5dc50456ecadf90418e168c708165822e78afe..b6790596a6c9f1d9e81347e85c829f3708e5fa60 100644 (file)
@@ -39,7 +39,7 @@ This is the default behavior.</dd>
 
 
 <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>
-<dd class="option-desc">Specify the Rust edition to use. Default is 2018.
+<dd class="option-desc">Specify the Rust edition to use. Default is 2021.
 Possible values: 2015, 2018, 2021</dd>
 
 
index 8236a08fbbd1191b1f4f903b13d8c98ebc8c04cc..c9257d91293a65158ddf67266f9ff0dda91c0c97 100644 (file)
@@ -34,7 +34,7 @@ This is the default behavior.</dd>
 
 
 <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>
-<dd class="option-desc">Specify the Rust edition to use. Default is 2018.
+<dd class="option-desc">Specify the Rust edition to use. Default is 2021.
 Possible values: 2015, 2018, 2021</dd>
 
 
index 0a3566b50621c06a3b659d074bb67dec53249d46..81ea65ce79a7b18b165e4b5fa04b51d79afab43a 100644 (file)
@@ -133,12 +133,12 @@ examples, etc.
 ```toml
 [package]
 # ...
-edition = '2018'
+edition = '2021'
 ```
 
 Most manifests have the `edition` field filled in automatically by [`cargo new`]
 with the latest stable edition. By default `cargo new` creates a manifest with
-the 2018 edition currently.
+the 2021 edition currently.
 
 If the `edition` field is not present in `Cargo.toml`, then the 2015 edition is
 assumed for backwards compatibility. Note that all manifests
index d6a97f1621b2ee58ab6541e1a75478d024ebf788..d3476d08366a84e8174dda4fa4d8422082620767 100644 (file)
@@ -408,8 +408,9 @@ version = "1.0.0"
 resolver = "2"
 ```
 
-The version `"1"` resolver is the original resolver that shipped with Cargo up
-to version 1.50, and is the default if the `resolver` is not specified.
+The version `"1"` resolver is the original resolver that shipped with Cargo up to version 1.50.
+The default is `"2"` if the root package specifies [`edition = "2021"`](manifest.md#the-edition-field) or a newer edition.
+Otherwise the default is `"1"`.
 
 The version `"2"` resolver introduces changes in [feature
 unification](#features). See the [features chapter][features-2] for more
index b64b841de82aeceb1dfde14da480501cca7d7158..c27b00855822ff897ad4592029900f4a577434af 100644 (file)
@@ -90,7 +90,6 @@ Each new feature described below should explain how to use it.
     * [Custom named profiles](#custom-named-profiles) — Adds custom named profiles in addition to the standard names.
     * [Profile `strip` option](#profile-strip-option) — Forces the removal of debug information and symbols from executables.
     * [per-package-target](#per-package-target) — Sets the `--target` to use for each individual package.
-    * [Edition 2021](#edition-2021) — Adds support for the 2021 Edition.
 * Information and metadata
     * [Build-plan](#build-plan) — Emits JSON information on which commands will be run.
     * [timings](#timings) — Generates a report on how long individual dependencies took to run.
@@ -1169,34 +1168,6 @@ cargo logout -Z credential-process
 [crates.io]: https://crates.io/
 [config file]: config.md
 
-### edition 2021
-* Tracking Issue: [rust-lang/rust#85811](https://github.com/rust-lang/rust/issues/85811)
-
-Support for the 2021 [edition] can be enabled by adding the `edition2021`
-unstable feature to the top of `Cargo.toml`:
-
-```toml
-cargo-features = ["edition2021"]
-
-[package]
-name = "my-package"
-version = "0.1.0"
-edition = "2021"
-```
-
-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 2021 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 2021
-edition that may break your build.
-
-The 2021 edition will set the default [resolver version] to "2".
-
-[edition]: ../../edition-guide/index.html
-[resolver version]: resolver.md#resolver-versions
-
 ### future incompat report
 * RFC: [#2834](https://github.com/rust-lang/rfcs/blob/master/text/2834-cargo-report-future-incompat.md)
 * rustc Tracking Issue: [#71249](https://github.com/rust-lang/rust/issues/71249)
@@ -1444,3 +1415,9 @@ The `-Z patch-in-config` flag, and the corresponding support for
 `[patch]` section in Cargo configuration files has been stabilized in
 the 1.56 release. See the [patch field](config.html#patch) for more
 information.
+
+### edition 2021
+
+The 2021 edition has been stabilized in the 1.56 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.
index 4cba15fb42406b743f9d2731c91c54de315c8bb4..16fc80f780e943cea94e1996f9e94c5f4b0c149e 100644 (file)
@@ -36,7 +36,7 @@ Create a package with a library target (\fBsrc/lib.rs\fR).
 .sp
 \fB\-\-edition\fR \fIedition\fR
 .RS 4
-Specify the Rust edition to use. Default is 2018.
+Specify the Rust edition to use. Default is 2021.
 Possible values: 2015, 2018, 2021
 .RE
 .sp
index 6d507b704f559746d2febc163a604ff083243016..53b23224d0d4c7191311240656856a5f30bd3ff2 100644 (file)
@@ -31,7 +31,7 @@ Create a package with a library target (\fBsrc/lib.rs\fR).
 .sp
 \fB\-\-edition\fR \fIedition\fR
 .RS 4
-Specify the Rust edition to use. Default is 2018.
+Specify the Rust edition to use. Default is 2021.
 Possible values: 2015, 2018, 2021
 .RE
 .sp
index 71fe63be6a2bb7f00d229404015e2e2a04d055ed..7923189ca3209577ab9d308ceb25639608f757b2 100644 (file)
@@ -356,7 +356,7 @@ fn new_with_edition_2018() {
 fn new_default_edition() {
     cargo_process("new foo").run();
     let manifest = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap();
-    assert!(manifest.contains("edition = \"2018\""));
+    assert!(manifest.contains("edition = \"2021\""));
 }
 
 #[cargo_test]