diff --git a/CHANGELOG.md b/CHANGELOG.md index 80e20698a..2a318bbf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.0.2] - 2020-08-16 + +### Fixed +- Fixed stack overflow caused by displaying errors + ## [1.0.1] - 2020-08-16 ### Fixed diff --git a/src/error.rs b/src/error.rs index a33ed51c6..e83e079c1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -38,13 +38,7 @@ macro_rules! error { $(#[$variantdoc] $variant), + } - impl Error for $name { - fn description(&self) -> &str { - match *self { - $($name::$variant => $message), + - } - } - } + impl Error for $name { } impl From<$name> for String { fn from(error: $name) -> String { @@ -62,8 +56,10 @@ macro_rules! error { } impl fmt::Display for $name { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - write!(formatter, "{}", self) + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + $($name::$variant => write!(f, $message)), + + } } } }; diff --git a/tests/tests.rs b/tests/tests.rs index a039ce6c3..5f21c0496 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -128,6 +128,10 @@ fn test() { sonar_test::test(&clang); + // SourceError _______________________________ + + assert_eq!(format!("{}", SourceError::Unknown), "an unknown error occurred"); + // Entity ____________________________________ let source = "