Skip to content

Commit a1b3393

Browse files
authored
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`
2 parents 92d812d + 893938f commit a1b3393

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/rustc_session/src/config.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use std::hash::Hash;
3535
use std::iter;
3636
use std::path::{Path, PathBuf};
3737
use std::str::{self, FromStr};
38+
use std::sync::LazyLock;
3839

3940
pub mod sigpipe;
4041

@@ -1322,7 +1323,12 @@ mod opt {
13221323
unstable(longer(a, b), move |opts| opts.optmulti(a, b, c, d))
13231324
}
13241325
}
1325-
1326+
static EDITION_STRING: LazyLock<String> = LazyLock::new(|| {
1327+
format!(
1328+
"Specify which edition of the compiler to use when compiling code. \
1329+
The default is {DEFAULT_EDITION} and the latest stable edition is {LATEST_STABLE_EDITION}."
1330+
)
1331+
});
13261332
/// Returns the "short" subset of the rustc command line options,
13271333
/// including metadata for each option, such as whether the option is
13281334
/// part of the stable long-term interface for rustc.
@@ -1355,7 +1361,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
13551361
opt::opt_s(
13561362
"",
13571363
"edition",
1358-
"Specify which edition of the compiler to use when compiling code.",
1364+
&*EDITION_STRING,
13591365
EDITION_NAME_LIST,
13601366
),
13611367
opt::multi_s(

0 commit comments

Comments
 (0)