integrate CodegenError to compiler-core::Error

This commit is contained in:
Jeong YunWon 2022-08-22 18:38:55 +09:00
parent 9d67b944cf
commit 1192a11d39
4 changed files with 24 additions and 22 deletions

View file

@ -1,3 +1,5 @@
use std::fmt::Display;
use crate::Location;
#[derive(Debug, PartialEq, Eq)]
@ -15,6 +17,24 @@ impl<T> std::ops::Deref for Error<T> {
}
}
impl<T> std::error::Error for Error<T>
where
T: std::fmt::Display + std::fmt::Debug,
{
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
None
}
}
impl<T> Display for Error<T>
where
T: std::fmt::Display,
{
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.location.fmt_with(f, &self.error)
}
}
impl<T> Error<T> {
pub fn error(self) -> T {
self.error