From e978645a5239f7e727d66b07bc7b608f1482ccd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 24 Jan 2018 16:11:35 +0100 Subject: [PATCH] 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. --- components/style/macros.rs | 15 ++++++--------- components/style/values/specified/text.rs | 6 ++++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/components/style/macros.rs b/components/style/macros.rs index ac795bdb09f..c3bf87b51a4 100644 --- a/components/style/macros.rs +++ b/components/style/macros.rs @@ -53,19 +53,16 @@ macro_rules! trivial_to_computed_value { /// FIXME(emilio): The fact that `UnexpectedIdent` is a `SelectorParseError` /// doesn't make a lot of sense to me. 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 ident = $input.expect_ident_cloned()?; - (match_ignore_ascii_case! { &ident, + match_ignore_ascii_case! { &ident, $( $match_body )* - _ => Err(()), - }) - .map_err(|()| { - location.new_custom_error( + _ => return Err(location.new_custom_error( ::selectors::parser::SelectorParseErrorKind::UnexpectedIdent(ident.clone()) - ) - }) - } + )) + } + }} } macro_rules! define_numbered_css_keyword_enum { diff --git a/components/style/values/specified/text.rs b/components/style/values/specified/text.rs index 5db55dd7668..0f60f5d7f4a 100644 --- a/components/style/values/specified/text.rs +++ b/components/style/values/specified/text.rs @@ -293,8 +293,9 @@ impl Parse for TextDecorationLine { } loop { - let result: Result<_, ParseError> = input.try(|input| { - try_match_ident_ignore_ascii_case! { input, + let result = input.try(|input| { + let ident = input.expect_ident().map_err(|_| ())?; + match_ignore_ascii_case! { ident, "underline" => { if result.contains(TextDecorationLine::UNDERLINE) { Err(()) @@ -327,6 +328,7 @@ impl Parse for TextDecorationLine { Ok(()) } } + _ => Err(()), } }); if result.is_err() {