diff options
author | Vincent Ambo <mail@tazj.in> | 2021-02-27T09·27+0200 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2021-02-27T13·05+0000 |
commit | 75750ba6835ae8ac3a97c24ca7ff5ebc1500f36d (patch) | |
tree | 35138b7ae42bcb6668b982224f6d5f3febbeafa6 /users/tazjin/rlox/src/treewalk/resolver.rs | |
parent | ebc987f4aaf653c227d21bec5998c62e87da7f7b (diff) |
style(tazjin/rlox): Set max_width=80 r/2235
Change-Id: Ib64831c0b97c94fdfbdbae64f4dfccc86879ef73 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2554 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'users/tazjin/rlox/src/treewalk/resolver.rs')
-rw-r--r-- | users/tazjin/rlox/src/treewalk/resolver.rs | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/users/tazjin/rlox/src/treewalk/resolver.rs b/users/tazjin/rlox/src/treewalk/resolver.rs index 3d12973aa089..8231ce5a9e58 100644 --- a/users/tazjin/rlox/src/treewalk/resolver.rs +++ b/users/tazjin/rlox/src/treewalk/resolver.rs @@ -56,14 +56,13 @@ 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(), + ), + }), }, } } @@ -80,7 +79,10 @@ 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); @@ -121,13 +123,17 @@ 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(), ), }); } @@ -137,7 +143,10 @@ 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(()) @@ -153,7 +162,10 @@ 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() { @@ -186,7 +198,10 @@ 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. |