Skip to content

Commit 49ef684

Browse files
committed
error: make UnwindSafe to make PublisherConfirm UnwindSafe too
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
1 parent a490cf4 commit 49ef684

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/error.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use amq_protocol::{
66
protocol::AMQPErrorKind,
77
};
88
use async_rs::{Runtime, traits::*};
9-
use std::{error, fmt, io, sync::Arc};
9+
use std::{error, fmt, io, panic::{RefUnwindSafe, UnwindSafe}, sync::Arc};
1010

1111
/// A std Result with a lapin::Error error type
1212
pub type Result<T> = std::result::Result<T, Error>;
@@ -146,6 +146,13 @@ impl Error {
146146
}
147147
}
148148

149+
// io::Error can contain Box<dyn Error + Send + Sync>, which opts out of RefUnwindSafe
150+
// even though the data is behind Arc (immutable shared reference). Error values carry
151+
// no interior mutability of their own; a panic through code holding an Error cannot
152+
// corrupt any invariant.
153+
impl UnwindSafe for Error {}
154+
impl RefUnwindSafe for Error {}
155+
149156
impl fmt::Display for Error {
150157
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
151158
match self.kind() {

0 commit comments

Comments
 (0)