34
34
//! The steps for adding new Cargo.toml syntax are:
35
35
//!
36
36
//! 1. Add the cargo-features unstable gate. Search below for "look here" to
37
- //! find the `features!` macro and add your feature to the list.
37
+ //! find the [ `features!`] macro invocation and add your feature to the list.
38
38
//!
39
39
//! 2. Update the Cargo.toml parsing code to handle your new feature.
40
40
//!
62
62
//!
63
63
//! 1. Add the option to the [`CliUnstable`] struct below. Flags can take an
64
64
//! optional value if you want.
65
- //! 2. Update the [`CliUnstable::add`][CliUnstable] function to parse the flag.
65
+ //! 2. Update the [`CliUnstable::add`] function to parse the flag.
66
66
//! 3. Wherever the new functionality is implemented, call
67
- //! [`Config::cli_unstable`][crate::util::config::Config::cli_unstable] to
68
- //! get an instance of `CliUnstable` and check if the option has been
69
- //! enabled on the `CliUnstable` instance. Nightly gating is already
70
- //! handled, so no need to worry about that.
67
+ //! [`Config::cli_unstable`] to get an instance of [`CliUnstable`]
68
+ //! and check if the option has been enabled on the [`CliUnstable`] instance.
69
+ //! Nightly gating is already handled, so no need to worry about that.
71
70
//!
72
71
//! ## Stabilization
73
72
//!
77
76
//! The steps for stabilizing are roughly:
78
77
//!
79
78
//! 1. Update the feature to be stable, based on the kind of feature:
80
- //! 1. `cargo-features`: Change the feature to `stable` in the `features!`
81
- //! macro below, and include the version and a URL for the documentation.
82
- //! 2. `-Z unstable-options`: Find the call to `fail_if_stable_opt` and
79
+ //! 1. `cargo-features`: Change the feature to `stable` in the [`features!`]
80
+ //! macro invocation below, and include the version and a URL for the
81
+ //! documentation.
82
+ //! 2. `-Z unstable-options`: Find the call to [`fail_if_stable_opt`] and
83
83
//! remove it. Be sure to update the man pages if necessary.
84
- //! 3. `-Z` flag: Change the parsing code in [`CliUnstable::add`][CliUnstable]
85
- //! to call `stabilized_warn` or `stabilized_err` and remove the field from
86
- //! `CliUnstable. Remove the `(unstable)` note in the clap help text if
84
+ //! 3. `-Z` flag: Change the parsing code in [`CliUnstable::add`] to call
85
+ //! `stabilized_warn` or `stabilized_err` and remove the field from
86
+ //! [ `CliUnstable`] . Remove the `(unstable)` note in the clap help text if
87
87
//! necessary.
88
88
//! 2. Remove `masquerade_as_nightly_cargo` from any tests, and remove
89
89
//! `cargo-features` from `Cargo.toml` test files if any. You can
92
92
//! 3. Update the docs in unstable.md to move the section to the bottom
93
93
//! and summarize it similar to the other entries. Update the rest of the
94
94
//! documentation to add the new feature.
95
+ //!
96
+ //! [`Config::cli_unstable`]: crate::util::config::Config::cli_unstable
97
+ //! [`fail_if_stable_opt`]: CliUnstable::fail_if_stable_opt
98
+ //! [`features!`]: macro.features.html
95
99
96
100
use std:: collections:: BTreeSet ;
97
101
use std:: env;
@@ -112,7 +116,47 @@ pub const SEE_CHANNELS: &str =
112
116
"See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information \
113
117
about Rust release channels.";
114
118
115
- /// The edition of the compiler (RFC 2052)
119
+ /// The edition of the compiler ([RFC 2052])
120
+ ///
121
+ /// The following sections will guide you how to add and stabilize an edition.
122
+ ///
123
+ /// ## Adding a new edition
124
+ ///
125
+ /// - Add the next edition to the enum.
126
+ /// - Update every match expression that now fails to compile.
127
+ /// - Update the [`FromStr`] impl.
128
+ /// - Update [`CLI_VALUES`] to include the new edition.
129
+ /// - Set [`LATEST_UNSTABLE`] to Some with the new edition.
130
+ /// - Add an unstable feature to the [`features!`] macro invocation below for the new edition.
131
+ /// - Gate on that new feature in [`TomlManifest::to_real_manifest`].
132
+ /// - Update the shell completion files.
133
+ /// - Update any failing tests (hopefully there are very few).
134
+ /// - Update unstable.md to add a new section for this new edition (see [this example]).
135
+ ///
136
+ /// ## Stabilization instructions
137
+ ///
138
+ /// - Set [`LATEST_UNSTABLE`] to None.
139
+ /// - Set [`LATEST_STABLE`] to the new version.
140
+ /// - Update [`is_stable`] to `true`.
141
+ /// - Set the editionNNNN feature to stable in the [`features!`] macro invocation below.
142
+ /// - Update any tests that are affected.
143
+ /// - Update the man page for the `--edition` flag.
144
+ /// - Update unstable.md to move the edition section to the bottom.
145
+ /// - Update the documentation:
146
+ /// - Update any features impacted by the edition.
147
+ /// - Update manifest.md#the-edition-field.
148
+ /// - Update the `--edition` flag (options-new.md).
149
+ /// - Rebuild man pages.
150
+ ///
151
+ /// [RFC 2052]: https://rust-lang.github.io/rfcs/2052-epochs.html
152
+ /// [`FromStr`]: Edition::from_str
153
+ /// [`CLI_VALUES`]: Edition::CLI_VALUES
154
+ /// [`LATEST_UNSTABLE`]: Edition::LATEST_UNSTABLE
155
+ /// [`LATEST_STABLE`]: Edition::LATEST_STABLE
156
+ /// [this example]: https://github.com/rust-lang/cargo/blob/3ebb5f15a940810f250b68821149387af583a79e/src/doc/src/reference/unstable.md?plain=1#L1238-L1264
157
+ /// [`is_stable`]: Edition::is_stable
158
+ /// [`TomlManifest::to_real_manifest`]: crate::util::toml::TomlManifest::to_real_manifest
159
+ /// [`features!`]: macro.features.html
116
160
#[ derive( Clone , Copy , Debug , Hash , PartialOrd , Ord , Eq , PartialEq , Serialize , Deserialize ) ]
117
161
pub enum Edition {
118
162
/// The 2015 edition
@@ -123,33 +167,6 @@ pub enum Edition {
123
167
Edition2021 ,
124
168
}
125
169
126
- // Adding a new edition:
127
- // - Add the next edition to the enum.
128
- // - Update every match expression that now fails to compile.
129
- // - Update the `FromStr` impl.
130
- // - Update CLI_VALUES to include the new edition.
131
- // - Set LATEST_UNSTABLE to Some with the new edition.
132
- // - Add an unstable feature to the features! macro below for the new edition.
133
- // - Gate on that new feature in TomlManifest::to_real_manifest.
134
- // - Update the shell completion files.
135
- // - Update any failing tests (hopefully there are very few).
136
- // - Update unstable.md to add a new section for this new edition (see
137
- // https://github.com/rust-lang/cargo/blob/3ebb5f15a940810f250b68821149387af583a79e/src/doc/src/reference/unstable.md?plain=1#L1238-L1264
138
- // as an example).
139
- //
140
- // Stabilization instructions:
141
- // - Set LATEST_UNSTABLE to None.
142
- // - Set LATEST_STABLE to the new version.
143
- // - Update `is_stable` to `true`.
144
- // - Set the editionNNNN feature to stable in the features macro below.
145
- // - Update any tests that are affected.
146
- // - Update the man page for the --edition flag.
147
- // - Update unstable.md to move the edition section to the bottom.
148
- // - Update the documentation:
149
- // - Update any features impacted by the edition.
150
- // - Update manifest.md#the-edition-field.
151
- // - Update the --edition flag (options-new.md).
152
- // - Rebuild man pages.
153
170
impl Edition {
154
171
/// The latest edition that is unstable.
155
172
///
0 commit comments