Skip to content

Commit

Permalink
Add style_edition 2027 (#6324)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhuichen authored Sep 27, 2024
1 parent 6157568 commit 5f48fe9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ fn style_edition_from_style_edition_str(edition_str: &str) -> Result<StyleEditio
"2018" => Ok(StyleEdition::Edition2018),
"2021" => Ok(StyleEdition::Edition2021),
"2024" => Ok(StyleEdition::Edition2024),
"2027" => Ok(StyleEdition::Edition2027),
_ => Err(format_err!("Invalid value for `--style-edition`")),
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/config/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,11 @@ pub enum StyleEdition {
#[unstable_variant]
/// [Edition 2024]().
Edition2024,
#[value = "2027"]
#[doc_hint = "2027"]
#[unstable_variant]
/// [Edition 2027]().
Edition2027,
}

impl From<StyleEdition> for rustc_span::edition::Edition {
Expand All @@ -523,6 +528,8 @@ impl From<StyleEdition> for rustc_span::edition::Edition {
StyleEdition::Edition2018 => Self::Edition2018,
StyleEdition::Edition2021 => Self::Edition2021,
StyleEdition::Edition2024 => Self::Edition2024,
// TODO: should update to Edition2027 when it becomes available
StyleEdition::Edition2027 => Self::Edition2024,
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/config/style_edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ macro_rules! style_edition_default {
$crate::config::StyleEdition::Edition2015
| $crate::config::StyleEdition::Edition2018
| $crate::config::StyleEdition::Edition2021 => $default_2015,
$crate::config::StyleEdition::Edition2024 => $default_2024,
// TODO: should update macro when default_2027 becomes available
$crate::config::StyleEdition::Edition2024
| $crate::config::StyleEdition::Edition2027 => $default_2024,
}
}
}
Expand All @@ -52,6 +54,7 @@ mod test {
assert_eq!(Unit::style_edition_default(StyleEdition::Edition2018), 100);
assert_eq!(Unit::style_edition_default(StyleEdition::Edition2021), 100);
assert_eq!(Unit::style_edition_default(StyleEdition::Edition2024), 100);
assert_eq!(Unit::style_edition_default(StyleEdition::Edition2027), 100);
}

#[test]
Expand All @@ -66,5 +69,6 @@ mod test {

// style edition 2024
assert_eq!(Unit::style_edition_default(StyleEdition::Edition2024), 50);
assert_eq!(Unit::style_edition_default(StyleEdition::Edition2027), 50);
}
}

0 comments on commit 5f48fe9

Please sign in to comment.