Skip to content

Commit 20be7cc

Browse files
authored
Auto merge of #331 - servo:r-and-d-cleanups, r=emilio
Minor rules and declaration cleanups. None
2 parents c8afe3b + bd27360 commit 20be7cc

File tree

3 files changed

+28
-45
lines changed

3 files changed

+28
-45
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- nightly
1717
- beta
1818
- stable
19-
- 1.56.0
19+
- 1.63.0
2020
features:
2121
-
2222
- --features dummy_match_byte
@@ -35,10 +35,6 @@ jobs:
3535
toolchain: ${{ matrix.toolchain }}
3636
override: true
3737

38-
- name: Downgrade phf to a version compatible with the MSRV
39-
run: cargo update --package phf --precise 0.10.1
40-
if: matrix.toolchain == '1.40.0'
41-
4238
- name: Cargo build
4339
run: cargo build ${{ matrix.features }}
4440

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ keywords = ["css", "syntax", "parser"]
1111
license = "MPL-2.0"
1212
build = "build.rs"
1313
edition = "2018"
14-
rust-version = "1.56"
14+
rust-version = "1.63"
1515

1616
exclude = ["src/css-parsing-tests/**", "src/big-data-url.css"]
1717

src/rules_and_declarations.rs

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ pub trait AtRuleParser<'i> {
140140

141141
/// A trait to provide various parsing of qualified rules.
142142
///
143-
/// For example, there could be different implementations
144-
/// for top-level qualified rules (i.e. style rules with Selectors as prelude)
145-
/// and for qualified rules inside `@keyframes` (keyframe rules with keyframe selectors as prelude).
143+
/// For example, there could be different implementations for top-level qualified rules (i.e. style
144+
/// rules with Selectors as prelude) and for qualified rules inside `@keyframes` (keyframe rules
145+
/// with keyframe selectors as prelude).
146146
///
147-
/// Default implementations that reject all qualified rules are provided,
148-
/// so that `impl QualifiedRuleParser<(), ()> for ... {}` can be used
149-
/// for example for using `RuleListParser` to parse a rule list with only at-rules
150-
/// (such as inside `@font-feature-values`).
147+
/// Default implementations that reject all qualified rules are provided, so that
148+
/// `impl QualifiedRuleParser<(), ()> for ... {}` can be used for example for using
149+
/// `RuleListParser` to parse a rule list with only at-rules (such as inside
150+
/// `@font-feature-values`).
151151
pub trait QualifiedRuleParser<'i> {
152152
/// The intermediate representation of a qualified rule prelude.
153153
type Prelude;
@@ -223,10 +223,7 @@ where
223223
/// since `<DeclarationListParser as Iterator>::next` can return either.
224224
/// It could be a custom enum.
225225
pub fn new(input: &'a mut Parser<'i, 't>, parser: P) -> Self {
226-
DeclarationListParser {
227-
input: input,
228-
parser: parser,
229-
}
226+
DeclarationListParser { input, parser }
230227
}
231228
}
232229

@@ -249,12 +246,10 @@ where
249246
let name = name.clone();
250247
let result = {
251248
let parser = &mut self.parser;
252-
// FIXME: https://github.com/servo/rust-cssparser/issues/254
253-
let callback = |input: &mut Parser<'i, '_>| {
249+
parse_until_after(self.input, Delimiter::Semicolon, |input| {
254250
input.expect_colon()?;
255251
parser.parse_value(name, input)
256-
};
257-
parse_until_after(self.input, Delimiter::Semicolon, callback)
252+
})
258253
};
259254
return Some(result.map_err(|e| (e, self.input.slice_from(start.position()))));
260255
}
@@ -304,8 +299,8 @@ where
304299
/// It could be a custom enum.
305300
pub fn new_for_stylesheet(input: &'a mut Parser<'i, 't>, parser: P) -> Self {
306301
RuleListParser {
307-
input: input,
308-
parser: parser,
302+
input,
303+
parser,
309304
is_stylesheet: true,
310305
any_rule_so_far: false,
311306
}
@@ -319,8 +314,8 @@ where
319314
/// (This is to deal with legacy workarounds for `<style>` HTML element parsing.)
320315
pub fn new_for_nested_rule(input: &'a mut Parser<'i, 't>, parser: P) -> Self {
321316
RuleListParser {
322-
input: input,
323-
parser: parser,
317+
input,
318+
parser,
324319
is_stylesheet: false,
325320
any_rule_so_far: false,
326321
}
@@ -439,34 +434,28 @@ where
439434
P: AtRuleParser<'i, Error = E>,
440435
{
441436
let delimiters = Delimiter::Semicolon | Delimiter::CurlyBracketBlock;
442-
// FIXME: https://github.com/servo/rust-cssparser/issues/254
443-
let callback = |input: &mut Parser<'i, '_>| parser.parse_prelude(name, input);
444-
let result = parse_until_before(input, delimiters, callback);
437+
let result = parse_until_before(input, delimiters, |input| parser.parse_prelude(name, input));
445438
match result {
446439
Ok(prelude) => {
447440
let result = match input.next() {
448-
Ok(&Token::Semicolon) | Err(_) => {
449-
parser.rule_without_block(prelude, start)
450-
.map_err(|()| input.new_unexpected_token_error(Token::Semicolon))
451-
},
441+
Ok(&Token::Semicolon) | Err(_) => parser
442+
.rule_without_block(prelude, start)
443+
.map_err(|()| input.new_unexpected_token_error(Token::Semicolon)),
452444
Ok(&Token::CurlyBracketBlock) => {
453-
// FIXME: https://github.com/servo/rust-cssparser/issues/254
454-
let callback =
455-
|input: &mut Parser<'i, '_>| parser.parse_block(prelude, start, input);
456-
parse_nested_block(input, callback)
457-
},
445+
parse_nested_block(input, |input| parser.parse_block(prelude, start, input))
446+
}
458447
Ok(_) => unreachable!(),
459448
};
460449
result.map_err(|e| (e, input.slice_from(start.position())))
461-
},
450+
}
462451
Err(error) => {
463452
let end_position = input.position();
464453
match input.next() {
465454
Ok(&Token::CurlyBracketBlock) | Ok(&Token::Semicolon) | Err(_) => {}
466455
_ => unreachable!(),
467456
};
468457
Err((error, input.slice(start.position()..end_position)))
469-
},
458+
}
470459
}
471460
}
472461

@@ -478,16 +467,14 @@ where
478467
P: QualifiedRuleParser<'i, Error = E>,
479468
{
480469
let start = input.state();
481-
// FIXME: https://github.com/servo/rust-cssparser/issues/254
482-
let callback = |input: &mut Parser<'i, '_>| parser.parse_prelude(input);
483-
let prelude = parse_until_before(input, Delimiter::CurlyBracketBlock, callback);
470+
let prelude = parse_until_before(input, Delimiter::CurlyBracketBlock, |input| {
471+
parser.parse_prelude(input)
472+
});
484473
match *input.next()? {
485474
Token::CurlyBracketBlock => {
486475
// Do this here so that we consume the `{` even if the prelude is `Err`.
487476
let prelude = prelude?;
488-
// FIXME: https://github.com/servo/rust-cssparser/issues/254
489-
let callback = |input: &mut Parser<'i, '_>| parser.parse_block(prelude, &start, input);
490-
parse_nested_block(input, callback)
477+
parse_nested_block(input, |input| parser.parse_block(prelude, &start, input))
491478
}
492479
_ => unreachable!(),
493480
}

0 commit comments

Comments
 (0)