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

@ -131,7 +131,7 @@ impl Parse for GridLine<specified::Integer> {
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
let mut grid_line = Self::auto();
if input.try(|i| i.expect_ident_matching("auto")).is_ok() {
if input.try_parse(|i| i.expect_ident_matching("auto")).is_ok() {
return Ok(grid_line);
}
@ -144,7 +144,7 @@ impl Parse for GridLine<specified::Integer> {
for _ in 0..3 {
// Maximum possible entities for <grid-line>
let location = input.current_source_location();
if input.try(|i| i.expect_ident_matching("span")).is_ok() {
if input.try_parse(|i| i.expect_ident_matching("span")).is_ok() {
if grid_line.is_span {
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
@ -154,7 +154,7 @@ impl Parse for GridLine<specified::Integer> {
}
grid_line.is_span = true;
} else if let Ok(i) = input.try(|i| specified::Integer::parse(context, i)) {
} else if let Ok(i) = input.try_parse(|i| specified::Integer::parse(context, i)) {
// FIXME(emilio): Probably shouldn't reject if it's calc()...
let value = i.value();
if value == 0 || val_before_span || !grid_line.line_num.is_zero() {
@ -165,7 +165,7 @@ impl Parse for GridLine<specified::Integer> {
MIN_GRID_LINE,
cmp::min(value, MAX_GRID_LINE),
));
} else if let Ok(name) = input.try(|i| i.expect_ident_cloned()) {
} else if let Ok(name) = input.try_parse(|i| i.expect_ident_cloned()) {
if val_before_span || grid_line.ident != atom!("") {
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
@ -432,7 +432,7 @@ impl Parse for RepeatCount<specified::Integer> {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
if let Ok(mut i) = input.try(|i| specified::Integer::parse_positive(context, i)) {
if let Ok(mut i) = input.try_parse(|i| specified::Integer::parse_positive(context, i)) {
if i.value() > MAX_GRID_LINE {
i = specified::Integer::new(MAX_GRID_LINE);
}
@ -671,14 +671,14 @@ impl Parse for LineNameList {
let mut fill_data = None;
loop {
let repeat_parse_result = input.try(|input| {
let repeat_parse_result = input.try_parse(|input| {
input.expect_function_matching("repeat")?;
input.parse_nested_block(|input| {
let count = RepeatCount::parse(context, input)?;
input.expect_comma()?;
let mut names_list = vec![];
names_list.push(parse_line_names(input)?); // there should be at least one
while let Ok(names) = input.try(parse_line_names) {
while let Ok(names) = input.try_parse(parse_line_names) {
names_list.push(names);
}
Ok((names_list, count))
@ -703,7 +703,7 @@ impl Parse for LineNameList {
},
_ => return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
}
} else if let Ok(names) = input.try(parse_line_names) {
} else if let Ok(names) = input.try_parse(parse_line_names) {
line_names.push(names);
} else {
break;