1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
use super::type_check::TypeCheckError; use petgraph::algo::Cycle; use std::error::Error; use std::fmt::Display; #[derive(Clone, Debug, PartialEq)] pub enum AnalysisError { CircularInitialization, TypeCheck(TypeCheckError), } impl Display for AnalysisError { fn fmt(&self, formatter: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { write!(formatter, "{:?}", self) } } impl Error for AnalysisError {} impl<N> From<Cycle<N>> for AnalysisError { fn from(_: Cycle<N>) -> Self { Self::CircularInitialization } } impl From<TypeCheckError> for AnalysisError { fn from(error: TypeCheckError) -> Self { Self::TypeCheck(error) } }