Skip to content

Commit

Permalink
refactor: rebase with set_cli() behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcartwright committed Jul 28, 2024
1 parent 0f53d2b commit 1f8c5eb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ impl CliOptions for GetOptsOptions {
config.set_cli().edition(edition);
}
if let Some(edition) = self.style_edition {
config.set().style_edition(edition);
config.set_cli().style_edition(edition);
}
if self.check {
config.set_cli().emit_mode(EmitMode::Diff);
Expand Down
9 changes: 7 additions & 2 deletions src/config/config_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ macro_rules! create_config {
"merge_imports" => self.0.set_merge_imports(),
"fn_args_layout" => self.0.set_fn_args_layout(),
"hide_parse_errors" => self.0.set_hide_parse_errors(),
"version" => self.0.set_version(),
"edition" => self.0.set_edition(),
&_ => (),
}
}
Expand Down Expand Up @@ -576,7 +578,7 @@ macro_rules! create_config {
Use `style_edition` instead."
);

if self.was_set().style_edition() {
if self.was_set().style_edition() || self.was_set_cli().style_edition() {
eprintln!(
"Warning: the deprecated `version` option was \
used in conjunction with the `edition` or \
Expand All @@ -591,7 +593,10 @@ macro_rules! create_config {
}

fn set_edition(&mut self) {
if self.was_set().style_edition() || self.was_set().version() {
let style_edition_set = self.was_set().style_edition()
|| self.was_set_cli().style_edition();

if style_edition_set || self.was_set().version() {
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ match_block_trailing_comma = false
blank_lines_upper_bound = 1
blank_lines_lower_bound = 0
edition = "2015"
style_edition = "2024"
version = "Two"
inline_attribute_width = 0
format_generated_files = true
Expand Down
3 changes: 2 additions & 1 deletion src/config/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,8 @@ config_option_with_style_edition_default!(
BlankLinesUpperBound, usize, _ => 1;
BlankLinesLowerBound, usize, _ => 0;
EditionConfig, Edition, _ => Edition::Edition2015;
StyleEditionConfig, StyleEdition, _ => StyleEdition::Edition2015;
StyleEditionConfig, StyleEdition,
Edition2024 => StyleEdition::Edition2024, _ => StyleEdition::Edition2015;
VersionConfig, Version, Edition2024 => Version::Two, _ => Version::One;
InlineAttributeWidth, usize, _ => 0;
FormatGeneratedFiles, bool, _ => true;
Expand Down

0 comments on commit 1f8c5eb

Please sign in to comment.