Skip to content

Commit a3e352e

Browse files
committed
Auto merge of #11157 - weihanglo:expose-edition-doc, r=epage
Expose guide to adding a new edition as rustdoc
2 parents d900b67 + 3589509 commit a3e352e

File tree

1 file changed

+57
-40
lines changed

1 file changed

+57
-40
lines changed

src/cargo/core/features.rs

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
//! The steps for adding new Cargo.toml syntax are:
3535
//!
3636
//! 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.
3838
//!
3939
//! 2. Update the Cargo.toml parsing code to handle your new feature.
4040
//!
@@ -62,12 +62,11 @@
6262
//!
6363
//! 1. Add the option to the [`CliUnstable`] struct below. Flags can take an
6464
//! 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.
6666
//! 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.
7170
//!
7271
//! ## Stabilization
7372
//!
@@ -77,13 +76,14 @@
7776
//! The steps for stabilizing are roughly:
7877
//!
7978
//! 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
8383
//! 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
8787
//! necessary.
8888
//! 2. Remove `masquerade_as_nightly_cargo` from any tests, and remove
8989
//! `cargo-features` from `Cargo.toml` test files if any. You can
@@ -92,6 +92,10 @@
9292
//! 3. Update the docs in unstable.md to move the section to the bottom
9393
//! and summarize it similar to the other entries. Update the rest of the
9494
//! 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
9599
96100
use std::collections::BTreeSet;
97101
use std::env;
@@ -112,7 +116,47 @@ pub const SEE_CHANNELS: &str =
112116
"See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information \
113117
about Rust release channels.";
114118

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
116160
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, Eq, PartialEq, Serialize, Deserialize)]
117161
pub enum Edition {
118162
/// The 2015 edition
@@ -123,33 +167,6 @@ pub enum Edition {
123167
Edition2021,
124168
}
125169

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.
153170
impl Edition {
154171
/// The latest edition that is unstable.
155172
///

0 commit comments

Comments
 (0)