This commit is contained in:
ConnorSkees 2020-04-26 01:52:43 -04:00
parent 48bffb69e0
commit 690c8a1f89
5 changed files with 11 additions and 16 deletions

View File

@ -261,7 +261,7 @@ impl StyleSheet {
/// ``` /// ```
#[inline] #[inline]
#[cfg(not(feature = "wasm"))] #[cfg(not(feature = "wasm"))]
pub fn from_path<P: AsRef<Path> + Into<String> + Clone>(p: P) -> SassResult<String> { pub fn from_path<P: AsRef<Path> + Into<String> + Clone>(p: &P) -> SassResult<String> {
let mut map = CodeMap::new(); let mut map = CodeMap::new();
let file = map.add_file(p.clone().into(), String::from_utf8(fs::read(p.clone())?)?); let file = map.add_file(p.clone().into(), String::from_utf8(fs::read(p.clone())?)?);
Css::from_stylesheet(StyleSheet( Css::from_stylesheet(StyleSheet(
@ -436,10 +436,7 @@ impl<'a> StyleSheetParser<'a> {
c if c.is_control() => { c if c.is_control() => {
return Err(("expected selector.", self.lexer.next().unwrap().pos()).into()); return Err(("expected selector.", self.lexer.next().unwrap().pos()).into());
} }
_ => match dbg!(self.lexer.next()) { _ => todo!("unexpected toplevel token: {:?}", kind),
Some(..) => todo!("unexpected toplevel token"),
_ => unsafe { std::hint::unreachable_unchecked() },
}
}; };
} }
Ok((rules, GLOBAL_SCOPE.with(|s| s.borrow().clone()))) Ok((rules, GLOBAL_SCOPE.with(|s| s.borrow().clone())))

View File

@ -66,7 +66,7 @@ fn main() {
for name in inputs { for name in inputs {
stdout stdout
.write_all( .write_all(
StyleSheet::from_path(name) StyleSheet::from_path(&name)
.unwrap_or_else(|e| { .unwrap_or_else(|e| {
eprintln!("{}", e); eprintln!("{}", e);
std::process::exit(1) std::process::exit(1)

View File

@ -48,9 +48,10 @@ fn attribute_name<I: Iterator<Item = Token>>(
toks.next(); toks.next();
if toks.peek().ok_or(("expected \"|\".", pos))?.kind != '|' { if toks.peek().ok_or(("expected \"|\".", pos))?.kind != '|' {
return Err(("expected \"|\".", pos).into()); return Err(("expected \"|\".", pos).into());
} else {
toks.next();
} }
toks.next();
let ident = eat_ident(toks, scope, super_selector)?.node; let ident = eat_ident(toks, scope, super_selector)?.node;
return Ok(QualifiedName { return Ok(QualifiedName {
ident, ident,
@ -161,10 +162,10 @@ impl Attribute {
if toks.peek().ok_or(("expected \"]\".", pos))?.kind != ']' { if toks.peek().ok_or(("expected \"]\".", pos))?.kind != ']' {
return Err(("expected \"]\".", pos).into()); return Err(("expected \"]\".", pos).into());
} else {
toks.next();
} }
toks.next();
Ok(SelectorKind::Attribute(Attribute { Ok(SelectorKind::Attribute(Attribute {
op, op,
attr, attr,

View File

@ -829,10 +829,7 @@ impl Value {
} }
':' | '?' | ')' => Err(("expected \";\".", span).into()), ':' | '?' | ')' => Err(("expected \";\".", span).into()),
v if v.is_control() => Err(("Expected expression.", span).into()), v if v.is_control() => Err(("Expected expression.", span).into()),
v => { v => todo!("unexpected token in value parsing: {:?}", v),
dbg!(v);
panic!("Unexpected token in value parsing")
}
} }
} }
} }

View File

@ -26,12 +26,12 @@ macro_rules! tempfile {
.suffix($dir) .suffix($dir)
.tempdir_in("") .tempdir_in("")
.unwrap(); .unwrap();
let mut f = dbg!(Builder::new() let mut f = Builder::new()
.rand_bytes(0) .rand_bytes(0)
.prefix("") .prefix("")
.suffix($name) .suffix($name)
.tempfile_in($dir) .tempfile_in($dir)
.unwrap()); .unwrap();
write!(f, "{}", $content).unwrap(); write!(f, "{}", $content).unwrap();
}; };
} }