@@ -23,23 +23,16 @@ pub fn parse_important<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(), BasicPa
23
23
/// The return value for `AtRuleParser::parse_prelude`.
24
24
/// Indicates whether the at-rule is expected to have a `{ /* ... */ }` block
25
25
/// or end with a `;` semicolon.
26
- pub enum AtRuleType < P , R > {
26
+ pub enum AtRuleType < P > {
27
27
/// The at-rule is expected to end with a `;` semicolon. Example: `@import`.
28
- ///
29
- /// The value is the finished representation of an at-rule
30
- /// as returned by `RuleListParser::next` or `DeclarationListParser::next`.
31
- WithoutBlock ( R ) ,
28
+ WithoutBlock ( P ) ,
32
29
33
30
/// The at-rule is expected to have a a `{ /* ... */ }` block. Example: `@media`
34
- ///
35
- /// The value is the representation of the "prelude" part of the rule.
36
31
WithBlock ( P ) ,
37
32
38
33
/// The at-rule may either have a block or end with a semicolon.
39
34
///
40
35
/// This is mostly for testing. As of this writing no real CSS at-rule behaves like this.
41
- ///
42
- /// The value is the representation of the "prelude" part of the rule.
43
36
OptionalBlock ( P ) ,
44
37
}
45
38
@@ -112,7 +105,7 @@ pub trait AtRuleParser<'i> {
112
105
/// that ends wherever the prelude should end.
113
106
/// (Before the next semicolon, the next `{`, or the end of the current block.)
114
107
fn parse_prelude < ' t > ( & mut self , name : CowRcStr < ' i > , input : & mut Parser < ' i , ' t > )
115
- -> Result < AtRuleType < Self :: Prelude , Self :: AtRule > , ParseError < ' i , Self :: Error > > {
108
+ -> Result < AtRuleType < Self :: Prelude > , ParseError < ' i , Self :: Error > > {
116
109
let _ = name;
117
110
let _ = input;
118
111
Err ( ParseError :: Basic ( BasicParseError :: AtRuleInvalid ( name) ) )
@@ -133,14 +126,16 @@ pub trait AtRuleParser<'i> {
133
126
Err ( ParseError :: Basic ( BasicParseError :: AtRuleBodyInvalid ) )
134
127
}
135
128
136
- /// An `OptionalBlock` prelude was followed by `;`.
137
- ///
138
129
/// Convert the prelude into the finished representation of the at-rule
139
130
/// as returned by `RuleListParser::next` or `DeclarationListParser::next`.
131
+ ///
132
+ /// This is only called when `parse_prelude` returned `WithoutBlock` or `OptionalBlock`,
133
+ /// and there is no block found following the prelude.
140
134
fn rule_without_block ( & mut self , prelude : Self :: Prelude ) -> Self :: AtRule {
141
135
let _ = prelude;
142
136
panic ! ( "The `AtRuleParser::rule_without_block` method must be overriden \
143
- if `AtRuleParser::parse_prelude` ever returns `AtRuleType::OptionalBlock`.")
137
+ if `AtRuleParser::parse_prelude` ever returns `AtRuleType::WithoutBlock` \
138
+ or `AtRuleType::OptionalBlock`.")
144
139
}
145
140
}
146
141
@@ -440,9 +435,9 @@ fn parse_at_rule<'i: 't, 't, P, E>(start: &ParserState, name: CowRcStr<'i>,
440
435
parser. parse_prelude ( name, input)
441
436
} ) ;
442
437
match result {
443
- Ok ( AtRuleType :: WithoutBlock ( rule ) ) => {
438
+ Ok ( AtRuleType :: WithoutBlock ( prelude ) ) => {
444
439
match input. next ( ) {
445
- Ok ( & Token :: Semicolon ) | Err ( _) => Ok ( rule ) ,
440
+ Ok ( & Token :: Semicolon ) | Err ( _) => Ok ( parser . rule_without_block ( prelude ) ) ,
446
441
Ok ( & Token :: CurlyBracketBlock ) => Err ( PreciseParseError {
447
442
error : ParseError :: Basic ( BasicParseError :: UnexpectedToken ( Token :: CurlyBracketBlock ) ) ,
448
443
slice : input. slice_from ( start. position ( ) ) ,
0 commit comments