summaryrefslogtreecommitdiffstats
path: root/vendor/anyhow/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/anyhow/build.rs')
-rw-r--r--vendor/anyhow/build.rs32
1 files changed, 23 insertions, 9 deletions
diff --git a/vendor/anyhow/build.rs b/vendor/anyhow/build.rs
index c470ba11b..38006832e 100644
--- a/vendor/anyhow/build.rs
+++ b/vendor/anyhow/build.rs
@@ -15,15 +15,17 @@ compile_error! {
// type. If the current toolchain is able to compile it, we go ahead and use
// backtrace in anyhow.
const PROBE: &str = r#"
- #![feature(backtrace)]
- #![allow(dead_code)]
+ #![feature(error_generic_member_access, provide_any)]
+ use std::any::{Demand, Provider};
use std::backtrace::{Backtrace, BacktraceStatus};
use std::error::Error;
use std::fmt::{self, Display};
#[derive(Debug)]
- struct E;
+ struct E {
+ backtrace: Backtrace,
+ }
impl Display for E {
fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
@@ -32,14 +34,26 @@ const PROBE: &str = r#"
}
impl Error for E {
- fn backtrace(&self) -> Option<&Backtrace> {
- let backtrace = Backtrace::capture();
- match backtrace.status() {
- BacktraceStatus::Captured | BacktraceStatus::Disabled | _ => {}
- }
- unimplemented!()
+ fn provide<'a>(&'a self, demand: &mut Demand<'a>) {
+ demand.provide_ref(&self.backtrace);
}
}
+
+ struct P;
+
+ impl Provider for P {
+ fn provide<'a>(&'a self, _demand: &mut Demand<'a>) {}
+ }
+
+ const _: fn() = || {
+ let backtrace: Backtrace = Backtrace::capture();
+ let status: BacktraceStatus = backtrace.status();
+ match status {
+ BacktraceStatus::Captured | BacktraceStatus::Disabled | _ => {}
+ }
+ };
+
+ const _: fn(&dyn Error) -> Option<&Backtrace> = |err| err.request_ref::<Backtrace>();
"#;
fn main() {