use Spanned::map_node rather than destructuring

This commit is contained in:
ConnorSkees 2020-04-18 13:03:54 -04:00
parent 5d2d236a82
commit a83aef04ca

View File

@ -325,7 +325,7 @@ impl<'a> StyleSheetParser<'a> {
if '*' == self.lexer.peek().unwrap().kind { if '*' == self.lexer.peek().unwrap().kind {
self.lexer.next(); self.lexer.next();
let comment = eat_comment(&mut self.lexer, &Scope::new(), &Selector::new())?; let comment = eat_comment(&mut self.lexer, &Scope::new(), &Selector::new())?;
rules.push(Spanned { node: Stmt::MultilineComment(comment.node), span: comment.span }); rules.push(comment.map_node(Stmt::MultilineComment));
} else if '/' == self.lexer.peek().unwrap().kind { } else if '/' == self.lexer.peek().unwrap().kind {
read_until_newline(&mut self.lexer); read_until_newline(&mut self.lexer);
devour_whitespace(&mut self.lexer); devour_whitespace(&mut self.lexer);
@ -404,7 +404,7 @@ impl<'a> StyleSheetParser<'a> {
rules.extend(i.eval(&mut Scope::new(), &Selector::new())?); rules.extend(i.eval(&mut Scope::new(), &Selector::new())?);
} }
AtRule::AtRoot(root_rules) => rules.extend(root_rules), AtRule::AtRoot(root_rules) => rules.extend(root_rules),
u @ AtRule::Unknown(..) => rules.push(Spanned { node: Stmt::AtRule(u), span: rule.span }), AtRule::Unknown(..) => rules.push(rule.map_node(Stmt::AtRule)),
} }
} }
} }
@ -457,7 +457,9 @@ impl<'a> StyleSheetParser<'a> {
AtRule::AtRoot(root_stmts) => stmts.extend(root_stmts), AtRule::AtRoot(root_stmts) => stmts.extend(root_stmts),
AtRule::Debug(ref message) => self.debug(expr.span, message), AtRule::Debug(ref message) => self.debug(expr.span, message),
AtRule::Warn(ref message) => self.warn(expr.span, message), AtRule::Warn(ref message) => self.warn(expr.span, message),
r => stmts.push(Spanned { AtRule::Mixin(..) | AtRule::Function(..) => todo!(),
AtRule::Charset => todo!(),
r @ AtRule::Unknown(..)=> stmts.push(Spanned {
node: Stmt::AtRule(r), node: Stmt::AtRule(r),
span, span,
}), }),