From ed4fdcb0ada909f1cc3d7436334e253f0ec14d55 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 4 Aug 2020 11:46:04 +0200 Subject: =?UTF-8?q?Par=20nodes=20=F0=9F=A7=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/syntax/test.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/syntax/test.rs') diff --git a/src/syntax/test.rs b/src/syntax/test.rs index db7a2de2..9faa7f23 100644 --- a/src/syntax/test.rs +++ b/src/syntax/test.rs @@ -86,22 +86,23 @@ pub trait SpanlessEq { } impl SpanlessEq for SyntaxNode { - fn spanless_eq(&self, other: &SyntaxNode) -> bool { + fn spanless_eq(&self, other: &Self) -> bool { fn downcast<'a>(func: &'a (dyn DynamicNode + 'static)) -> &'a DebugFn { func.downcast::().expect("not a debug fn") } match (self, other) { - (SyntaxNode::Dyn(a), SyntaxNode::Dyn(b)) => { + (Self::Dyn(a), Self::Dyn(b)) => { downcast(a.as_ref()).spanless_eq(downcast(b.as_ref())) } + (Self::Par(a), Self::Par(b)) => a.spanless_eq(b), (a, b) => a == b, } } } impl SpanlessEq for DebugFn { - fn spanless_eq(&self, other: &DebugFn) -> bool { + fn spanless_eq(&self, other: &Self) -> bool { self.header.spanless_eq(&other.header) && self.body.spanless_eq(&other.body) } @@ -132,7 +133,7 @@ impl SpanlessEq for FuncArg { } impl SpanlessEq for Expr { - fn spanless_eq(&self, other: &Expr) -> bool { + fn spanless_eq(&self, other: &Self) -> bool { match (self, other) { (Expr::Tuple(a), Expr::Tuple(b)) => a.spanless_eq(b), (Expr::NamedTuple(a), Expr::NamedTuple(b)) => a.spanless_eq(b), @@ -148,20 +149,20 @@ impl SpanlessEq for Expr { } impl SpanlessEq for Tuple { - fn spanless_eq(&self, other: &Tuple) -> bool { + fn spanless_eq(&self, other: &Self) -> bool { self.0.spanless_eq(&other.0) } } impl SpanlessEq for NamedTuple { - fn spanless_eq(&self, other: &NamedTuple) -> bool { + fn spanless_eq(&self, other: &Self) -> bool { self.name.v == other.name.v && self.tuple.v.spanless_eq(&other.tuple.v) } } impl SpanlessEq for Object { - fn spanless_eq(&self, other: &Object) -> bool { + fn spanless_eq(&self, other: &Self) -> bool { self.0.spanless_eq(&other.0) } } @@ -173,20 +174,20 @@ impl SpanlessEq for Pair { } impl SpanlessEq for Vec { - fn spanless_eq(&self, other: &Vec) -> bool { + fn spanless_eq(&self, other: &Self) -> bool { self.len() == other.len() && self.iter().zip(other).all(|(x, y)| x.spanless_eq(&y)) } } impl SpanlessEq for Spanned { - fn spanless_eq(&self, other: &Spanned) -> bool { + fn spanless_eq(&self, other: &Self) -> bool { self.v.spanless_eq(&other.v) } } impl SpanlessEq for Box { - fn spanless_eq(&self, other: &Box) -> bool { + fn spanless_eq(&self, other: &Self) -> bool { (&**self).spanless_eq(&**other) } } -- cgit v1.2.3