about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/treewalk/resolver.rs
diff options
context:
space:
mode:
Diffstat (limited to 'users/tazjin/rlox/src/treewalk/resolver.rs')
-rw-r--r--users/tazjin/rlox/src/treewalk/resolver.rs43
1 files changed, 14 insertions, 29 deletions
diff --git a/users/tazjin/rlox/src/treewalk/resolver.rs b/users/tazjin/rlox/src/treewalk/resolver.rs
index 8231ce5a9e58..3d12973aa089 100644
--- a/users/tazjin/rlox/src/treewalk/resolver.rs
+++ b/users/tazjin/rlox/src/treewalk/resolver.rs
@@ -56,13 +56,14 @@ impl<'a> Resolver<'a> {
                 // The resolver does not clone references, so unless
                 // the interpreter is called before the resolver this
                 // case should never happen.
-                None => return Err(Error {
-                    line: 0,
-                    kind: ErrorKind::InternalError(
-                        "multiple function references before interpretation"
-                            .into(),
-                    ),
-                }),
+                None => {
+                    return Err(Error {
+                        line: 0,
+                        kind: ErrorKind::InternalError(
+                            "multiple function references before interpretation".into(),
+                        ),
+                    })
+                }
             },
         }
     }
@@ -79,10 +80,7 @@ impl<'a> Resolver<'a> {
         Ok(())
     }
 
-    fn resolve_function(
-        &mut self,
-        func: &'a mut parser::Function,
-    ) -> Result<(), Error> {
+    fn resolve_function(&mut self, func: &'a mut parser::Function) -> Result<(), Error> {
         self.declare(&func.name.lexeme);
         self.define(&func.name.lexeme);
 
@@ -123,17 +121,13 @@ impl<'a> Resolver<'a> {
         }
     }
 
-    fn resolve_variable(
-        &mut self,
-        var: &'a mut parser::Variable,
-    ) -> Result<(), Error> {
+    fn resolve_variable(&mut self, var: &'a mut parser::Variable) -> Result<(), Error> {
         if let Some(scope) = self.scopes.last_mut() {
             if let Some(false) = scope.get(var.name.lexeme.as_str()) {
                 return Err(Error {
                     line: var.name.line,
                     kind: ErrorKind::StaticError(
-                        "can't read local variable in its own initialiser"
-                            .into(),
+                        "can't read local variable in its own initialiser".into(),
                     ),
                 });
             }
@@ -143,10 +137,7 @@ impl<'a> Resolver<'a> {
         Ok(())
     }
 
-    fn resolve_assign(
-        &mut self,
-        assign: &'a mut parser::Assign,
-    ) -> Result<(), Error> {
+    fn resolve_assign(&mut self, assign: &'a mut parser::Assign) -> Result<(), Error> {
         self.resolve_expr(&mut assign.value)?;
         assign.depth = self.resolve_local(&assign.name);
         Ok(())
@@ -162,10 +153,7 @@ impl<'a> Resolver<'a> {
         None
     }
 
-    fn resolve_call(
-        &mut self,
-        call: &'a mut parser::Call,
-    ) -> Result<(), Error> {
+    fn resolve_call(&mut self, call: &'a mut parser::Call) -> Result<(), Error> {
         self.resolve_expr(&mut call.callee)?;
 
         for arg in call.args.iter_mut() {
@@ -198,10 +186,7 @@ impl<'a> Resolver<'a> {
     }
 }
 
-pub fn resolve(
-    globals: &[String],
-    block: &mut parser::Block,
-) -> Result<(), Error> {
+pub fn resolve(globals: &[String], block: &mut parser::Block) -> Result<(), Error> {
     let mut resolver: Resolver = Default::default();
 
     // Scope for static globals only starts, never ends.