mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: make the try_match_ident_ignore_ascii_case macro actually return the error.
This allows it to be used as an expression, which I'd like to do very soon.
This commit is contained in:
parent
2024ef56b0
commit
e978645a52
2 changed files with 10 additions and 11 deletions
|
@ -53,19 +53,16 @@ macro_rules! trivial_to_computed_value {
|
||||||
/// FIXME(emilio): The fact that `UnexpectedIdent` is a `SelectorParseError`
|
/// FIXME(emilio): The fact that `UnexpectedIdent` is a `SelectorParseError`
|
||||||
/// doesn't make a lot of sense to me.
|
/// doesn't make a lot of sense to me.
|
||||||
macro_rules! try_match_ident_ignore_ascii_case {
|
macro_rules! try_match_ident_ignore_ascii_case {
|
||||||
($input:expr, $( $match_body:tt )*) => {
|
($input:expr, $( $match_body:tt )*) => {{
|
||||||
let location = $input.current_source_location();
|
let location = $input.current_source_location();
|
||||||
let ident = $input.expect_ident_cloned()?;
|
let ident = $input.expect_ident_cloned()?;
|
||||||
(match_ignore_ascii_case! { &ident,
|
match_ignore_ascii_case! { &ident,
|
||||||
$( $match_body )*
|
$( $match_body )*
|
||||||
_ => Err(()),
|
_ => return Err(location.new_custom_error(
|
||||||
})
|
|
||||||
.map_err(|()| {
|
|
||||||
location.new_custom_error(
|
|
||||||
::selectors::parser::SelectorParseErrorKind::UnexpectedIdent(ident.clone())
|
::selectors::parser::SelectorParseErrorKind::UnexpectedIdent(ident.clone())
|
||||||
)
|
))
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! define_numbered_css_keyword_enum {
|
macro_rules! define_numbered_css_keyword_enum {
|
||||||
|
|
|
@ -293,8 +293,9 @@ impl Parse for TextDecorationLine {
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let result: Result<_, ParseError> = input.try(|input| {
|
let result = input.try(|input| {
|
||||||
try_match_ident_ignore_ascii_case! { input,
|
let ident = input.expect_ident().map_err(|_| ())?;
|
||||||
|
match_ignore_ascii_case! { ident,
|
||||||
"underline" => {
|
"underline" => {
|
||||||
if result.contains(TextDecorationLine::UNDERLINE) {
|
if result.contains(TextDecorationLine::UNDERLINE) {
|
||||||
Err(())
|
Err(())
|
||||||
|
@ -327,6 +328,7 @@ impl Parse for TextDecorationLine {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if result.is_err() {
|
if result.is_err() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue