Skip to content

Commit e6a783a

Browse files
committed
Stabilize 2021 edition
1 parent 72aee9e commit e6a783a

File tree

12 files changed

+23
-45
lines changed

12 files changed

+23
-45
lines changed

src/cargo/core/features.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ impl Edition {
150150
/// The latest edition that is unstable.
151151
///
152152
/// This is `None` if there is no next unstable edition.
153-
pub const LATEST_UNSTABLE: Option<Edition> = Some(Edition::Edition2021);
153+
pub const LATEST_UNSTABLE: Option<Edition> = None;
154154
/// The latest stable edition.
155-
pub const LATEST_STABLE: Edition = Edition::Edition2018;
155+
pub const LATEST_STABLE: Edition = Edition::Edition2021;
156156
/// Possible values allowed for the `--edition` CLI flag.
157157
///
158158
/// This requires a static value due to the way clap works, otherwise I
@@ -176,7 +176,7 @@ impl Edition {
176176
match self {
177177
Edition2015 => true,
178178
Edition2018 => true,
179-
Edition2021 => false,
179+
Edition2021 => true,
180180
}
181181
}
182182

@@ -398,7 +398,7 @@ features! {
398398
(stable, rust_version, "1.56", "reference/manifest.html#the-rust-version-field"),
399399

400400
// Support for 2021 edition.
401-
(unstable, edition2021, "", "reference/unstable.html#edition-2021"),
401+
(stable, edition2021, "1.56", "reference/manifest.html#the-edition-field"),
402402

403403
// Allow to specify per-package targets (compile kinds)
404404
(unstable, per_package_target, "", "reference/unstable.html#per-package-target"),

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 2018. Possible values:
33+
Specify the Rust edition to use. Default is 2021. Possible values:
3434
2015, 2018, 2021
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 2018. Possible values:
28+
Specify the Rust edition to use. Default is 2021. Possible values:
2929
2015, 2018, 2021
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 2018.
13+
Specify the Rust edition to use. Default is 2021.
1414
Possible values: 2015, 2018, 2021
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 2018.
42+
<dd class="option-desc">Specify the Rust edition to use. Default is 2021.
4343
Possible values: 2015, 2018, 2021</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 2018.
37+
<dd class="option-desc">Specify the Rust edition to use. Default is 2021.
3838
Possible values: 2015, 2018, 2021</dd>
3939

4040

src/doc/src/reference/manifest.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ examples, etc.
133133
```toml
134134
[package]
135135
# ...
136-
edition = '2018'
136+
edition = '2021'
137137
```
138138

139139
Most manifests have the `edition` field filled in automatically by [`cargo new`]
140140
with the latest stable edition. By default `cargo new` creates a manifest with
141-
the 2018 edition currently.
141+
the 2021 edition currently.
142142

143143
If the `edition` field is not present in `Cargo.toml`, then the 2015 edition is
144144
assumed for backwards compatibility. Note that all manifests

src/doc/src/reference/resolver.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,9 @@ version = "1.0.0"
408408
resolver = "2"
409409
```
410410

411-
The version `"1"` resolver is the original resolver that shipped with Cargo up
412-
to version 1.50, and is the default if the `resolver` is not specified.
411+
The version `"1"` resolver is the original resolver that shipped with Cargo up to version 1.50.
412+
The default is `"2"` if the root package specifies [`edition = "2021"`](manifest.md#the-edition-field) or a newer edition.
413+
Otherwise the default is `"1"`.
413414

414415
The version `"2"` resolver introduces changes in [feature
415416
unification](#features). See the [features chapter][features-2] for more

src/doc/src/reference/unstable.md

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ Each new feature described below should explain how to use it.
9090
* [Custom named profiles](#custom-named-profiles) — Adds custom named profiles in addition to the standard names.
9191
* [Profile `strip` option](#profile-strip-option) — Forces the removal of debug information and symbols from executables.
9292
* [per-package-target](#per-package-target) — Sets the `--target` to use for each individual package.
93-
* [Edition 2021](#edition-2021) — Adds support for the 2021 Edition.
9493
* Information and metadata
9594
* [Build-plan](#build-plan) — Emits JSON information on which commands will be run.
9695
* [timings](#timings) — Generates a report on how long individual dependencies took to run.
@@ -1169,34 +1168,6 @@ cargo logout -Z credential-process
11691168
[crates.io]: https://crates.io/
11701169
[config file]: config.md
11711170

1172-
### edition 2021
1173-
* Tracking Issue: [rust-lang/rust#85811](https://github.com/rust-lang/rust/issues/85811)
1174-
1175-
Support for the 2021 [edition] can be enabled by adding the `edition2021`
1176-
unstable feature to the top of `Cargo.toml`:
1177-
1178-
```toml
1179-
cargo-features = ["edition2021"]
1180-
1181-
[package]
1182-
name = "my-package"
1183-
version = "0.1.0"
1184-
edition = "2021"
1185-
```
1186-
1187-
If you want to transition an existing project from a previous edition, then
1188-
`cargo fix --edition` can be used on the nightly channel. After running `cargo
1189-
fix`, you can switch the edition to 2021 as illustrated above.
1190-
1191-
This feature is very unstable, and is only intended for early testing and
1192-
experimentation. Future nightly releases may introduce changes for the 2021
1193-
edition that may break your build.
1194-
1195-
The 2021 edition will set the default [resolver version] to "2".
1196-
1197-
[edition]: ../../edition-guide/index.html
1198-
[resolver version]: resolver.md#resolver-versions
1199-
12001171
### future incompat report
12011172
* RFC: [#2834](https://github.com/rust-lang/rfcs/blob/master/text/2834-cargo-report-future-incompat.md)
12021173
* 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
14441415
`[patch]` section in Cargo configuration files has been stabilized in
14451416
the 1.56 release. See the [patch field](config.html#patch) for more
14461417
information.
1418+
1419+
### edition 2021
1420+
1421+
The 2021 edition has been stabilized in the 1.56 release.
1422+
See the [`edition` field](manifest.md#the-edition-field) for more information on setting the edition.
1423+
See [`cargo fix --edition`](../commands/cargo-fix.md) and [The Edition Guide](../../edition-guide/index.html) for more information on migrating existing projects.

src/etc/man/cargo-init.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Create a package with a library target (\fBsrc/lib.rs\fR).
3636
.sp
3737
\fB\-\-edition\fR \fIedition\fR
3838
.RS 4
39-
Specify the Rust edition to use. Default is 2018.
39+
Specify the Rust edition to use. Default is 2021.
4040
Possible values: 2015, 2018, 2021
4141
.RE
4242
.sp

0 commit comments

Comments
 (0)