Skip to content
Myr

Merge pull request #271 from dtolnay/provider

Before adoption: this commit came in with the history the project adopted, so no landing records it.

impl std::any::Provider for anyhow::Error

authored by David Tolnay · committed by GitHub · parents 916e22b, ee49ec0 · Browse files · 2 files+11 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+11 added−4 removed

  • other:+11 added−4 removed

2 files+11 added−4 removed

modified:src/error.rs+4 added-3 removed
520 unmodified lines
521522 Some(addr.cast::<E>().deref_mut())523 }524 }525}526527#[cfg(backtrace)]528impl std::any::Provider for Error {529 // Called by thiserror when you have `#[source] anyhow::Error`. This provide530 // implementation includes the anyhow::Error's Backtrace if any, unlike531 // deref'ing to dyn Error where the provide implementation would include532 // only the original error's Backtrace from before it got wrapped into an533 // anyhow::Error.531 #[cfg(backtrace)]532 #[doc(hidden)]533 pub fn provide<'a>(&'a self, demand: &mut Demand<'a>) {534 fn provide<'a>(&'a self, demand: &mut Demand<'a>) {535 unsafe { ErrorImpl::provide(self.inner.by_ref(), demand) }536 }537}538
454 unmodified lines
modified:build.rs+7 added-1 removed
15 unmodified lines
16// backtrace in anyhow.17const PROBE: &str = r#"18 #![feature(error_generic_member_access, provide_any)]1920 use std::any::Demand;20 use std::any::{Demand, Provider};21 use std::backtrace::{Backtrace, BacktraceStatus};22 use std::error::Error;23 use std::fmt::{self, Display};24
13 unmodified lines
38 demand.provide_ref(&self.backtrace);39 }40 }4142 struct P;4344 impl Provider for P {45 fn provide<'a>(&'a self, _demand: &mut Demand<'a>) {}46 }4748 const _: fn() = || {49 let backtrace: Backtrace = Backtrace::capture();50 let status: BacktraceStatus = backtrace.status();51 match status {
80 unmodified lines