diff --git a/src/desugar/call.rs b/src/desugar/call.rs index 52cd41f..339c956 100644 --- a/src/desugar/call.rs +++ b/src/desugar/call.rs @@ -1,5 +1,4 @@ use crate::ast::{Call, Expr, Ident, Lit, Separated, Space, TableLit, TableLitElem}; -use crate::span::HasSpan; // TODO Add span for just the parentheses to ast, or limit span to parentheses @@ -81,14 +80,13 @@ impl Call { return (new, true); } - let arg_span = s1.span().at_start(); - let arg = Expr::Lit(Lit::Nil(arg_span)); + let arg = Expr::Lit(Lit::Nil(span)); let new = Expr::Call(Self::Arg { expr: Box::new(expr), s0, s1, arg: Box::new(arg), - s2: Space::empty(arg_span.at_end()), + s2: Space::empty(span), span, }); (new, true) @@ -112,13 +110,12 @@ impl Call { } let arg = Expr::TableConstr(constr); - let arg_span = arg.span(); let new = Expr::Call(Self::Arg { expr: Box::new(expr), s0, - s1: Space::empty(arg_span.at_start()), + s1: Space::empty(span), arg: Box::new(arg), - s2: Space::empty(arg_span.at_end()), + s2: Space::empty(span), span, }); (new, true) diff --git a/src/desugar/program.rs b/src/desugar/program.rs index 6598fed..a529b07 100644 --- a/src/desugar/program.rs +++ b/src/desugar/program.rs @@ -1,5 +1,4 @@ use crate::ast::{Expr, Lit, Program, Space, TableLit}; -use crate::span::HasSpan; impl Program { pub fn desugar(self) -> (Self, bool) { @@ -25,23 +24,22 @@ impl Program { s2, span, }; - (new, true) - } else { - let elems_span = elems.span(); - let table = TableLit { - s0: s1, - elems, - s1: Space::empty(elems_span.at_end()), - span: elems_span, - }; - let new = Self::Expr { - s0, - expr: Expr::Lit(Lit::Table(table)), - s1: s2, - span, - }; - (new, true) + return (new, true); } + + let table = TableLit { + s0: s1, + elems, + s1: Space::empty(span), + span, + }; + let new = Self::Expr { + s0, + expr: Expr::Lit(Lit::Table(table)), + s1: s2, + span, + }; + (new, true) } } } diff --git a/src/span.rs b/src/span.rs index 42cf32c..296f992 100644 --- a/src/span.rs +++ b/src/span.rs @@ -24,14 +24,6 @@ impl Span { let end = self.end.max(other.end); Self::new(start, end) } - - pub fn at_start(self) -> Self { - Self::new(self.start, self.start) - } - - pub fn at_end(self) -> Self { - Self::new(self.end, self.end) - } } impl fmt::Debug for Span {