From af0dd5ef32ca0cbe60c4455ba8ddeb80b80c67a3 Mon Sep 17 00:00:00 2001 From: Nathan West Date: Thu, 20 Aug 2020 13:51:17 -0400 Subject: [PATCH] Fixed unsound errors (#1143) --- Cargo.lock | 4 ++-- components/errors/Cargo.toml | 2 +- components/errors/src/lib.rs | 19 ++++++++----------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 643eb6c4..55044502 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2307,9 +2307,9 @@ dependencies = [ [[package]] name = "syntect" -version = "4.3.0" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b57a45fdcf4891bc79f635be5c559210a4cfa464891f969724944c713282eedb" +checksum = "4e3978df05b5850c839a6b352d3c35ce0478944a4be689be826b53cf75363e88" dependencies = [ "bincode", "bitflags", diff --git a/components/errors/Cargo.toml b/components/errors/Cargo.toml index 7932541b..2539432a 100644 --- a/components/errors/Cargo.toml +++ b/components/errors/Cargo.toml @@ -8,4 +8,4 @@ edition = "2018" tera = "1" toml = "0.5" image = "0.23" -syntect = "4.1" +syntect = "4.4" diff --git a/components/errors/src/lib.rs b/components/errors/src/lib.rs index 989fe565..037c48df 100644 --- a/components/errors/src/lib.rs +++ b/components/errors/src/lib.rs @@ -17,21 +17,18 @@ pub enum ErrorKind { pub struct Error { /// Kind of error pub kind: ErrorKind, - pub source: Option>, + pub source: Option>, } -unsafe impl Sync for Error {} -unsafe impl Send for Error {} impl StdError for Error { fn source(&self) -> Option<&(dyn StdError + 'static)> { - let mut source = self.source.as_ref().map(|c| &**c); - if source.is_none() { - if let ErrorKind::Tera(ref err) = self.kind { - source = err.source(); - } + match self.source { + Some(ref err) => Some(&**err), + None => match self.kind { + ErrorKind::Tera(ref err) => err.source(), + _ => None, + }, } - - source } } @@ -55,7 +52,7 @@ impl Error { } /// Creates generic error with a cause - pub fn chain(value: impl ToString, source: impl Into>) -> Self { + pub fn chain(value: impl ToString, source: impl Into>) -> Self { Self { kind: ErrorKind::Msg(value.to_string()), source: Some(source.into()) } }