mirror of
https://github.com/fafhrd91/actix-web
synced 2025-01-18 05:41:50 +01:00
remove unsafe error transmute, upgrade failure to 0.1.2 #434
This commit is contained in:
parent
58230b15b9
commit
972b008a6e
@ -83,7 +83,7 @@ cookie = { version="0.11", features=["percent-encode"] }
|
||||
brotli2 = { version="^0.3.2", optional = true }
|
||||
flate2 = { version="^1.0.2", optional = true, default-features = false }
|
||||
|
||||
failure = "=0.1.1"
|
||||
failure = "^0.1.2"
|
||||
|
||||
# io
|
||||
mio = "^0.6.13"
|
||||
|
17
src/error.rs
17
src/error.rs
@ -52,7 +52,8 @@ pub struct Error {
|
||||
impl Error {
|
||||
/// Deprecated way to reference the underlying response error.
|
||||
#[deprecated(
|
||||
since = "0.6.0", note = "please use `Error::as_response_error()` instead"
|
||||
since = "0.6.0",
|
||||
note = "please use `Error::as_response_error()` instead"
|
||||
)]
|
||||
pub fn cause(&self) -> &ResponseError {
|
||||
self.cause.as_ref()
|
||||
@ -97,21 +98,9 @@ impl Error {
|
||||
//
|
||||
// So we first downcast into that compat, to then further downcast through
|
||||
// the failure's Error downcasting system into the original failure.
|
||||
//
|
||||
// This currently requires a transmute. This could be avoided if failure
|
||||
// provides a deref: https://github.com/rust-lang-nursery/failure/pull/213
|
||||
let compat: Option<&failure::Compat<failure::Error>> =
|
||||
Fail::downcast_ref(self.cause.as_fail());
|
||||
if let Some(compat) = compat {
|
||||
pub struct CompatWrappedError {
|
||||
error: failure::Error,
|
||||
}
|
||||
let compat: &CompatWrappedError =
|
||||
unsafe { &*(compat as *const _ as *const CompatWrappedError) };
|
||||
compat.error.downcast_ref()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
compat.and_then(|e| e.get_ref().downcast_ref())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user