Skip to content

Commit

Permalink
Add edition 2027
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhuichen committed Sep 25, 2024
1 parent 6157568 commit 0b0dbe8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ fn edition_from_edition_str(edition_str: &str) -> Result<Edition> {
"2018" => Ok(Edition::Edition2018),
"2021" => Ok(Edition::Edition2021),
"2024" => Ok(Edition::Edition2024),
"2027" => Ok(Edition::Edition2027),
_ => Err(format_err!("Invalid value for `--edition`")),
}
}
Expand All @@ -770,6 +771,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
13 changes: 13 additions & 0 deletions src/config/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ pub enum Edition {
#[doc_hint = "2024"]
/// Edition 2024.
Edition2024,
#[value = "2027"]
#[doc_hint = "2027"]
/// Edition 2027.
Edition2027,
}

impl Default for Edition {
Expand All @@ -458,6 +462,8 @@ impl From<Edition> for rustc_span::edition::Edition {
Edition::Edition2018 => Self::Edition2018,
Edition::Edition2021 => Self::Edition2021,
Edition::Edition2024 => Self::Edition2024,
// TODO: update to 2027 after rustc change
Edition::Edition2027 => Self::Edition2024,
}
}
}
Expand All @@ -469,6 +475,7 @@ impl From<Edition> for StyleEdition {
Edition::Edition2018 => StyleEdition::Edition2018,
Edition::Edition2021 => StyleEdition::Edition2021,
Edition::Edition2024 => StyleEdition::Edition2024,
Edition::Edition2027 => StyleEdition::Edition2027,
}
}
}
Expand Down Expand Up @@ -514,6 +521,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 +535,7 @@ impl From<StyleEdition> for rustc_span::edition::Edition {
StyleEdition::Edition2018 => Self::Edition2018,
StyleEdition::Edition2021 => Self::Edition2021,
StyleEdition::Edition2024 => Self::Edition2024,
StyleEdition::Edition2027 => Self::Edition2024,
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/config/style_edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ 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,
$crate::config::StyleEdition::Edition2024
| $crate::config::StyleEdition::Edition2027 => $default_2024,
}
}
}
Expand All @@ -52,6 +53,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 +68,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 0b0dbe8

Please sign in to comment.