Skip to content

Commit 0c9c54b

Browse files
author
bors-servo
authored
Auto merge of #260 - lqd:warning_begone, r=SimonSapin
Work around warning from `late_bound_lifetime_arguments` lint The generic parsing functions require lifetime annotations to build because of rust-lang/rust#42508. However, this creates a warning from the `late_bound_lifetime_arguments` compatibility lint, described in rust-lang/rust#42868, because they have both early-bound and late-bound lifetime parameters. This PR works around this warning, in a functional but sub-optimal way. The result is quite verbose, and I didn't manage to "convince" rustc to think all lifetimes were early-bound at the `fn` definitions, but manages to avoid triggering both rust-lang/rust#42508 and the lint, by passing these closures via variables at each call-site. Fixes #254
2 parents bcd27d1 + d5006f6 commit 0c9c54b

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

src/rules_and_declarations.rs

+21-27
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,12 @@ where
281281
// Ident
282282
let result = {
283283
let parser = &mut self.parser;
284-
// FIXME: https://github.com/rust-lang/rust/issues/42508
285-
parse_until_after::<'i, 't, _, _, _>(
286-
self.input,
287-
Delimiter::Semicolon,
288-
|input| {
289-
input.expect_colon()?;
290-
parser.parse_value(name, input)
291-
},
292-
)
284+
// FIXME: https://github.com/servo/rust-cssparser/issues/254
285+
let callback = |input: &mut Parser<'i, '_>| {
286+
input.expect_colon()?;
287+
parser.parse_value(name, input)
288+
};
289+
parse_until_after(self.input, Delimiter::Semicolon, callback)
293290
};
294291
return Some(result.map_err(|e| (e, self.input.slice_from(start.position()))));
295292
}
@@ -483,10 +480,9 @@ where
483480
{
484481
let location = input.current_source_location();
485482
let delimiters = Delimiter::Semicolon | Delimiter::CurlyBracketBlock;
486-
// FIXME: https://github.com/rust-lang/rust/issues/42508
487-
let result = parse_until_before::<'i, 't, _, _, _>(input, delimiters, |input| {
488-
parser.parse_prelude(name, input)
489-
});
483+
// FIXME: https://github.com/servo/rust-cssparser/issues/254
484+
let callback = |input: &mut Parser<'i, '_>| parser.parse_prelude(name, input);
485+
let result = parse_until_before(input, delimiters, callback);
490486
match result {
491487
Ok(AtRuleType::WithoutBlock(prelude)) => match input.next() {
492488
Ok(&Token::Semicolon) | Err(_) => Ok(parser.rule_without_block(prelude, location)),
@@ -499,11 +495,11 @@ where
499495
Ok(AtRuleType::WithBlock(prelude)) => {
500496
match input.next() {
501497
Ok(&Token::CurlyBracketBlock) => {
502-
// FIXME: https://github.com/rust-lang/rust/issues/42508
503-
parse_nested_block::<'i, 't, _, _, _>(input, move |input| {
504-
parser.parse_block(prelude, location, input)
505-
})
506-
.map_err(|e| (e, input.slice_from(start.position())))
498+
// FIXME: https://github.com/servo/rust-cssparser/issues/254
499+
let callback =
500+
|input: &mut Parser<'i, '_>| parser.parse_block(prelude, location, input);
501+
parse_nested_block(input, callback)
502+
.map_err(|e| (e, input.slice_from(start.position())))
507503
}
508504
Ok(&Token::Semicolon) => Err((
509505
input.new_unexpected_token_error(Token::Semicolon),
@@ -532,19 +528,17 @@ where
532528
P: QualifiedRuleParser<'i, Error = E>,
533529
{
534530
let location = input.current_source_location();
535-
// FIXME: https://github.com/rust-lang/rust/issues/42508
536-
let prelude =
537-
parse_until_before::<'i, 't, _, _, _>(input, Delimiter::CurlyBracketBlock, |input| {
538-
parser.parse_prelude(input)
539-
});
531+
// FIXME: https://github.com/servo/rust-cssparser/issues/254
532+
let callback = |input: &mut Parser<'i, '_>| parser.parse_prelude(input);
533+
let prelude = parse_until_before(input, Delimiter::CurlyBracketBlock, callback);
540534
match *input.next()? {
541535
Token::CurlyBracketBlock => {
542536
// Do this here so that we consume the `{` even if the prelude is `Err`.
543537
let prelude = prelude?;
544-
// FIXME: https://github.com/rust-lang/rust/issues/42508
545-
parse_nested_block::<'i, 't, _, _, _>(input, move |input| {
546-
parser.parse_block(prelude, location, input)
547-
})
538+
// FIXME: https://github.com/servo/rust-cssparser/issues/254
539+
let callback =
540+
|input: &mut Parser<'i, '_>| parser.parse_block(prelude, location, input);
541+
parse_nested_block(input, callback)
548542
}
549543
_ => unreachable!(),
550544
}

0 commit comments

Comments
 (0)