1
Fork 0

Split declare_features!.

It's a macro with four clauses, three of which are doing one thing, and
the fourth is doing something completely different. This commit splits
it into two macros, which is more sensible.
This commit is contained in:
Nicholas Nethercote 2023-10-04 10:00:30 +11:00
parent 043a9873b9
commit 3c1b60c1b4

View file

@ -14,16 +14,19 @@ enum FeatureStatus {
Internal, Internal,
} }
macro_rules! declare_features { macro_rules! status_to_enum {
(__status_to_enum active) => { (active) => {
FeatureStatus::Default FeatureStatus::Default
}; };
(__status_to_enum incomplete) => { (incomplete) => {
FeatureStatus::Incomplete FeatureStatus::Incomplete
}; };
(__status_to_enum internal) => { (internal) => {
FeatureStatus::Internal FeatureStatus::Internal
}; };
}
macro_rules! declare_features {
($( ($(
$(#[doc = $doc:tt])* ($status:ident, $feature:ident, $ver:expr, $issue:expr, $edition:expr), $(#[doc = $doc:tt])* ($status:ident, $feature:ident, $ver:expr, $issue:expr, $edition:expr),
)+) => { )+) => {
@ -92,7 +95,7 @@ macro_rules! declare_features {
pub fn incomplete(&self, feature: Symbol) -> bool { pub fn incomplete(&self, feature: Symbol) -> bool {
match feature { match feature {
$( $(
sym::$feature => declare_features!(__status_to_enum $status) == FeatureStatus::Incomplete, sym::$feature => status_to_enum!($status) == FeatureStatus::Incomplete,
)* )*
// accepted and removed features aren't in this file but are never incomplete // accepted and removed features aren't in this file but are never incomplete
_ if self.declared_lang_features.iter().any(|f| f.0 == feature) => false, _ if self.declared_lang_features.iter().any(|f| f.0 == feature) => false,
@ -107,7 +110,7 @@ macro_rules! declare_features {
pub fn internal(&self, feature: Symbol) -> bool { pub fn internal(&self, feature: Symbol) -> bool {
match feature { match feature {
$( $(
sym::$feature => declare_features!(__status_to_enum $status) == FeatureStatus::Internal, sym::$feature => status_to_enum!($status) == FeatureStatus::Internal,
)* )*
// accepted and removed features aren't in this file but are never internal // accepted and removed features aren't in this file but are never internal
// (a removed feature might have been internal, but it doesn't matter anymore) // (a removed feature might have been internal, but it doesn't matter anymore)