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]
#[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 file = map.add_file(p.clone().into(), String::from_utf8(fs::read(p.clone())?)?);
Css::from_stylesheet(StyleSheet(
@ -436,10 +436,7 @@ impl<'a> StyleSheetParser<'a> {
c if c.is_control() => {
return Err(("expected selector.", self.lexer.next().unwrap().pos()).into());
}
_ => match dbg!(self.lexer.next()) {
Some(..) => todo!("unexpected toplevel token"),
_ => unsafe { std::hint::unreachable_unchecked() },
}
_ => todo!("unexpected toplevel token: {:?}", kind),
};
}
Ok((rules, GLOBAL_SCOPE.with(|s| s.borrow().clone())))

View File

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

View File

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

View File

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

View File

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