Browse Source

cargo fmt

Getty Ritter 1 year ago
parent
commit
1736c71304
5 changed files with 23 additions and 20 deletions
  1. 1 4
      src/builtins.rs
  2. 0 1
      src/core.rs
  3. 11 4
      src/errors.rs
  4. 7 10
      src/interp.rs
  5. 4 1
      src/lexer.rs

+ 1 - 4
src/builtins.rs

@@ -209,10 +209,7 @@ pub fn builtins() -> Vec<BuiltinFunc> {
                         let tup = val.as_tup(&state.ast.borrow(), expr.loc)?;
                         let mut contents = Vec::new();
                         for elem in tup {
-                            for th in state
-                                .hnf(elem)?
-                                .as_tup(&state.ast.borrow(), expr.loc)?
-                            {
+                            for th in state.hnf(elem)?.as_tup(&state.ast.borrow(), expr.loc)? {
                                 contents.push(th.clone());
                             }
                         }

+ 0 - 1
src/core.rs

@@ -96,7 +96,6 @@ impl FileTable {
         }
         result
     }
-
 }
 
 impl Span {

+ 11 - 4
src/errors.rs

@@ -52,9 +52,13 @@ impl MatzoError {
         err: lalrpop_util::ParseError<usize, lexer::Token, lexer::LexerError>,
     ) -> Self {
         match err {
-            lalrpop_util::ParseError::User { error } => {
-                MatzoError::new(Loc { span: error.range, file }, "Unrecognized token".to_string())
-            }
+            lalrpop_util::ParseError::User { error } => MatzoError::new(
+                Loc {
+                    span: error.range,
+                    file,
+                },
+                "Unrecognized token".to_string(),
+            ),
             lalrpop_util::ParseError::UnrecognizedToken {
                 token: (start, tok, end),
                 expected,
@@ -91,7 +95,10 @@ impl MatzoError {
                     start: start as u32,
                     end: end as u32,
                 };
-                MatzoError::new(Loc { span, file }, format!("Extra token {}", tok.token_name()))
+                MatzoError::new(
+                    Loc { span, file },
+                    format!("Extra token {}", tok.token_name()),
+                )
             }
         }
     }

+ 7 - 10
src/interp.rs

@@ -72,10 +72,7 @@ impl Value {
         match self {
             Value::Closure(closure) => Ok(closure),
             _ => self.with_str(ast, |s| {
-                return Err(MatzoError::new(
-                    loc,
-                    format!("Expected closure, got {}", s),
-                ));
+                return Err(MatzoError::new(loc, format!("Expected closure, got {}", s)));
             }),
         }
     }
@@ -152,7 +149,7 @@ impl Thunk {
         match self {
             Thunk::Expr(_, _) => f("..."),
             Thunk::Value(v) => v.with_str(ast, f),
-            Thunk::Builtin(b) => f(&format!("#<builtin {}", b.name))
+            Thunk::Builtin(b) => f(&format!("#<builtin {}", b.name)),
         }
     }
 }
@@ -302,7 +299,10 @@ impl State {
     /// Evaluate this string as a standalone program, writing the
     /// results to the provided writer.
     pub fn run_with_writer(&self, src: &str, w: &mut impl std::io::Write) -> Result<(), Error> {
-        let file = self.file_table.borrow_mut().add_file("???".to_owned(), src.to_string());
+        let file = self
+            .file_table
+            .borrow_mut()
+            .add_file("???".to_owned(), src.to_string());
         if let Err(mtz) = self.run_file(src, file, w) {
             bail!("{}", self.print_error(mtz));
         }
@@ -723,10 +723,7 @@ impl State {
             }
             buf.push(']');
         } else {
-            scruts[0].with_str(
-                &self.ast.borrow(),
-                |s| buf.push_str(s),
-            );
+            scruts[0].with_str(&self.ast.borrow(), |s| buf.push_str(s));
         }
         Err(MatzoError::new(
             closure.func.loc,

+ 4 - 1
src/lexer.rs

@@ -9,7 +9,10 @@ pub struct Located<T> {
 
 impl<T> Located<T> {
     pub fn new(item: T, file: FileRef, span: Span) -> Located<T> {
-        Located { loc: Loc { file, span} , item }
+        Located {
+            loc: Loc { file, span },
+            item,
+        }
     }
 }