diff options
author | Greg Brown <gmb60@cam.ac.uk> | 2021-01-08 18:00:11 +0000 |
---|---|---|
committer | Greg Brown <gmb60@cam.ac.uk> | 2021-01-08 18:00:11 +0000 |
commit | e1452227b8bd9ad3805480f8a5a66a75fb8370dd (patch) | |
tree | b02c9dfdc157d753e3f1c8a09bbd2ffb0bbfcc36 /src/chomp/error.rs | |
parent | fe2eac31d9dbec772796c3ea75be32e9cd01b810 (diff) |
Do more restructuring.
Diffstat (limited to 'src/chomp/error.rs')
-rw-r--r-- | src/chomp/error.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/chomp/error.rs b/src/chomp/error.rs index d0a3cc8..ffcbdd0 100644 --- a/src/chomp/error.rs +++ b/src/chomp/error.rs @@ -13,7 +13,7 @@ use super::{ }; /// A type error when using a fix point variable. -#[derive(Debug)] +#[derive(Debug, Eq, PartialEq)] pub enum VariableError { /// Usage of a free variable. FreeVariable(Variable), @@ -34,7 +34,7 @@ impl Display for VariableError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::FreeVariable(var) => { - let start = var.name().span().start(); + let start = var.name().span().unwrap_or_else(Span::call_site).start(); write!( f, "{}:{}: unbound variable '{}'", @@ -44,7 +44,7 @@ impl Display for VariableError { ) } Self::GuardedVariable(var) => { - let start = var.name().span().start(); + let start = var.name().span().unwrap_or_else(Span::call_site).start(); write!( f, "{}:{}: variable '{}' is guarded", @@ -60,7 +60,7 @@ impl Display for VariableError { impl Error for VariableError {} /// A type error when concatenating two terms. -#[derive(Debug)] +#[derive(Debug, Eq, PartialEq)] pub enum CatError { /// The first term was unexpectedly nullable. FirstNullable(Cat), @@ -159,7 +159,7 @@ impl Display for CatError { impl Error for CatError {} /// A type error when alternating two terms. -#[derive(Debug)] +#[derive(Debug, Eq, PartialEq)] pub enum AltError { /// Both terms are nullable. BothNullable(Alt), @@ -271,7 +271,7 @@ impl Display for AltError { impl Error for AltError {} -#[derive(Debug)] +#[derive(Debug, Eq, PartialEq)] pub struct FixError(pub Fix, pub Type, pub Box<TypeError>); impl From<FixError> for syn::Error { @@ -302,7 +302,7 @@ impl Display for FixError { impl Error for FixError {} -#[derive(Debug)] +#[derive(Debug, Eq, PartialEq)] pub enum TypeError { Cat(CatError), Alt(AltError), @@ -352,7 +352,7 @@ impl Display for TypeError { impl Error for TypeError {} -#[derive(Debug)] +#[derive(Debug, Eq, PartialEq)] pub enum SubstituteError { FreeParameter(Parameter), WrongArgCount { call: Call, expected: usize }, @@ -362,7 +362,7 @@ impl Display for SubstituteError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::FreeParameter(param) => { - let start = param.name().span().start(); + let start = param.name().span().unwrap_or_else(Span::call_site).start(); write!( f, "{}:{}: undeclared variable `{}'", |