Skip to content

Commit

Permalink
fix(protocol): fix the default From<:T Diagnostic> implementation to …
Browse files Browse the repository at this point in the history
…cover more cases.
  • Loading branch information
zkat committed Aug 5, 2021
1 parent 40133a3 commit 781a51f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,24 @@ pub trait Diagnostic: std::error::Error {

impl std::error::Error for Box<dyn Diagnostic> {}

impl<T: Diagnostic + 'static> From<T> for Box<dyn Diagnostic> {
impl<T: Diagnostic + Send + Sync + 'static> From<T> for Box<dyn Diagnostic + Send + Sync + 'static> {
fn from(diag: T) -> Self {
Box::new(diag)
}
}

impl<T: Diagnostic + Send + Sync + 'static> From<T> for Box<dyn Diagnostic + Send + 'static> {
fn from(diag: T) -> Self {
Box::<dyn Diagnostic + Send + Sync>::from(diag)
}
}

impl<T: Diagnostic + Send + Sync + 'static> From<T> for Box<dyn Diagnostic + 'static> {
fn from(diag: T) -> Self {
Box::<dyn Diagnostic + Send + Sync>::from(diag)
}
}

/**
Protocol for [Diagnostic] handlers, which are responsible for actually printing out Diagnostics.
Expand Down

0 comments on commit 781a51f

Please sign in to comment.