about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-01-06 21:26:12 +0100
committerGitHub <noreply@github.com>2023-01-06 21:26:12 +0100
commita1b3393f5feb93c1241452ada9bf39c4349471e7 (patch)
tree2a4cba4b9c9dec684087b224d1aad51e5d13b724
parent92d812de1df16e56c47219001b7c30bbf8843206 (diff)
parent893938f64f7a9ff531b3968c9a9e79e0524606bd (diff)
downloadrust-a1b3393f5feb93c1241452ada9bf39c4349471e7.tar.gz
rust-a1b3393f5feb93c1241452ada9bf39c4349471e7.zip
Rollup merge of #106542 - sigaloid:master, r=bjorn3
Add default and latest stable edition to --edition in rustc (attempt 2)

Fixes #106041

No longer leaks string like my first attempt PR, #106094 - uses LazyLock to construct a `&'static str`

It will now output the default edition and latest stable edition in the help message for the `--edition` flag.

Going to request the same reviewer as the first attempt for continuity - r? `@Nilstrieb`
-rw-r--r--compiler/rustc_session/src/config.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index a87e820386e..1ccfc59f7a9 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -35,6 +35,7 @@ use std::hash::Hash;
 use std::iter;
 use std::path::{Path, PathBuf};
 use std::str::{self, FromStr};
+use std::sync::LazyLock;
 
 pub mod sigpipe;
 
@@ -1322,7 +1323,12 @@ mod opt {
         unstable(longer(a, b), move |opts| opts.optmulti(a, b, c, d))
     }
 }
-
+static EDITION_STRING: LazyLock<String> = LazyLock::new(|| {
+    format!(
+        "Specify which edition of the compiler to use when compiling code. \
+The default is {DEFAULT_EDITION} and the latest stable edition is {LATEST_STABLE_EDITION}."
+    )
+});
 /// Returns the "short" subset of the rustc command line options,
 /// including metadata for each option, such as whether the option is
 /// part of the stable long-term interface for rustc.
@@ -1355,7 +1361,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
         opt::opt_s(
             "",
             "edition",
-            "Specify which edition of the compiler to use when compiling code.",
+            &*EDITION_STRING,
             EDITION_NAME_LIST,
         ),
         opt::multi_s(