Skip to content

Commit 80f5a81

Browse files
committed
Auto merge of rust-lang#134929 - compiler-errors:style-edition-2024, r=ytmimi
Stabilize `style_edition = "2024"` in-tree This PR stabilizes the `style_edition` flag in rustfmt. **Why am I doing this in-tree?** The beta release cut is imminent (according to forge, on January 3) and this is the most lightweight approach to getting this flag stable on nightly. It's imperative (as far as I can tell -- `@traviscross` can verify or disagree) that we stabilize the `style_edition` flag so that users can control their style edition separately from the edition. I'm happy to move this PR to the rustfmt repo and subsequently prepare a subtree sync if someone on `@rust-lang/rustfmt` believes that we should get this landed on the rustfmt side then synced. If this is the right recourse, I'd like to note that this is still quite time-sensitive. However, I'm happy to dedicate time to get this done if necessary, since I'd really like to un-jeopardize the style edition. Tracking: - rust-lang#123799
2 parents 4e5fec2 + f694db1 commit 80f5a81

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

Diff for: src/tools/rustfmt/src/bin/main.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,6 @@ impl GetOptsOptions {
568568
if let Some(ref file_lines) = matches.opt_str("file-lines") {
569569
options.file_lines = file_lines.parse()?;
570570
}
571-
if let Some(ref edition_str) = matches.opt_str("style-edition") {
572-
options.style_edition =
573-
Some(style_edition_from_style_edition_str(edition_str)?);
574-
}
575571
} else {
576572
let mut unstable_options = vec![];
577573
if matches.opt_present("skip-children") {
@@ -583,9 +579,6 @@ impl GetOptsOptions {
583579
if matches.opt_present("file-lines") {
584580
unstable_options.push("`--file-lines`");
585581
}
586-
if matches.opt_present("style-edition") {
587-
unstable_options.push("`--style-edition`");
588-
}
589582
if !unstable_options.is_empty() {
590583
let s = if unstable_options.len() == 1 { "" } else { "s" };
591584
return Err(format_err!(
@@ -661,6 +654,10 @@ impl GetOptsOptions {
661654
}
662655
}
663656

657+
if let Some(ref edition_str) = matches.opt_str("style-edition") {
658+
options.style_edition = Some(style_edition_from_style_edition_str(edition_str)?);
659+
}
660+
664661
Ok(options)
665662
}
666663

Diff for: src/tools/rustfmt/src/config/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub(crate) mod style_edition;
2929
// This macro defines configuration options used in rustfmt. Each option
3030
// is defined as follows:
3131
//
32-
// `name: value type, default value, is stable, description;`
32+
// `name: value type, is stable, description;`
3333
create_config! {
3434
// Fundamental stuff
3535
max_width: MaxWidth, true, "Maximum width of each line";
@@ -149,7 +149,7 @@ create_config! {
149149
blank_lines_lower_bound: BlankLinesLowerBound, false,
150150
"Minimum number of blank lines which must be put between items";
151151
edition: EditionConfig, true, "The edition of the parser (RFC 2052)";
152-
style_edition: StyleEditionConfig, false, "The edition of the Style Guide (RFC 3338)";
152+
style_edition: StyleEditionConfig, true, "The edition of the Style Guide (RFC 3338)";
153153
version: VersionConfig, false, "Version of formatting rules";
154154
inline_attribute_width: InlineAttributeWidth, false,
155155
"Write an item and its attribute on the same line \

Diff for: src/tools/rustfmt/src/config/options.rs

-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ pub enum StyleEdition {
511511
Edition2021,
512512
#[value = "2024"]
513513
#[doc_hint = "2024"]
514-
#[unstable_variant]
515514
/// [Edition 2024]().
516515
Edition2024,
517516
}

0 commit comments

Comments
 (0)