Fixed unsound errors (#1143)

This commit is contained in:
Nathan West 2020-08-20 13:51:17 -04:00 committed by GitHub
parent 51a2213fcf
commit af0dd5ef32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 14 deletions

4
Cargo.lock generated
View file

@ -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",

View file

@ -8,4 +8,4 @@ edition = "2018"
tera = "1"
toml = "0.5"
image = "0.23"
syntect = "4.1"
syntect = "4.4"

View file

@ -17,21 +17,18 @@ pub enum ErrorKind {
pub struct Error {
/// Kind of error
pub kind: ErrorKind,
pub source: Option<Box<dyn StdError>>,
pub source: Option<Box<dyn StdError + Send + Sync>>,
}
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<Box<dyn StdError>>) -> Self {
pub fn chain(value: impl ToString, source: impl Into<Box<dyn StdError + Send + Sync>>) -> Self {
Self { kind: ErrorKind::Msg(value.to_string()), source: Some(source.into()) }
}