style(tazjin/rlox): Set max_width=80

Change-Id: Ib64831c0b97c94fdfbdbae64f4dfccc86879ef73
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2554
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
Vincent Ambo 2021-02-27 11:27:52 +02:00 committed by tazjin
parent ebc987f4aa
commit 75750ba683
7 changed files with 153 additions and 50 deletions

View file

@ -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.