style: Switch all callsites of try() to try_parse() in the style crate.

Fully automated via:

  $ rg -l '\.try\(' | xargs sed -i 's/\.try(/.try_parse(/g'
  $ cd servo/components/style && cargo +nightly fmt

Differential Revision: https://phabricator.services.mozilla.com/D80099
This commit is contained in:
Emilio Cobos Álvarez 2020-06-17 22:27:37 +00:00
parent 5af0d7ca7c
commit 685e749cfc
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
56 changed files with 469 additions and 403 deletions

View file

@ -103,7 +103,7 @@ impl SupportsCondition {
///
/// <https://drafts.csswg.org/css-conditional/#supports_condition>
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
if input.try(|i| i.expect_ident_matching("not")).is_ok() {
if input.try_parse(|i| i.expect_ident_matching("not")).is_ok() {
let inner = SupportsCondition::parse_in_parens(input)?;
return Ok(SupportsCondition::Not(Box::new(inner)));
}
@ -129,7 +129,7 @@ impl SupportsCondition {
loop {
conditions.push(SupportsCondition::parse_in_parens(input)?);
if input
.try(|input| input.expect_ident_matching(keyword))
.try_parse(|input| input.expect_ident_matching(keyword))
.is_err()
{
// Did not find the expected keyword.
@ -175,20 +175,20 @@ impl SupportsCondition {
fn parse_in_parens<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
// Whitespace is normally taken care of in `Parser::next`,
// but we want to not include it in `pos` for the SupportsCondition::FutureSyntax cases.
while input.try(Parser::expect_whitespace).is_ok() {}
while input.try_parse(Parser::expect_whitespace).is_ok() {}
let pos = input.position();
let location = input.current_source_location();
match *input.next()? {
Token::ParenthesisBlock => {
let nested =
input.try(|input| input.parse_nested_block(parse_condition_or_declaration));
let nested = input
.try_parse(|input| input.parse_nested_block(parse_condition_or_declaration));
if nested.is_ok() {
return nested;
}
},
Token::Function(ref ident) => {
let ident = ident.clone();
let nested = input.try(|input| {
let nested = input.try_parse(|input| {
input.parse_nested_block(|input| {
SupportsCondition::parse_functional(&ident, input)
})
@ -239,7 +239,7 @@ fn eval_moz_bool_pref(_: &CStr, _: &ParserContext) -> bool {
pub fn parse_condition_or_declaration<'i, 't>(
input: &mut Parser<'i, 't>,
) -> Result<SupportsCondition, ParseError<'i>> {
if let Ok(condition) = input.try(SupportsCondition::parse) {
if let Ok(condition) = input.try_parse(SupportsCondition::parse) {
Ok(SupportsCondition::Parenthesized(Box::new(condition)))
} else {
Declaration::parse(input).map(SupportsCondition::Declaration)
@ -414,7 +414,7 @@ impl Declaration {
PropertyDeclaration::parse_into(&mut declarations, id, &context, input)
.map_err(|_| input.new_custom_error(()))
})?;
let _ = input.try(parse_important);
let _ = input.try_parse(parse_important);
Ok(())
})
.is_ok()