Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add style_edition 2027 #6324

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a TODO comment here explaining that rustc_span::edition::Edition doesn't have an Edition2027 variant.

}
}
}
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edition2024 default will also extend to 2027. Is this the desired behaviour?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I think that's fine since we don't currently have plans to change any default option values for 2027, but it would be nice to add a TODO comment explaining that we'll need to update the macro once we need to start changing defaults for 2027.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnhuichen want to remind you about the ask to add a comment here.

}
}
}
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);
}
}
Loading