From 03e7f107395602da075ba03fbd8fee24b2f0f946 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 20 Nov 2022 22:15:56 +0100 Subject: [PATCH] Satisfy warnings --- src/ast/basic.rs | 4 ++-- src/ast/call.rs | 6 +++--- src/ast/expr.rs | 22 +++++++++++----------- src/ast/field.rs | 8 ++++---- src/ast/func_def.rs | 12 ++++++------ src/ast/lit.rs | 16 ++++++++-------- src/ast/program.rs | 4 ++-- src/ast/table_constr.rs | 4 ++-- src/ast/table_destr.rs | 4 ++-- src/ast/var.rs | 8 ++++---- src/parser/suffix.rs | 14 +++++++------- src/pretty/basic.rs | 4 ++-- src/pretty/expr.rs | 22 +++++++++++----------- src/pretty/program.rs | 4 ++-- 14 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/ast/basic.rs b/src/ast/basic.rs index 1194111..33562f2 100644 --- a/src/ast/basic.rs +++ b/src/ast/basic.rs @@ -62,8 +62,8 @@ pub enum Separated { impl HasSpan for Separated { fn span(&self) -> Span { match self { - Separated::Empty(span) => *span, - Separated::NonEmpty { span, .. } => *span, + Self::Empty(span) => *span, + Self::NonEmpty { span, .. } => *span, } } } diff --git a/src/ast/call.rs b/src/ast/call.rs index 10f82e8..547e1f1 100644 --- a/src/ast/call.rs +++ b/src/ast/call.rs @@ -40,9 +40,9 @@ pub enum Call { impl HasSpan for Call { fn span(&self) -> Span { match self { - Call::Arg { span, .. } => *span, - Call::NoArg { span, .. } => *span, - Call::Constr { span, .. } => *span, + Self::Arg { span, .. } => *span, + Self::NoArg { span, .. } => *span, + Self::Constr { span, .. } => *span, } } } diff --git a/src/ast/expr.rs b/src/ast/expr.rs index 522f2f1..50a25ee 100644 --- a/src/ast/expr.rs +++ b/src/ast/expr.rs @@ -186,17 +186,17 @@ impl fmt::Debug for Expr { impl HasSpan for Expr { fn span(&self) -> Span { match self { - Expr::Lit(lit) => lit.span(), - Expr::Call(call) => call.span(), - Expr::Field(field) => field.span(), - Expr::Var(var) => var.span(), - Expr::TableConstr(constr) => constr.span(), - Expr::TableDestr(destr) => destr.span(), - Expr::FuncDef(def) => def.span(), - Expr::Paren { span, .. } => *span, - Expr::Neg { span, .. } => *span, - Expr::Not { span, .. } => *span, - Expr::BinOp { span, .. } => *span, + Self::Lit(lit) => lit.span(), + Self::Call(call) => call.span(), + Self::Field(field) => field.span(), + Self::Var(var) => var.span(), + Self::TableConstr(constr) => constr.span(), + Self::TableDestr(destr) => destr.span(), + Self::FuncDef(def) => def.span(), + Self::Paren { span, .. } => *span, + Self::Neg { span, .. } => *span, + Self::Not { span, .. } => *span, + Self::BinOp { span, .. } => *span, } } } diff --git a/src/ast/field.rs b/src/ast/field.rs index c8c10b4..1972686 100644 --- a/src/ast/field.rs +++ b/src/ast/field.rs @@ -60,10 +60,10 @@ pub enum Field { impl HasSpan for Field { fn span(&self) -> Span { match self { - Field::Access { span, .. } => *span, - Field::Assign { span, .. } => *span, - Field::AccessIdent { span, .. } => *span, - Field::AssignIdent { span, .. } => *span, + Self::Access { span, .. } => *span, + Self::Assign { span, .. } => *span, + Self::AccessIdent { span, .. } => *span, + Self::AssignIdent { span, .. } => *span, } } } diff --git a/src/ast/func_def.rs b/src/ast/func_def.rs index 3ce0b34..e1e89ad 100644 --- a/src/ast/func_def.rs +++ b/src/ast/func_def.rs @@ -90,12 +90,12 @@ pub enum FuncDef { impl HasSpan for FuncDef { fn span(&self) -> Span { match self { - FuncDef::AnonNoArg { span, .. } => *span, - FuncDef::AnonArg { span, .. } => *span, - FuncDef::AnonDestr { span, .. } => *span, - FuncDef::NamedNoArg { span, .. } => *span, - FuncDef::NamedArg { span, .. } => *span, - FuncDef::NamedDestr { span, .. } => *span, + Self::AnonNoArg { span, .. } => *span, + Self::AnonArg { span, .. } => *span, + Self::AnonDestr { span, .. } => *span, + Self::NamedNoArg { span, .. } => *span, + Self::NamedArg { span, .. } => *span, + Self::NamedDestr { span, .. } => *span, } } } diff --git a/src/ast/lit.rs b/src/ast/lit.rs index c079955..63ced41 100644 --- a/src/ast/lit.rs +++ b/src/ast/lit.rs @@ -119,8 +119,8 @@ pub enum TableLitElem { impl HasSpan for TableLitElem { fn span(&self) -> Span { match self { - TableLitElem::Positional(value) => value.span(), - TableLitElem::Named { span, .. } => *span, + Self::Positional(value) => value.span(), + Self::Named { span, .. } => *span, } } } @@ -187,12 +187,12 @@ impl fmt::Debug for Lit { impl HasSpan for Lit { fn span(&self) -> Span { match self { - Lit::Nil(span) => *span, - Lit::Bool(_, span) => *span, - Lit::Builtin(_, span) => *span, - Lit::Num(n) => n.span(), - Lit::String(s) => s.span(), - Lit::Table(t) => t.span(), + Self::Nil(span) => *span, + Self::Bool(_, span) => *span, + Self::Builtin(_, span) => *span, + Self::Num(n) => n.span(), + Self::String(s) => s.span(), + Self::Table(t) => t.span(), } } } diff --git a/src/ast/program.rs b/src/ast/program.rs index 1a219f5..2020225 100644 --- a/src/ast/program.rs +++ b/src/ast/program.rs @@ -25,8 +25,8 @@ pub enum Program { impl HasSpan for Program { fn span(&self) -> Span { match self { - Program::Expr { span, .. } => *span, - Program::Module { span, .. } => *span, + Self::Expr { span, .. } => *span, + Self::Module { span, .. } => *span, } } } diff --git a/src/ast/table_constr.rs b/src/ast/table_constr.rs index bf6b517..d347ce1 100644 --- a/src/ast/table_constr.rs +++ b/src/ast/table_constr.rs @@ -24,8 +24,8 @@ pub enum TableConstrElem { impl HasSpan for TableConstrElem { fn span(&self) -> Span { match self { - TableConstrElem::Lit(lit) => lit.span(), - TableConstrElem::Indexed { span, .. } => *span, + Self::Lit(lit) => lit.span(), + Self::Indexed { span, .. } => *span, } } } diff --git a/src/ast/table_destr.rs b/src/ast/table_destr.rs index 3d90fb3..eb88dcb 100644 --- a/src/ast/table_destr.rs +++ b/src/ast/table_destr.rs @@ -24,8 +24,8 @@ pub enum TablePatternElem { impl HasSpan for TablePatternElem { fn span(&self) -> Span { match self { - TablePatternElem::Positional(ident) => ident.span(), - TablePatternElem::Named { span, .. } => *span, + Self::Positional(ident) => ident.span(), + Self::Named { span, .. } => *span, } } } diff --git a/src/ast/var.rs b/src/ast/var.rs index bc32e7a..6ec6026 100644 --- a/src/ast/var.rs +++ b/src/ast/var.rs @@ -49,10 +49,10 @@ pub enum Var { impl HasSpan for Var { fn span(&self) -> Span { match self { - Var::Access { span, .. } => *span, - Var::Assign { span, .. } => *span, - Var::AccessIdent(ident) => ident.span(), - Var::AssignIdent { span, .. } => *span, + Self::Access { span, .. } => *span, + Self::Assign { span, .. } => *span, + Self::AccessIdent(ident) => ident.span(), + Self::AssignIdent { span, .. } => *span, } } } diff --git a/src/parser/suffix.rs b/src/parser/suffix.rs index 6c10491..cb02008 100644 --- a/src/parser/suffix.rs +++ b/src/parser/suffix.rs @@ -59,7 +59,7 @@ impl Suffix { fn into_expr(self, span: Span, expr: Expr) -> Expr { let expr = Box::new(expr); match self { - Suffix::CallArg { s0, s1, arg, s2 } => Expr::Call(Call::Arg { + Self::CallArg { s0, s1, arg, s2 } => Expr::Call(Call::Arg { expr, s0, s1, @@ -67,14 +67,14 @@ impl Suffix { s2, span, }), - Suffix::CallNoArg { s0, s1 } => Expr::Call(Call::NoArg { expr, s0, s1, span }), - Suffix::CallConstr { s0, constr } => Expr::Call(Call::Constr { + Self::CallNoArg { s0, s1 } => Expr::Call(Call::NoArg { expr, s0, s1, span }), + Self::CallConstr { s0, constr } => Expr::Call(Call::Constr { expr, s0, constr, span, }), - Suffix::FieldAccess { s0, s1, index, s2 } => Expr::Field(Field::Access { + Self::FieldAccess { s0, s1, index, s2 } => Expr::Field(Field::Access { expr, s0, s1, @@ -82,7 +82,7 @@ impl Suffix { s2, span, }), - Suffix::FieldAssign { + Self::FieldAssign { s0, s1, index, @@ -101,14 +101,14 @@ impl Suffix { value, span, }), - Suffix::FieldAccessIdent { s0, s1, ident } => Expr::Field(Field::AccessIdent { + Self::FieldAccessIdent { s0, s1, ident } => Expr::Field(Field::AccessIdent { expr, s0, s1, ident, span, }), - Suffix::FieldAssignIdent { + Self::FieldAssignIdent { s0, s1, ident, diff --git a/src/pretty/basic.rs b/src/pretty/basic.rs index 293c9a1..a7171fa 100644 --- a/src/pretty/basic.rs +++ b/src/pretty/basic.rs @@ -17,8 +17,8 @@ impl Separated { FS2: Fn(&'a D, S2) -> DocBuilder<'a, D>, { match self { - Separated::Empty(_) => allocator.nil(), - Separated::NonEmpty { + Self::Empty(_) => allocator.nil(), + Self::NonEmpty { first_elem, last_elems, trailing, diff --git a/src/pretty/expr.rs b/src/pretty/expr.rs index eeef8db..21e424f 100644 --- a/src/pretty/expr.rs +++ b/src/pretty/expr.rs @@ -5,14 +5,14 @@ use crate::ast::Expr; impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Expr { fn pretty(self, allocator: &'a D) -> DocBuilder<'a, D> { match self { - Expr::Lit(lit) => allocator.text(""), - Expr::Call(call) => allocator.text(""), - Expr::Field(field) => allocator.text(""), - Expr::Var(var) => allocator.text(""), - Expr::TableConstr(constr) => allocator.text(""), - Expr::TableDestr(destr) => allocator.text(""), - Expr::FuncDef(def) => allocator.text(""), - Expr::Paren { + Self::Lit(lit) => allocator.text(""), + Self::Call(call) => allocator.text(""), + Self::Field(field) => allocator.text(""), + Self::Var(var) => allocator.text(""), + Self::TableConstr(constr) => allocator.text(""), + Self::TableDestr(destr) => allocator.text(""), + Self::FuncDef(def) => allocator.text(""), + Self::Paren { s0, inner, s1, @@ -20,7 +20,7 @@ impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Expr { } => inner.pretty(allocator).parens(), // TODO Check whether parentheses are necessary - Expr::Neg { + Self::Neg { minus: _, s0, expr, @@ -28,14 +28,14 @@ impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Expr { } => allocator.text("-").append(expr.pretty(allocator)), // TODO Check whether parentheses are necessary - Expr::Not { + Self::Not { not: _, s0, expr, span: _, } => allocator.text("not ").append(expr.pretty(allocator)), - Expr::BinOp { + Self::BinOp { left, s0, op, diff --git a/src/pretty/program.rs b/src/pretty/program.rs index 22925af..327059d 100644 --- a/src/pretty/program.rs +++ b/src/pretty/program.rs @@ -5,13 +5,13 @@ use crate::ast::Program; impl<'a, D: DocAllocator<'a>> Pretty<'a, D> for Program { fn pretty(self, allocator: &'a D) -> DocBuilder<'a, D> { match self { - Program::Expr { + Self::Expr { s0, expr, s1, span: _, } => expr.pretty(allocator), - Program::Module { + Self::Module { s0, s1, elems,