mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Remove StaticId.
Destructors in statics are ok now. Differential Revision: https://phabricator.services.mozilla.com/D9004
This commit is contained in:
parent
d0c96bff27
commit
fb0702476a
1 changed files with 18 additions and 41 deletions
|
@ -1671,53 +1671,30 @@ impl PropertyId {
|
||||||
///
|
///
|
||||||
/// Returns Err(()) for unknown non-custom properties.
|
/// Returns Err(()) for unknown non-custom properties.
|
||||||
fn parse_unchecked(property_name: &str) -> Result<Self, ()> {
|
fn parse_unchecked(property_name: &str) -> Result<Self, ()> {
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/33156): remove this
|
|
||||||
// enum and use PropertyId when stable Rust allows destructors in
|
|
||||||
// statics.
|
|
||||||
//
|
|
||||||
// ShorthandAlias is not used in the Servo build.
|
|
||||||
// That's why we need to allow dead_code.
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub enum StaticId {
|
|
||||||
Longhand(LonghandId),
|
|
||||||
Shorthand(ShorthandId),
|
|
||||||
LonghandAlias(LonghandId, AliasId),
|
|
||||||
ShorthandAlias(ShorthandId, AliasId),
|
|
||||||
}
|
|
||||||
ascii_case_insensitive_phf_map! {
|
ascii_case_insensitive_phf_map! {
|
||||||
static_id -> StaticId = {
|
property_id -> PropertyId = {
|
||||||
% for (kind, properties) in [("Longhand", data.longhands), ("Shorthand", data.shorthands)]:
|
% for (kind, properties) in [("Longhand", data.longhands), ("Shorthand", data.shorthands)]:
|
||||||
% for property in properties:
|
% for property in properties:
|
||||||
"${property.name}" => StaticId::${kind}(${kind}Id::${property.camel_case}),
|
"${property.name}" => PropertyId::${kind}(${kind}Id::${property.camel_case}),
|
||||||
% for alias in property.alias:
|
% for alias in property.alias:
|
||||||
"${alias.name}" => {
|
"${alias.name}" => {
|
||||||
StaticId::${kind}Alias(${kind}Id::${property.camel_case},
|
PropertyId::${kind}Alias(
|
||||||
AliasId::${alias.camel_case})
|
${kind}Id::${property.camel_case},
|
||||||
},
|
AliasId::${alias.camel_case},
|
||||||
% endfor
|
)
|
||||||
% endfor
|
},
|
||||||
|
% endfor
|
||||||
|
% endfor
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(match static_id(property_name) {
|
if let Some(id) = property_id(property_name) {
|
||||||
Some(&StaticId::Longhand(id)) => {
|
return Ok(id.clone())
|
||||||
PropertyId::Longhand(id)
|
}
|
||||||
},
|
|
||||||
Some(&StaticId::Shorthand(id)) => {
|
let name = ::custom_properties::parse_name(property_name)?;
|
||||||
PropertyId::Shorthand(id)
|
Ok(PropertyId::Custom(::custom_properties::Name::from(name)))
|
||||||
},
|
|
||||||
Some(&StaticId::LonghandAlias(id, alias)) => {
|
|
||||||
PropertyId::LonghandAlias(id, alias)
|
|
||||||
},
|
|
||||||
Some(&StaticId::ShorthandAlias(id, alias)) => {
|
|
||||||
PropertyId::ShorthandAlias(id, alias)
|
|
||||||
},
|
|
||||||
None => {
|
|
||||||
let name = ::custom_properties::parse_name(property_name)?;
|
|
||||||
PropertyId::Custom(::custom_properties::Name::from(name))
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses a property name, and returns an error if it's unknown or isn't
|
/// Parses a property name, and returns an error if it's unknown or isn't
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue