From fdca0ca4f2eb8546bb500dfc6ce84d39c253d3e0 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Wed, 17 Jun 2020 02:28:35 -0400 Subject: [PATCH] improve span information for at-rules --- src/parse/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/parse/mod.rs b/src/parse/mod.rs index b0f395a..6dc41f9 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -107,10 +107,12 @@ impl<'a> Parser<'a> { if self.in_function && !stmts.is_empty() { return Ok(stmts); } + self.span_before = *pos; match kind { '@' => { self.toks.next(); let kind_string = self.parse_identifier()?; + self.span_before = kind_string.span; match AtRuleKind::try_from(&kind_string)? { AtRuleKind::Import => stmts.append(&mut self.import()?), AtRuleKind::Mixin => self.parse_mixin()?, @@ -228,7 +230,7 @@ impl<'a> Parser<'a> { } } '\u{0}'..='\u{8}' | '\u{b}'..='\u{1f}' => { - return Err(("expected selector.", self.toks.next().unwrap().pos).into()) + return Err(("expected selector.", *pos).into()) } '}' => { self.toks.next(); @@ -287,6 +289,8 @@ impl<'a> Parser<'a> { return Err(("expected \"{\".", self.span_before).into()); }; + self.span_before = span; + let mut found_curly = false; while let Some(tok) = self.toks.next() {