committed by
Sean McArthur
parent
0bf30ccc68
commit
4cf22dfa21
@@ -38,6 +38,9 @@ tokio-threadpool = { version = "0.1.3", optional = true }
|
||||
tokio-timer = { version = "0.2", optional = true }
|
||||
want = "0.0.6"
|
||||
|
||||
[build-dependencies]
|
||||
rustc_version = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
futures-timer = "0.1"
|
||||
num_cpus = "1.0"
|
||||
|
||||
9
build.rs
Normal file
9
build.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
extern crate rustc_version;
|
||||
|
||||
use rustc_version::{version, Version};
|
||||
|
||||
fn main() {
|
||||
if version().unwrap() >= Version::parse("1.30.0").unwrap() {
|
||||
println!("cargo:rustc-cfg=error_source");
|
||||
}
|
||||
}
|
||||
10
src/error.rs
10
src/error.rs
@@ -323,6 +323,7 @@ impl StdError for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(error_source))]
|
||||
fn cause(&self) -> Option<&StdError> {
|
||||
self
|
||||
.inner
|
||||
@@ -330,6 +331,15 @@ impl StdError for Error {
|
||||
.as_ref()
|
||||
.map(|cause| &**cause as &StdError)
|
||||
}
|
||||
|
||||
#[cfg(error_source)]
|
||||
fn source(&self) -> Option<&(StdError + 'static)> {
|
||||
self
|
||||
.inner
|
||||
.cause
|
||||
.as_ref()
|
||||
.map(|cause| &**cause as &(StdError + 'static))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
|
||||
Reference in New Issue
Block a user