Skip to content

Commit 7fcc18d

Browse files
committed
integrate CodegenError to compiler-core::Error
1 parent 2b7bf79 commit 7fcc18d

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎core/src/error.rs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::fmt::Display;
2+
13
use crate::Location;
24

35
#[derive(Debug, PartialEq, Eq)]
@@ -15,6 +17,24 @@ impl<T> std::ops::Deref for Error<T> {
1517
}
1618
}
1719

20+
impl<T> std::error::Error for Error<T>
21+
where
22+
T: std::fmt::Display + std::fmt::Debug,
23+
{
24+
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
25+
None
26+
}
27+
}
28+
29+
impl<T> Display for Error<T>
30+
where
31+
T: std::fmt::Display,
32+
{
33+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
34+
self.location.fmt_with(f, &self.error)
35+
}
36+
}
37+
1838
impl<T> Error<T> {
1939
pub fn error(self) -> T {
2040
self.error

‎parser/src/error.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl ParseError {
193193

194194
impl fmt::Display for ParseError {
195195
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
196-
self.location.fmt_with(f, &self.error)
196+
self.0.fmt(f)
197197
}
198198
}
199199

0 commit comments

Comments
 (0)