/// 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
match self {
Edition2015 => true,
Edition2018 => true,
- Edition2021 => false,
+ Edition2021 => true,
}
}
(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"),
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
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
{{/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}}
<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>
<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>
```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
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
* [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.
[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)
`[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.
.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
.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
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]