Debian Codegraph @

src/error.rs

raw symbols SCIP
1 use craterust-analyzer cargo anyhow 1.0.103 crate/::backtracerust-analyzer cargo anyhow 1.0.103 backtrace/::Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace#;
2 use craterust-analyzer cargo anyhow 1.0.103 crate/::chainrust-analyzer cargo anyhow 1.0.103 chain/::Chainrust-analyzer cargo anyhow 1.0.103 Chain#;
3 #[cfg(error_generic_member_access)]
4 use craterust-analyzer cargo anyhow 1.0.103 crate/::nightly::{self, Request};
5 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
6 use craterust-analyzer cargo anyhow 1.0.103 crate/::ptrrust-analyzer cargo anyhow 1.0.103 ptr/::Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut#;
7 use craterust-analyzer cargo anyhow 1.0.103 crate/::ptrrust-analyzer cargo anyhow 1.0.103 ptr/::{Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#, Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#};
8 use craterust-analyzer cargo anyhow 1.0.103 crate/::{Errorrust-analyzer cargo anyhow 1.0.103 Error#, StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#};
9 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::boxedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/::Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#;
10 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/::TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#;
11 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::{selfrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#};
12 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::ManuallyDroprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/ManuallyDrop#;
13 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
14 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#, DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut#};
15 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::panicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core panic/::{RefUnwindSaferust-analyzer cargo core https://github.com/rust-lang/rust/library/core panic/unwind_safe/RefUnwindSafe#, UnwindSaferust-analyzer cargo core https://github.com/rust-lang/rust/library/core panic/unwind_safe/UnwindSafe#};
16 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/;
17 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#;
18
19 impl Errorrust-analyzer cargo anyhow 1.0.103 Error# {
20 /// Create a new error object from any error type.
21 ///
22 /// The error type must be threadsafe and `'static`, so that the `Error`
23 /// will be as well.
24 ///
25 /// If the error type does not provide a backtrace, a backtrace will be
26 /// created here to ensure that a backtrace exists.
27 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
28 #[cold]
29 #[must_use]
30 pub fn newrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]new().<E>(error: E) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]
31 where
32 E: StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
33 {
34 let backtrace = backtrace_if_absentrust-analyzer cargo anyhow 1.0.103 backtrace/backtrace_if_absent!!(&error);
35 Errorrust-analyzer cargo anyhow 1.0.103 Error#::construct_from_stdrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct_from_std().(error, backtrace)
36 }
37
38 /// Create a new error object from a printable error message.
39 ///
40 /// If the argument implements std::error::Error, prefer `Error::new`
41 /// instead which preserves the underlying error's cause chain and
42 /// backtrace. If the argument may or may not implement std::error::Error
43 /// now or in the future, use `anyhow!(err)` which handles either way
44 /// correctly.
45 ///
46 /// `Error::msg("...")` is equivalent to `anyhow!("...")` but occasionally
47 /// convenient in places where a function is preferable over a macro, such
48 /// as iterator or stream combinators:
49 ///
50 /// ```
51 /// # mod ffi {
52 /// # pub struct Input;
53 /// # pub struct Output;
54 /// # pub async fn do_some_work(_: Input) -> Result<Output, &'static str> {
55 /// # unimplemented!()
56 /// # }
57 /// # }
58 /// #
59 /// # use ffi::{Input, Output};
60 /// #
61 /// use anyhow::{Error, Result};
62 /// use futures::stream::{Stream, StreamExt, TryStreamExt};
63 ///
64 /// async fn demo<S>(stream: S) -> Result<Vec<Output>>
65 /// where
66 /// S: Stream<Item = Input>,
67 /// {
68 /// stream
69 /// .then(ffi::do_some_work) // returns Result<Output, &str>
70 /// .map_err(Error::msg)
71 /// .try_collect()
72 /// .await
73 /// }
74 /// ```
75 #[cold]
76 #[must_use]
77 pub fn msgrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]msg().<M>(message: M) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]
78 where
79 M: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
80 {
81 Errorrust-analyzer cargo anyhow 1.0.103 Error#::construct_from_adhocrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct_from_adhoc().(message, backtracerust-analyzer cargo anyhow 1.0.103 backtrace/backtrace!!())
82 }
83
84 /// Construct an error object from a type-erased standard library error.
85 ///
86 /// This is mostly useful for interop with other error libraries.
87 ///
88 /// # Example
89 ///
90 /// Here is a skeleton of a library that provides its own error abstraction.
91 /// The pair of `From` impls provide bidirectional support for `?`
92 /// conversion between `Report` and `anyhow::Error`.
93 ///
94 /// ```
95 /// use std::error::Error as StdError;
96 ///
97 /// pub struct Report {/* ... */}
98 ///
99 /// impl<E> From<E> for Report
100 /// where
101 /// E: Into<anyhow::Error>,
102 /// Result<(), E>: anyhow::Context<(), E>,
103 /// {
104 /// fn from(error: E) -> Self {
105 /// let anyhow_error: anyhow::Error = error.into();
106 /// let boxed_error: Box<dyn StdError + Send + Sync + 'static> = anyhow_error.into();
107 /// Report::from_boxed(boxed_error)
108 /// }
109 /// }
110 ///
111 /// impl From<Report> for anyhow::Error {
112 /// fn from(report: Report) -> Self {
113 /// let boxed_error: Box<dyn StdError + Send + Sync + 'static> = report.into_boxed();
114 /// anyhow::Error::from_boxed(boxed_error)
115 /// }
116 /// }
117 ///
118 /// impl Report {
119 /// fn from_boxed(boxed_error: Box<dyn StdError + Send + Sync + 'static>) -> Self {
120 /// todo!()
121 /// }
122 /// fn into_boxed(self) -> Box<dyn StdError + Send + Sync + 'static> {
123 /// todo!()
124 /// }
125 /// }
126 ///
127 /// // Example usage: can use `?` in both directions.
128 /// fn a() -> anyhow::Result<()> {
129 /// b()?;
130 /// Ok(())
131 /// }
132 /// fn b() -> Result<(), Report> {
133 /// a()?;
134 /// Ok(())
135 /// }
136 /// ```
137 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
138 #[cold]
139 #[must_use]
140 pub fn from_boxedrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]from_boxed().(boxed_error: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static>) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error] {
141 let backtrace = backtrace_if_absentrust-analyzer cargo anyhow 1.0.103 backtrace/backtrace_if_absent!!(&*boxed_error);
142 Errorrust-analyzer cargo anyhow 1.0.103 Error#::construct_from_boxedrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct_from_boxed().(boxed_error, backtrace)
143 }
144
145 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
146 #[cold]
147 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) fn construct_from_stdrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct_from_std().<E>(error: E, backtrace: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace#>) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]
148 where
149 E: StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
150 {
151 let vtable = &ErrorVTablerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable# {
152 object_droprust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop.: object_droprust-analyzer cargo anyhow 1.0.103 error/object_drop().::<E>,
153 object_refrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_ref.: object_refrust-analyzer cargo anyhow 1.0.103 error/object_ref().::<E>,
154 object_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_boxed.: object_boxedrust-analyzer cargo anyhow 1.0.103 error/object_boxed().::<E>,
155 object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_reallocate_boxed.: object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/object_reallocate_boxed().::<E>,
156 object_downcastrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_downcast.: object_downcastrust-analyzer cargo anyhow 1.0.103 error/object_downcast().::<E>,
157 object_drop_restrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop_rest.: object_drop_frontrust-analyzer cargo anyhow 1.0.103 error/object_drop_front().::<E>,
158 #[cfg(all(not(error_generic_member_access), feature = "std"))]
159 object_backtracerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_backtrace.: no_backtracerust-analyzer cargo anyhow 1.0.103 error/no_backtrace().,
160 };
161
162 // Safety: passing vtable that operates on the right type E.
163 unsafe { Errorrust-analyzer cargo anyhow 1.0.103 Error#::constructrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct().(error, vtable, backtrace) }
164 }
165
166 #[cold]
167 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) fn construct_from_adhocrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct_from_adhoc().<M>(message: M, backtrace: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace#>) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]
168 where
169 M: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
170 {
171 use craterust-analyzer cargo anyhow 1.0.103 crate/::wrapperrust-analyzer cargo anyhow 1.0.103 wrapper/::MessageErrorrust-analyzer cargo anyhow 1.0.103 wrapper/MessageError#;
172 let error: MessageErrorrust-analyzer cargo anyhow 1.0.103 wrapper/MessageError#<M> = MessageErrorrust-analyzer cargo anyhow 1.0.103 wrapper/MessageError#(message);
173 let vtable = &ErrorVTablerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable# {
174 object_droprust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop.: object_droprust-analyzer cargo anyhow 1.0.103 error/object_drop().::<MessageErrorrust-analyzer cargo anyhow 1.0.103 wrapper/MessageError#<M>>,
175 object_refrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_ref.: object_refrust-analyzer cargo anyhow 1.0.103 error/object_ref().::<MessageErrorrust-analyzer cargo anyhow 1.0.103 wrapper/MessageError#<M>>,
176 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
177 object_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_boxed.: object_boxedrust-analyzer cargo anyhow 1.0.103 error/object_boxed().::<MessageErrorrust-analyzer cargo anyhow 1.0.103 wrapper/MessageError#<M>>,
178 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
179 object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_reallocate_boxed.: object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/object_reallocate_boxed().::<MessageErrorrust-analyzer cargo anyhow 1.0.103 wrapper/MessageError#<M>>,
180 object_downcastrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_downcast.: object_downcastrust-analyzer cargo anyhow 1.0.103 error/object_downcast().::<M>,
181 object_drop_restrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop_rest.: object_drop_frontrust-analyzer cargo anyhow 1.0.103 error/object_drop_front().::<M>,
182 #[cfg(all(not(error_generic_member_access), feature = "std"))]
183 object_backtracerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_backtrace.: no_backtracerust-analyzer cargo anyhow 1.0.103 error/no_backtrace().,
184 };
185
186 // Safety: MessageError is repr(transparent) so it is okay for the
187 // vtable to allow casting the MessageError<M> to M.
188 unsafe { Errorrust-analyzer cargo anyhow 1.0.103 Error#::constructrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct().(error, vtable, backtrace) }
189 }
190
191 #[cold]
192 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) fn construct_from_displayrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct_from_display().<M>(message: M, backtrace: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace#>) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]
193 where
194 M: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
195 {
196 use craterust-analyzer cargo anyhow 1.0.103 crate/::wrapperrust-analyzer cargo anyhow 1.0.103 wrapper/::DisplayErrorrust-analyzer cargo anyhow 1.0.103 wrapper/DisplayError#;
197 let error: DisplayErrorrust-analyzer cargo anyhow 1.0.103 wrapper/DisplayError#<M> = DisplayErrorrust-analyzer cargo anyhow 1.0.103 wrapper/DisplayError#(message);
198 let vtable = &ErrorVTablerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable# {
199 object_droprust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop.: object_droprust-analyzer cargo anyhow 1.0.103 error/object_drop().::<DisplayErrorrust-analyzer cargo anyhow 1.0.103 wrapper/DisplayError#<M>>,
200 object_refrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_ref.: object_refrust-analyzer cargo anyhow 1.0.103 error/object_ref().::<DisplayErrorrust-analyzer cargo anyhow 1.0.103 wrapper/DisplayError#<M>>,
201 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
202 object_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_boxed.: object_boxedrust-analyzer cargo anyhow 1.0.103 error/object_boxed().::<DisplayErrorrust-analyzer cargo anyhow 1.0.103 wrapper/DisplayError#<M>>,
203 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
204 object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_reallocate_boxed.: object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/object_reallocate_boxed().::<DisplayErrorrust-analyzer cargo anyhow 1.0.103 wrapper/DisplayError#<M>>,
205 object_downcastrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_downcast.: object_downcastrust-analyzer cargo anyhow 1.0.103 error/object_downcast().::<M>,
206 object_drop_restrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop_rest.: object_drop_frontrust-analyzer cargo anyhow 1.0.103 error/object_drop_front().::<M>,
207 #[cfg(all(not(error_generic_member_access), feature = "std"))]
208 object_backtracerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_backtrace.: no_backtracerust-analyzer cargo anyhow 1.0.103 error/no_backtrace().,
209 };
210
211 // Safety: DisplayError is repr(transparent) so it is okay for the
212 // vtable to allow casting the DisplayError<M> to M.
213 unsafe { Errorrust-analyzer cargo anyhow 1.0.103 Error#::constructrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct().(error, vtable, backtrace) }
214 }
215
216 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
217 #[cold]
218 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) fn construct_from_contextrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct_from_context().<C, E>(
219 context: C,
220 error: E,
221 backtrace: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace#>,
222 ) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]
223 where
224 C: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
225 E: StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
226 {
227 let error: ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, E> = ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError# { contextrust-analyzer cargo anyhow 1.0.103 error/ContextError#context., errorrust-analyzer cargo anyhow 1.0.103 error/ContextError#error. };
228
229 let vtable = &ErrorVTablerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable# {
230 object_droprust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop.: object_droprust-analyzer cargo anyhow 1.0.103 error/object_drop().::<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, E>>,
231 object_refrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_ref.: object_refrust-analyzer cargo anyhow 1.0.103 error/object_ref().::<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, E>>,
232 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
233 object_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_boxed.: object_boxedrust-analyzer cargo anyhow 1.0.103 error/object_boxed().::<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, E>>,
234 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
235 object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_reallocate_boxed.: object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/object_reallocate_boxed().::<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, E>>,
236 object_downcastrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_downcast.: context_downcastrust-analyzer cargo anyhow 1.0.103 error/context_downcast().::<C, E>,
237 object_drop_restrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop_rest.: context_drop_restrust-analyzer cargo anyhow 1.0.103 error/context_drop_rest().::<C, E>,
238 #[cfg(all(not(error_generic_member_access), feature = "std"))]
239 object_backtracerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_backtrace.: no_backtracerust-analyzer cargo anyhow 1.0.103 error/no_backtrace().,
240 };
241
242 // Safety: passing vtable that operates on the right type.
243 unsafe { Errorrust-analyzer cargo anyhow 1.0.103 Error#::constructrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct().(error, vtable, backtrace) }
244 }
245
246 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
247 #[cold]
248 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) fn construct_from_boxedrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct_from_boxed().(
249 error: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>,
250 backtrace: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace#>,
251 ) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error] {
252 use craterust-analyzer cargo anyhow 1.0.103 crate/::wrapperrust-analyzer cargo anyhow 1.0.103 wrapper/::BoxedErrorrust-analyzer cargo anyhow 1.0.103 wrapper/BoxedError#;
253 let error = BoxedErrorrust-analyzer cargo anyhow 1.0.103 wrapper/BoxedError#(error);
254 let vtable = &ErrorVTablerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable# {
255 object_droprust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop.: object_droprust-analyzer cargo anyhow 1.0.103 error/object_drop().::<BoxedErrorrust-analyzer cargo anyhow 1.0.103 wrapper/BoxedError#>,
256 object_refrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_ref.: object_refrust-analyzer cargo anyhow 1.0.103 error/object_ref().::<BoxedErrorrust-analyzer cargo anyhow 1.0.103 wrapper/BoxedError#>,
257 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
258 object_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_boxed.: object_boxedrust-analyzer cargo anyhow 1.0.103 error/object_boxed().::<BoxedErrorrust-analyzer cargo anyhow 1.0.103 wrapper/BoxedError#>,
259 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
260 object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_reallocate_boxed.: object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/object_reallocate_boxed().::<BoxedErrorrust-analyzer cargo anyhow 1.0.103 wrapper/BoxedError#>,
261 object_downcastrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_downcast.: object_downcastrust-analyzer cargo anyhow 1.0.103 error/object_downcast().::<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>>,
262 object_drop_restrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop_rest.: object_drop_frontrust-analyzer cargo anyhow 1.0.103 error/object_drop_front().::<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>>,
263 #[cfg(all(not(error_generic_member_access), feature = "std"))]
264 object_backtracerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_backtrace.: no_backtracerust-analyzer cargo anyhow 1.0.103 error/no_backtrace().,
265 };
266
267 // Safety: BoxedError is repr(transparent) so it is okay for the vtable
268 // to allow casting to Box<dyn StdError + Send + Sync>.
269 unsafe { Errorrust-analyzer cargo anyhow 1.0.103 Error#::constructrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct().(error, vtable, backtrace) }
270 }
271
272 // Takes backtrace as argument rather than capturing it here so that the
273 // user sees one fewer layer of wrapping noise in the backtrace.
274 //
275 // Unsafe because the given vtable must have sensible behavior on the error
276 // value of type E.
277 #[cold]
278 unsafe fn constructrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct().<E>(
279 error: E,
280 vtable: &'static ErrorVTablerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#,
281 backtrace: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace#>,
282 ) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]
283 where
284 E: StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
285 {
286 let inner: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<E>> = Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl# {
287 vtablerust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#vtable.,
288 backtracerust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#backtrace.,
289 _objectrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#_object.: error,
290 });
291 // Erase the concrete type of E from the compile-time type system. This
292 // is equivalent to the safe unsize coercion from Box<ErrorImpl<E>> to
293 // Box<ErrorImpl<dyn StdError + Send + Sync + 'static>> except that the
294 // result is a thin pointer. The necessary behavior for manipulating the
295 // underlying ErrorImpl<E> is preserved in the vtable provided by the
296 // caller rather than a builtin fat pointer vtable.
297 let inner = Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#::newrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]new().(inner).castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>();
298 Errorrust-analyzer cargo anyhow 1.0.103 Error# { innerrust-analyzer cargo anyhow 1.0.103 Error#inner. }
299 }
300
301 /// Wrap the error value with additional context.
302 ///
303 /// For attaching context to a `Result` as it is propagated, the
304 /// [`Context`][crate::Context] extension trait may be more convenient than
305 /// this function.
306 ///
307 /// The primary reason to use `error.context(...)` instead of
308 /// `result.context(...)` via the `Context` trait would be if the context
309 /// needs to depend on some data held by the underlying error:
310 ///
311 /// ```
312 /// # use std::fmt::{self, Debug, Display};
313 /// #
314 /// # type T = ();
315 /// #
316 /// # impl std::error::Error for ParseError {}
317 /// # impl Debug for ParseError {
318 /// # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
319 /// # unimplemented!()
320 /// # }
321 /// # }
322 /// # impl Display for ParseError {
323 /// # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
324 /// # unimplemented!()
325 /// # }
326 /// # }
327 /// #
328 /// use anyhow::Result;
329 /// use std::fs::File;
330 /// use std::path::Path;
331 ///
332 /// struct ParseError {
333 /// line: usize,
334 /// column: usize,
335 /// }
336 ///
337 /// fn parse_impl(file: File) -> Result<T, ParseError> {
338 /// # const IGNORE: &str = stringify! {
339 /// ...
340 /// # };
341 /// # unimplemented!()
342 /// }
343 ///
344 /// pub fn parse(path: impl AsRef<Path>) -> Result<T> {
345 /// let file = File::open(&path)?;
346 /// parse_impl(file).map_err(|error| {
347 /// let context = format!(
348 /// "only the first {} lines of {} are valid",
349 /// error.line, path.as_ref().display(),
350 /// );
351 /// anyhow::Error::new(error).context(context)
352 /// })
353 /// }
354 /// ```
355 #[cold]
356 #[must_use]
357 pub fn contextrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]context().<C>(self, context: C) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]
358 where
359 C: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
360 {
361 let error: ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, Errorrust-analyzer cargo anyhow 1.0.103 Error#> = ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError# {
362 contextrust-analyzer cargo anyhow 1.0.103 error/ContextError#context.,
363 errorrust-analyzer cargo anyhow 1.0.103 error/ContextError#error.: self,
364 };
365
366 let vtable = &ErrorVTablerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable# {
367 object_droprust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop.: object_droprust-analyzer cargo anyhow 1.0.103 error/object_drop().::<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, Errorrust-analyzer cargo anyhow 1.0.103 Error#>>,
368 object_refrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_ref.: object_refrust-analyzer cargo anyhow 1.0.103 error/object_ref().::<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, Errorrust-analyzer cargo anyhow 1.0.103 Error#>>,
369 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
370 object_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_boxed.: object_boxedrust-analyzer cargo anyhow 1.0.103 error/object_boxed().::<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, Errorrust-analyzer cargo anyhow 1.0.103 Error#>>,
371 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
372 object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_reallocate_boxed.: object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/object_reallocate_boxed().::<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, Errorrust-analyzer cargo anyhow 1.0.103 Error#>>,
373 object_downcastrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_downcast.: context_chain_downcastrust-analyzer cargo anyhow 1.0.103 error/context_chain_downcast().::<C>,
374 object_drop_restrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop_rest.: context_chain_drop_restrust-analyzer cargo anyhow 1.0.103 error/context_chain_drop_rest().::<C>,
375 #[cfg(all(not(error_generic_member_access), feature = "std"))]
376 object_backtracerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_backtrace.: context_backtracerust-analyzer cargo anyhow 1.0.103 error/context_backtrace().::<C>,
377 };
378
379 // As the cause is anyhow::Error, we already have a backtrace for it.
380 let backtrace = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
381
382 // Safety: passing vtable that operates on the right type.
383 unsafe { Errorrust-analyzer cargo anyhow 1.0.103 Error#::constructrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct().(error, vtable, backtrace) }
384 }
385
386 /// Get the backtrace for this Error.
387 ///
388 /// In order for the backtrace to be meaningful, one of the two environment
389 /// variables `RUST_LIB_BACKTRACE=1` or `RUST_BACKTRACE=1` must be defined
390 /// and `RUST_LIB_BACKTRACE` must not be `0`. Backtraces are somewhat
391 /// expensive to capture in Rust, so we don't necessarily want to be
392 /// capturing them all over the place all the time.
393 ///
394 /// - If you want panics and errors to both have backtraces, set
395 /// `RUST_BACKTRACE=1`;
396 /// - If you want only errors to have backtraces, set
397 /// `RUST_LIB_BACKTRACE=1`;
398 /// - If you want only panics to have backtraces, set `RUST_BACKTRACE=1` and
399 /// `RUST_LIB_BACKTRACE=0`.
400 ///
401 /// # Stability
402 ///
403 /// Standard library backtraces are only available when using Rust &ge;
404 /// 1.65. On older compilers, this function is only available if the crate's
405 /// "backtrace" feature is enabled, and will use the `backtrace` crate as
406 /// the underlying backtrace implementation. The return type of this
407 /// function on old compilers is `&(impl Debug + Display)`.
408 ///
409 /// ```toml
410 /// [dependencies]
411 /// anyhow = { version = "1.0", features = ["backtrace"] }
412 /// ```
413 #[cfg(feature = "std")]
414 pub fn backtracerust-analyzer cargo anyhow 1.0.103 error/impl#[Error]backtrace().(&self) -> &Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace# {
415 unsafe { ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::backtracerust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]backtrace().(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_ref().()) }
416 }
417
418 /// An iterator of the chain of source errors contained by this Error.
419 ///
420 /// This iterator will visit every error in the cause chain of this error
421 /// object, beginning with the error that this error object was created
422 /// from.
423 ///
424 /// # Example
425 ///
426 /// ```
427 /// use anyhow::Error;
428 /// use std::io;
429 ///
430 /// pub fn underlying_io_error_kind(error: &Error) -> Option<io::ErrorKind> {
431 /// for cause in error.chain() {
432 /// if let Some(io_error) = cause.downcast_ref::<io::Error>() {
433 /// return Some(io_error.kind());
434 /// }
435 /// }
436 /// None
437 /// }
438 /// ```
439 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
440 #[cold]
441 pub fn chainrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]chain().(&self) -> Chainrust-analyzer cargo anyhow 1.0.103 Chain# {
442 unsafe { ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::chainrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]chain().(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_ref().()) }
443 }
444
445 /// The lowest level cause of this error &mdash; this error's cause's
446 /// cause's cause etc.
447 ///
448 /// The root cause is the last error in the iterator produced by
449 /// [`chain()`][Error::chain].
450 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
451 #[allow(clippy::double_ended_iterator_last)]
452 pub fn root_causerust-analyzer cargo anyhow 1.0.103 error/impl#[Error]root_cause().(&self) -> &(dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static) {
453 self.chainrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]chain().().lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
454 }
455
456 /// Returns true if `E` is the type held by this error object.
457 ///
458 /// For errors with context, this method returns true if `E` matches the
459 /// type of the context `C` **or** the type of the error on which the
460 /// context has been attached. For details about the interaction between
461 /// context and downcasting, [see here].
462 ///
463 /// [see here]: crate::Context#effect-on-downcasting
464 pub fn isrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]is().<E>(&self) -> bool
465 where
466 E: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
467 {
468 self.downcast_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_ref().::<E>().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()
469 }
470
471 /// Attempt to downcast the error object to a concrete type.
472 pub fn downcastrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast().<E>(mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<E, Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]>
473 where
474 E: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
475 {
476 let target = TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<E>();
477 let inner = self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..by_mutrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_mut().();
478 unsafe {
479 // Use vtable to find NonNull<()> which points to a value of type E
480 // somewhere inside the data structure.
481 let addr = match (vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(inner.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr.).object_downcastrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_downcast.)(inner.by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]by_ref().(), target) {
482 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(addr) => addr.by_mutrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]by_mut().().extendrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]extend().(),
483 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(self),
484 };
485
486 // Prepare to read E out of the data structure. We'll drop the rest
487 // of the data structure separately so that E is not dropped.
488 let outer = ManuallyDroprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/ManuallyDrop#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/impl#[`ManuallyDrop<T>`]new().(self);
489
490 // Read E from where the vtable found it.
491 let error = addr.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]cast().::<E>().readrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]read().();
492
493 // Drop rest of the data structure outside of E.
494 (vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(outer.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.).object_drop_restrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop_rest.)(outer.innerrust-analyzer cargo anyhow 1.0.103 Error#inner., target);
495
496 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(error)
497 }
498 }
499
500 /// Downcast this error object by reference.
501 ///
502 /// # Example
503 ///
504 /// ```
505 /// # use anyhow::anyhow;
506 /// # use std::fmt::{self, Display};
507 /// # use std::task::Poll;
508 /// #
509 /// # #[derive(Debug)]
510 /// # enum DataStoreError {
511 /// # Censored(()),
512 /// # }
513 /// #
514 /// # impl Display for DataStoreError {
515 /// # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
516 /// # unimplemented!()
517 /// # }
518 /// # }
519 /// #
520 /// # impl std::error::Error for DataStoreError {}
521 /// #
522 /// # const REDACTED_CONTENT: () = ();
523 /// #
524 /// # let error = anyhow!("...");
525 /// # let root_cause = &error;
526 /// #
527 /// # let ret =
528 /// // If the error was caused by redaction, then return a tombstone instead
529 /// // of the content.
530 /// match root_cause.downcast_ref::<DataStoreError>() {
531 /// Some(DataStoreError::Censored(_)) => Ok(Poll::Ready(REDACTED_CONTENT)),
532 /// None => Err(error),
533 /// }
534 /// # ;
535 /// ```
536 pub fn downcast_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_ref().<E>(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&E>
537 where
538 E: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
539 {
540 let target = TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<E>();
541 unsafe {
542 // Use vtable to find NonNull<()> which points to a value of type E
543 // somewhere inside the data structure.
544 let addr = (vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.).object_downcastrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_downcast.)(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_ref().(), target)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
545 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(addr.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<E>().derefrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]deref().())
546 }
547 }
548
549 /// Downcast this error object by mutable reference.
550 pub fn downcast_mutrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_mut().<E>(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut E>
551 where
552 E: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
553 {
554 let target = TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<E>();
555 unsafe {
556 // Use vtable to find NonNull<()> which points to a value of type E
557 // somewhere inside the data structure.
558 let addr =
559 (vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.).object_downcastrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_downcast.)(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_ref().(), target)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch()..by_mutrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]by_mut().();
560 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(addr.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]cast().::<E>().deref_mutrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]deref_mut().())
561 }
562 }
563
564 /// Convert to a standard library error trait object.
565 ///
566 /// This is implemented as a cheap pointer cast that does not allocate or
567 /// deallocate memory. Like [`anyhow::Error::from_boxed`], it's useful for
568 /// interop with other error libraries.
569 ///
570 /// The same conversion is also available as
571 /// <code style="display:inline;white-space:normal;">impl From&lt;anyhow::Error&gt;
572 /// for Box&lt;dyn Error + Send + Sync + &apos;static&gt;</code>.
573 ///
574 /// If a backtrace was collected during construction of the `anyhow::Error`,
575 /// that backtrace remains accessible using the standard library `Error`
576 /// trait's provider API, but as a consequence, the resulting boxed error
577 /// can no longer be downcast to its original underlying type.
578 ///
579 /// ```
580 #[cfg_attr(not(error_generic_member_access), doc = "# _ = stringify! {")]
581 /// #![feature(error_generic_member_access)]
582 ///
583 /// use anyhow::anyhow;
584 /// use std::backtrace::Backtrace;
585 /// use thiserror::Error;
586 ///
587 /// #[derive(Error, Debug)]
588 /// #[error("...")]
589 /// struct MyError;
590 ///
591 /// let anyhow_error = anyhow!(MyError);
592 /// println!("{}", anyhow_error.backtrace()); // has Backtrace
593 /// assert!(anyhow_error.downcast_ref::<MyError>().is_some()); // can downcast
594 ///
595 /// let boxed_dyn_error = anyhow_error.into_boxed_dyn_error();
596 /// assert!(std::error::request_ref::<Backtrace>(&*boxed_dyn_error).is_some()); // has Backtrace
597 /// assert!(boxed_dyn_error.downcast_ref::<MyError>().is_none()); // can no longer downcast
598 #[cfg_attr(not(error_generic_member_access), doc = "# };")]
599 /// ```
600 ///
601 /// [`anyhow::Error::from_boxed`]: Self::from_boxed
602 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
603 #[must_use]
604 pub fn into_boxed_dyn_errorrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]into_boxed_dyn_error().(self) -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static> {
605 let outer = ManuallyDroprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/ManuallyDrop#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/impl#[`ManuallyDrop<T>`]new().(self);
606 unsafe {
607 // Use vtable to attach ErrorImpl<E>'s native StdError vtable for
608 // the right original type E.
609 (vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(outer.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.).object_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_boxed.)(outer.innerrust-analyzer cargo anyhow 1.0.103 Error#inner.)
610 }
611 }
612
613 /// Convert to a standard library error trait object.
614 ///
615 /// Unlike `self.into_boxed_dyn_error()`, this method relocates the
616 /// underlying error into a new allocation in order to make it downcastable
617 /// to `&E` or `Box<E>` for its original underlying error type. Any
618 /// backtrace collected during construction of the `anyhow::Error` is
619 /// discarded.
620 ///
621 /// ```
622 #[cfg_attr(not(error_generic_member_access), doc = "# _ = stringify!{")]
623 /// #![feature(error_generic_member_access)]
624 ///
625 /// use anyhow::anyhow;
626 /// use std::backtrace::Backtrace;
627 /// use thiserror::Error;
628 ///
629 /// #[derive(Error, Debug)]
630 /// #[error("...")]
631 /// struct MyError;
632 ///
633 /// let anyhow_error = anyhow!(MyError);
634 /// println!("{}", anyhow_error.backtrace()); // has Backtrace
635 /// assert!(anyhow_error.downcast_ref::<MyError>().is_some()); // can downcast
636 ///
637 /// let boxed_dyn_error = anyhow_error.reallocate_into_boxed_dyn_error_without_backtrace();
638 /// assert!(std::error::request_ref::<Backtrace>(&*boxed_dyn_error).is_none()); // Backtrace lost
639 /// assert!(boxed_dyn_error.downcast_ref::<MyError>().is_some()); // can downcast to &MyError
640 /// assert!(boxed_dyn_error.downcast::<MyError>().is_ok()); // can downcast to Box<MyError>
641 #[cfg_attr(not(error_generic_member_access), doc = "# };")]
642 /// ```
643 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
644 #[must_use]
645 pub fn reallocate_into_boxed_dyn_error_without_backtracerust-analyzer cargo anyhow 1.0.103 error/impl#[Error]reallocate_into_boxed_dyn_error_without_backtrace().(
646 self,
647 ) -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static> {
648 let outer = ManuallyDroprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/ManuallyDrop#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/impl#[`ManuallyDrop<T>`]new().(self);
649 unsafe {
650 // Use vtable to attach E's native StdError vtable for the right
651 // original type E.
652 (vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(outer.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.).object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_reallocate_boxed.)(outer.innerrust-analyzer cargo anyhow 1.0.103 Error#inner.)
653 }
654 }
655
656 #[cfg(error_generic_member_access)]
657 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) fn provide<'a>(&'a self, request: &mut Request<'a>) {
658 unsafe { ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::provide(selfrust-analyzer cargo anyhow 1.0.103 error/.inner.by_ref(), request) }
659 }
660
661 // Called by thiserror when you have `#[source] anyhow::Error`. This provide
662 // implementation includes the anyhow::Error's Backtrace if any, unlike
663 // deref'ing to dyn Error where the provide implementation would include
664 // only the original error's Backtrace from before it got wrapped into an
665 // anyhow::Error.
666 #[cfg(error_generic_member_access)]
667 #[doc(hidden)]
668 pub fn thiserror_provide<'a>(&'a self, request: &mut Request<'a>) {
669 Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]::provide(selfrust-analyzer cargo anyhow 1.0.103 error/, request);
670 }
671 }
672
673 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
674 impl<E> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<E> for Errorrust-analyzer cargo anyhow 1.0.103 Error#
675 where
676 E: StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
677 {
678 #[cold]
679 fn fromrust-analyzer cargo anyhow 1.0.103 error/impl#[Error][`From<E>`]from().(error: E) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error][`From<E>`] {
680 let backtrace = backtrace_if_absentrust-analyzer cargo anyhow 1.0.103 backtrace/backtrace_if_absent!!(&error);
681 Errorrust-analyzer cargo anyhow 1.0.103 Error#::construct_from_stdrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]construct_from_std().(error, backtrace)
682 }
683 }
684
685 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
686 impl Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for Errorrust-analyzer cargo anyhow 1.0.103 Error# {
687 type Targetrust-analyzer cargo anyhow 1.0.103 error/impl#[Error][Deref]Target# = dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static;
688
689 fn derefrust-analyzer cargo anyhow 1.0.103 error/impl#[Error][Deref]deref().(&self) -> &Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# {
690 unsafe { ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::errorrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]error().(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_ref().()) }
691 }
692 }
693
694 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
695 impl DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut# for Errorrust-analyzer cargo anyhow 1.0.103 Error# {
696 fn deref_mutrust-analyzer cargo anyhow 1.0.103 error/impl#[Error][DerefMut]deref_mut().(&mut self) -> &mut Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[Error][DerefMut]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# {
697 unsafe { ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::error_mutrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]error_mut().(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..by_mutrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_mut().()) }
698 }
699 }
700
701 impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Errorrust-analyzer cargo anyhow 1.0.103 Error# {
702 fn fmtrust-analyzer cargo anyhow 1.0.103 error/impl#[Error][Display]fmt().(&self, formatter: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
703 unsafe { ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::displayrust-analyzer cargo anyhow 1.0.103 fmt/impl#[ErrorImpl]display().(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_ref().(), formatter) }
704 }
705 }
706
707 impl Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Errorrust-analyzer cargo anyhow 1.0.103 Error# {
708 fn fmtrust-analyzer cargo anyhow 1.0.103 error/impl#[Error][Debug]fmt().(&self, formatter: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
709 unsafe { ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::debugrust-analyzer cargo anyhow 1.0.103 fmt/impl#[ErrorImpl]debug().(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_ref().(), formatter) }
710 }
711 }
712
713 impl Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for Errorrust-analyzer cargo anyhow 1.0.103 Error# {
714 fn droprust-analyzer cargo anyhow 1.0.103 error/impl#[Error][Drop]drop().(&mut self) {
715 unsafe {
716 // Invoke the vtable's drop behavior.
717 (vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.).object_droprust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop.)(self.innerrust-analyzer cargo anyhow 1.0.103 Error#inner.);
718 }
719 }
720 }
721
722 struct ErrorVTablerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable# {
723 object_droprust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop.: unsafe fn(Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>),
724 object_refrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_ref.: unsafe fn(Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>) -> Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static>,
725 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
726 object_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_boxed.: unsafe fn(Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>) -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static>,
727 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
728 object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_reallocate_boxed.: unsafe fn(Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>) -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static>,
729 object_downcastrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_downcast.: unsafe fn(Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>, TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<()>>,
730 object_drop_restrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop_rest.: unsafe fn(Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>, TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#),
731 #[cfg(all(not(error_generic_member_access), feature = "std"))]
732 object_backtracerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_backtrace.: unsafe fn(Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace#>,
733 }
734
735 // Safety: requires layout of *e to match ErrorImpl<E>.
736 unsafe fn object_droprust-analyzer cargo anyhow 1.0.103 error/object_drop().<E>(e: Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>) {
737 // Cast back to ErrorImpl<E> so that the allocator receives the correct
738 // Layout to deallocate the Box's memory.
739 let unerased_own = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<E>>();
740 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(unsafe { unerased_own.boxedrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]boxed().() });
741 }
742
743 // Safety: requires layout of *e to match ErrorImpl<E>.
744 unsafe fn object_drop_frontrust-analyzer cargo anyhow 1.0.103 error/object_drop_front().<E>(e: Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>, target: TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#) {
745 // Drop the fields of ErrorImpl other than E as well as the Box allocation,
746 // without dropping E itself. This is used by downcast after doing a
747 // ptr::read to take ownership of the E.
748 let _ = target;
749 let unerased_own = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<ManuallyDroprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/ManuallyDrop#<E>>>();
750 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(unsafe { unerased_own.boxedrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]boxed().() });
751 }
752
753 // Safety: requires layout of *e to match ErrorImpl<E>.
754 unsafe fn object_refrust-analyzer cargo anyhow 1.0.103 error/object_ref().<E>(e: Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>) -> Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static>
755 where
756 E: StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
757 {
758 // Attach E's native StdError vtable onto a pointer to self._object.
759 let unerased_ref = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<E>>();
760 Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#::from_rawrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]from_raw().(unsafe {
761 NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#::new_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]new_unchecked().(ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::addr_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/addr_of!!((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().unerased_ref.as_ptrrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]as_ptr().())._objectrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#_object.).cast_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`]cast_mut().())
762 })
763 }
764
765 // Safety: requires layout of *e to match ErrorImpl<E>.
766 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
767 unsafe fn object_boxedrust-analyzer cargo anyhow 1.0.103 error/object_boxed().<E>(e: Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>) -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static>
768 where
769 E: StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
770 {
771 // Attach ErrorImpl<E>'s native StdError vtable. The StdError impl is below.
772 let unerased_own = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<E>>();
773 unsafe { unerased_own.boxedrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]boxed().() }
774 }
775
776 // Safety: requires layout of *e to match ErrorImpl<E>.
777 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
778 unsafe fn object_reallocate_boxedrust-analyzer cargo anyhow 1.0.103 error/object_reallocate_boxed().<E>(e: Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>) -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static>
779 where
780 E: StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static,
781 {
782 // Attach E's native StdError vtable.
783 let unerased_own = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<E>>();
784 Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(unsafe { unerased_own.boxedrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]boxed().() }._objectrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#_object.)
785 }
786
787 // Safety: requires layout of *e to match ErrorImpl<E>.
788 unsafe fn object_downcastrust-analyzer cargo anyhow 1.0.103 error/object_downcast().<E>(e: Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>, target: TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<()>>
789 where
790 E: 'static,
791 {
792 if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<E>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().target {
793 // Caller is looking for an E pointer and e is ErrorImpl<E>, take a
794 // pointer to its E field.
795 let unerased_ref = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<E>>();
796 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(
797 Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#::from_rawrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]from_raw().(unsafe {
798 NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#::new_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]new_unchecked().(ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::addr_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/addr_of!!((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().unerased_ref.as_ptrrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]as_ptr().())._objectrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#_object.).cast_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`]cast_mut().())
799 })
800 .castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<()>(),
801 )
802 } else {
803 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
804 }
805 }
806
807 #[cfg(all(not(error_generic_member_access), feature = "std"))]
808 fn no_backtracerust-analyzer cargo anyhow 1.0.103 error/no_backtrace().(e: Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace#> {
809 let _ = e;
810 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
811 }
812
813 // Safety: requires layout of *e to match ErrorImpl<ContextError<C, E>>.
814 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
815 unsafe fn context_downcastrust-analyzer cargo anyhow 1.0.103 error/context_downcast().<C, E>(e: Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>, target: TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<()>>
816 where
817 C: 'static,
818 E: 'static,
819 {
820 if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<C>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().target {
821 let unerased_ref = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, E>>>();
822 let inner = unsafe { ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::addr_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/addr_of!!((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().unerased_ref.as_ptrrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]as_ptr().())._objectrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#_object..contextrust-analyzer cargo anyhow 1.0.103 error/ContextError#context.) };
823 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#::from_rawrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]from_raw().(unsafe { NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#::new_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]new_unchecked().(inner.cast_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`]cast_mut().()) }).castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<()>())
824 } else if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<E>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().target {
825 let unerased_ref = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, E>>>();
826 let inner = unsafe { ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::addr_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/addr_of!!((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().unerased_ref.as_ptrrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]as_ptr().())._objectrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#_object..errorrust-analyzer cargo anyhow 1.0.103 error/ContextError#error.) };
827 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#::from_rawrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]from_raw().(unsafe { NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#::new_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]new_unchecked().(inner.cast_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`]cast_mut().()) }).castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<()>())
828 } else {
829 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
830 }
831 }
832
833 // Safety: requires layout of *e to match ErrorImpl<ContextError<C, E>>.
834 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
835 unsafe fn context_drop_restrust-analyzer cargo anyhow 1.0.103 error/context_drop_rest().<C, E>(e: Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>, target: TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#)
836 where
837 C: 'static,
838 E: 'static,
839 {
840 // Called after downcasting by value to either the C or the E and doing a
841 // ptr::read to take ownership of that value.
842 if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<C>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().target {
843 let unerased_own = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<ManuallyDroprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/ManuallyDrop#<C>, E>>>();
844 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(unsafe { unerased_own.boxedrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]boxed().() });
845 } else {
846 let unerased_own = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, ManuallyDroprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/ManuallyDrop#<E>>>>();
847 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(unsafe { unerased_own.boxedrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]boxed().() });
848 }
849 }
850
851 // Safety: requires layout of *e to match ErrorImpl<ContextError<C, Error>>.
852 unsafe fn context_chain_downcastrust-analyzer cargo anyhow 1.0.103 error/context_chain_downcast().<C>(e: Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>, target: TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<()>>
853 where
854 C: 'static,
855 {
856 let unerased_ref = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, Errorrust-analyzer cargo anyhow 1.0.103 Error#>>>();
857 if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<C>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().target {
858 let inner = unsafe { ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::addr_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/addr_of!!((*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().unerased_ref.as_ptrrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]as_ptr().())._objectrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#_object..contextrust-analyzer cargo anyhow 1.0.103 error/ContextError#context.) };
859 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#::from_rawrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]from_raw().(unsafe { NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#::new_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]new_unchecked().(inner.cast_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`]cast_mut().()) }).castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<()>())
860 } else {
861 // Recurse down the context chain per the inner error's vtable.
862 let unerased = unsafe { unerased_ref.derefrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]deref().() };
863 let source = &unerased._objectrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#_object..errorrust-analyzer cargo anyhow 1.0.103 error/ContextError#error.;
864 unsafe { (vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(source.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.).object_downcastrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_downcast.)(source.innerrust-analyzer cargo anyhow 1.0.103 Error#inner..by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_ref().(), target) }
865 }
866 }
867
868 // Safety: requires layout of *e to match ErrorImpl<ContextError<C, Error>>.
869 unsafe fn context_chain_drop_restrust-analyzer cargo anyhow 1.0.103 error/context_chain_drop_rest().<C>(e: Ownrust-analyzer cargo anyhow 1.0.103 ptr/Own#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>, target: TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#)
870 where
871 C: 'static,
872 {
873 // Called after downcasting by value to either the C or one of the causes
874 // and doing a ptr::read to take ownership of that value.
875 if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<C>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().target {
876 let unerased_own = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<ManuallyDroprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/ManuallyDrop#<C>, Errorrust-analyzer cargo anyhow 1.0.103 Error#>>>();
877 // Drop the entire rest of the data structure rooted in the next Error.
878 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(unsafe { unerased_own.boxedrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]boxed().() });
879 } else {
880 let unerased_own = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, ManuallyDroprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/manually_drop/ManuallyDrop#<Errorrust-analyzer cargo anyhow 1.0.103 Error#>>>>();
881 let unerased = unsafe { unerased_own.boxedrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]boxed().() };
882 // Read the Own<ErrorImpl> from the next error.
883 let inner = unerased._objectrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#_object..errorrust-analyzer cargo anyhow 1.0.103 error/ContextError#error..innerrust-analyzer cargo anyhow 1.0.103 Error#inner.;
884 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(unerased);
885 let vtable = unsafe { vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(inner.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Own#ptr.) };
886 // Recursively drop the next error using the same target typeid.
887 unsafe { (vtable.object_drop_restrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_drop_rest.)(inner, target) };
888 }
889 }
890
891 // Safety: requires layout of *e to match ErrorImpl<ContextError<C, Error>>.
892 #[cfg(all(not(error_generic_member_access), feature = "std"))]
893 #[allow(clippy::unnecessary_wraps)]
894 unsafe fn context_backtracerust-analyzer cargo anyhow 1.0.103 error/context_backtrace().<C>(e: Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace#>
895 where
896 C: 'static,
897 {
898 let unerased_ref = e.castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, Errorrust-analyzer cargo anyhow 1.0.103 Error#>>>();
899 let unerased = unsafe { unerased_ref.derefrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]deref().() };
900 let backtrace = unsafe { ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::backtracerust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]backtrace().(unerased._objectrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#_object..errorrust-analyzer cargo anyhow 1.0.103 error/ContextError#error..innerrust-analyzer cargo anyhow 1.0.103 Error#inner..by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Own<T>`]by_ref().()) };
901 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(backtrace)
902 }
903
904 // NOTE: If working with `ErrorImpl<()>`, references should be avoided in favor
905 // of raw pointers and `NonNull`.
906 // repr C to ensure that E remains in the final position.
907 #[repr(C)]
908 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) struct ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<E = ()> {
909 vtablerust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#vtable.: &'static ErrorVTablerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#,
910 backtracerust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#backtrace.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace#>,
911 // NOTE: Don't use directly. Use only through vtable. Erased type may have
912 // different alignment.
913 _objectrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#_object.: E,
914 }
915
916 // Reads the vtable out of `p`. This is the same as `p.as_ref().vtable`, but
917 // avoids converting `p` into a reference.
918 unsafe fn vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(p: NonNullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/NonNull#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>) -> &'static ErrorVTablerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable# {
919 // NOTE: This assumes that `ErrorVTable` is the first field of ErrorImpl.
920 unsafe { *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().(p.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/non_null/impl#[`NonNull<T>`]as_ptr().() as *const &'static ErrorVTablerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#) }
921 }
922
923 // repr C to ensure that ContextError<C, E> has the same layout as
924 // ContextError<ManuallyDrop<C>, E> and ContextError<C, ManuallyDrop<E>>.
925 #[repr(C)]
926 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) struct ContextErrorrust-analyzer cargo anyhow 1.0.103 error/ContextError#<C, E> {
927 pub contextrust-analyzer cargo anyhow 1.0.103 error/ContextError#context.: C,
928 pub errorrust-analyzer cargo anyhow 1.0.103 error/ContextError#error.: E,
929 }
930
931 impl<E> ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<E> {
932 fn eraserust-analyzer cargo anyhow 1.0.103 error/impl#[`ErrorImpl<E>`]erase().(&self) -> Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#> {
933 // Erase the concrete type of E but preserve the vtable in self.vtable
934 // for manipulating the resulting thin pointer. This is analogous to an
935 // unsize coercion.
936 Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#::newrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]new().(self).castrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]cast().::<ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#>()
937 }
938 }
939
940 impl ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl# {
941 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) unsafe fn errorrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]error().(this: Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]>) -> &(dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static) {
942 // Use vtable to attach E's native StdError vtable for the right
943 // original type E.
944 unsafe { (vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(this.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr.).object_refrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_ref.)(this).derefrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]deref().() }
945 }
946
947 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
948 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) unsafe fn error_mutrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]error_mut().(this: Mutrust-analyzer cargo anyhow 1.0.103 ptr/Mut#<Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]>) -> &mut (dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static) {
949 // Use vtable to attach E's native StdError vtable for the right
950 // original type E.
951 unsafe {
952 (vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(this.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Mut#ptr.).object_refrust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_ref.)(this.by_refrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]by_ref().())
953 .by_mutrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]by_mut().()
954 .deref_mutrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Mut<'a, T>`]deref_mut().()
955 }
956 }
957
958 #[cfg(feature = "std")]
959 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) unsafe fn backtracerust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]backtrace().(this: Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]>) -> &Backtracerust-analyzer cargo std https://github.com/rust-lang/rust/library/std backtrace/Backtrace# {
960 // This unwrap can only panic if the underlying error's backtrace method
961 // is nondeterministic, which would only happen in maliciously
962 // constructed code.
963 unsafe { this.derefrust-analyzer cargo anyhow 1.0.103 ptr/impl#[`Ref<'a, T>`]deref().() }
964 .backtracerust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#backtrace.
965 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
966 .or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]or_else().(|| {
967 #[cfg(error_generic_member_access)]
968 return nightly::request_ref_backtrace(unsafe { Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]::error(this) });
969 #[cfg(not(error_generic_member_access))]
970 return unsafe { (vtablerust-analyzer cargo anyhow 1.0.103 error/vtable().(this.ptrrust-analyzer cargo anyhow 1.0.103 ptr/Ref#ptr.).object_backtracerust-analyzer cargo anyhow 1.0.103 error/ErrorVTable#object_backtrace.)(this) };
971 })
972 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("backtrace capture failed")
973 }
974
975 #[cfg(error_generic_member_access)]
976 unsafe fn provide<'a>(this: Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<'a, Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]>, request: &mut Request<'a>) {
977 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(backtrace) = unsafe { &this.deref().backtrace } {
978 nightly::provide_ref_backtrace(request, backtracerust-analyzer cargo anyhow 1.0.103 backtrace/backtrace!);
979 }
980 nightly::provide(unsafe { Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]::error(this) }, request);
981 }
982
983 #[cold]
984 pub(craterust-analyzer cargo anyhow 1.0.103 crate/) unsafe fn chainrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]chain().(this: Refrust-analyzer cargo anyhow 1.0.103 ptr/Ref#<Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]>) -> Chainrust-analyzer cargo anyhow 1.0.103 Chain# {
985 Chainrust-analyzer cargo anyhow 1.0.103 Chain#::newrust-analyzer cargo anyhow 1.0.103 chain/impl#[`Chain<'a>`]new().(unsafe { Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]::errorrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]error().(this) })
986 }
987 }
988
989 impl<E> StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<E>
990 where
991 E: StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#,
992 {
993 fn sourcerust-analyzer cargo anyhow 1.0.103 error/impl#[`ErrorImpl<E>`][Error]source().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&(dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static)> {
994 unsafe { ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::errorrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]error().(self.eraserust-analyzer cargo anyhow 1.0.103 error/impl#[`ErrorImpl<E>`]erase().()).sourcerust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#source().() }
995 }
996
997 #[cfg(error_generic_member_access)]
998 fn provide<'a>(&'a self, request: &mut Request<'a>) {
999 unsafe { ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::provide(selfrust-analyzer cargo anyhow 1.0.103 error/.erase(), request) }
1000 }
1001 }
1002
1003 impl<E> Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<E>
1004 where
1005 E: Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#,
1006 {
1007 fn fmtrust-analyzer cargo anyhow 1.0.103 error/impl#[`ErrorImpl<E>`][Debug]fmt().(&self, formatter: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
1008 unsafe { ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::debugrust-analyzer cargo anyhow 1.0.103 fmt/impl#[ErrorImpl]debug().(self.eraserust-analyzer cargo anyhow 1.0.103 error/impl#[`ErrorImpl<E>`]erase().(), formatter) }
1009 }
1010 }
1011
1012 impl<E> Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#<E>
1013 where
1014 E: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#,
1015 {
1016 fn fmtrust-analyzer cargo anyhow 1.0.103 error/impl#[`ErrorImpl<E>`][Display]fmt().(&self, formatter: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
1017 unsafe { Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#fmt().(ErrorImplrust-analyzer cargo anyhow 1.0.103 error/ErrorImpl#::errorrust-analyzer cargo anyhow 1.0.103 error/impl#[ErrorImpl]error().(self.eraserust-analyzer cargo anyhow 1.0.103 error/impl#[`ErrorImpl<E>`]erase().()), formatter) }
1018 }
1019 }
1020
1021 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
1022 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Errorrust-analyzer cargo anyhow 1.0.103 Error#> for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static> {
1023 #[cold]
1024 fn fromrust-analyzer cargo anyhow 1.0.103 error/impl#[`Box<dyn Error + Send + Sync + 'static>`][`From<Error>`]from().(error: Errorrust-analyzer cargo anyhow 1.0.103 Error#) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[`Box<dyn Error + Send + Sync + 'static>`][`From<Error>`] {
1025 error.into_boxed_dyn_errorrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]into_boxed_dyn_error().()
1026 }
1027 }
1028
1029 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
1030 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Errorrust-analyzer cargo anyhow 1.0.103 Error#> for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + 'static> {
1031 #[cold]
1032 fn fromrust-analyzer cargo anyhow 1.0.103 error/impl#[`Box<dyn Error + Send + 'static>`][`From<Error>`]from().(error: Errorrust-analyzer cargo anyhow 1.0.103 Error#) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[`Box<dyn Error + Send + 'static>`][`From<Error>`] {
1033 error.into_boxed_dyn_errorrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]into_boxed_dyn_error().()
1034 }
1035 }
1036
1037 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
1038 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Errorrust-analyzer cargo anyhow 1.0.103 Error#> for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static> {
1039 #[cold]
1040 fn fromrust-analyzer cargo anyhow 1.0.103 error/impl#[`Box<dyn Error + 'static>`][`From<Error>`]from().(error: Errorrust-analyzer cargo anyhow 1.0.103 Error#) -> Selfrust-analyzer cargo anyhow 1.0.103 error/impl#[`Box<dyn Error + 'static>`][`From<Error>`] {
1041 error.into_boxed_dyn_errorrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]into_boxed_dyn_error().()
1042 }
1043 }
1044
1045 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
1046 impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#> for Errorrust-analyzer cargo anyhow 1.0.103 Error# {
1047 fn as_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error][`AsRef<dyn Error + Send + Sync + 'static>`]as_ref().(&self) -> &(dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static) {
1048 &*rust-analyzer cargo anyhow 1.0.103 error/impl#[Error][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self
1049 }
1050 }
1051
1052 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]
1053 impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#> for Errorrust-analyzer cargo anyhow 1.0.103 Error# {
1054 fn as_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error][`AsRef<dyn Error + 'static>`]as_ref().(&self) -> &(dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static) {
1055 &*rust-analyzer cargo anyhow 1.0.103 error/impl#[Error][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self
1056 }
1057 }
1058
1059 impl UnwindSaferust-analyzer cargo core https://github.com/rust-lang/rust/library/core panic/unwind_safe/UnwindSafe# for Errorrust-analyzer cargo anyhow 1.0.103 Error# {}
1060 impl RefUnwindSaferust-analyzer cargo core https://github.com/rust-lang/rust/library/core panic/unwind_safe/RefUnwindSafe# for Errorrust-analyzer cargo anyhow 1.0.103 Error# {}