Auto merge of #18280 - emilio:parse-dumbness, r=jdm

style: Avoid dropping a parse error on the floor when checking whether a prop is enabled.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18280)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-08-29 01:34:57 -05:00 committed by GitHub
commit 441ae08d24

View file

@ -1070,7 +1070,7 @@ impl PropertyId {
None => return ::custom_properties::parse_name(property_name)
.map(|name| PropertyId::Custom(::custom_properties::Name::from(name))),
};
id.check_allowed_in(alias, context).map_err(|_| ())?;
id.check_allowed_in(alias, context)?;
Ok(id)
}
@ -1153,8 +1153,11 @@ impl PropertyId {
}
}
fn check_allowed_in(&self, alias: Option<AliasId>, context: &PropertyParserContext)
-> Result<(), PropertyDeclarationParseError<'static>> {
fn check_allowed_in(
&self,
alias: Option<AliasId>,
context: &PropertyParserContext,
) -> Result<(), ()> {
let id: NonCustomPropertyId;
if let Some(alias_id) = alias {
id = alias_id.into();
@ -1174,10 +1177,10 @@ impl PropertyId {
${id_set("DISALLOWED_IN_PAGE_RULE", lambda p: not p.allowed_in_page_rule)}
match context.rule_type {
CssRuleType::Keyframe if DISALLOWED_IN_KEYFRAME_BLOCK.contains(id) => {
return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
return Err(());
}
CssRuleType::Page if DISALLOWED_IN_PAGE_RULE.contains(id) => {
return Err(PropertyDeclarationParseError::NotAllowedInPageRule)
return Err(())
}
_ => {}
}
@ -1242,15 +1245,15 @@ impl PropertyId {
if context.stylesheet_origin != Origin::UserAgent {
if EXPERIMENTAL.contains(id) {
if !passes_pref_check() {
return Err(PropertyDeclarationParseError::ExperimentalProperty);
return Err(())
}
} else {
return Err(PropertyDeclarationParseError::UnknownProperty(self.name().into()));
return Err(())
}
}
} else {
if EXPERIMENTAL.contains(id) && !passes_pref_check() {
return Err(PropertyDeclarationParseError::ExperimentalProperty);
return Err(());
}
}