Merge pull request #401 from dtolnay/construct
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Add `construct_` prefix to name of private construct functions
authored by David Tolnay · committed by GitHub · parents 8ceb5e9, 671f700 · Browse files · 3 files·+17 added−13 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+17 added−13 removed
- other:+17 added−13 removed
Provenance
- Commit
ffecefc- Tree
a897766- Author
David Tolnay <dtolnay@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
8ceb5e9- Parent 2
671f700
3 files changed+17 added−13 removed
modified:src/context.rs+3 added-3 removed
23 unmodified lines24 where25 C: Display + Send + Sync + 'static,26 {27 let backtrace = backtrace_if_absent!(&self);28- Error::from_context(context, self, backtrace)28+ Error::construct_from_context(context, self, backtrace)29 }30 }31 32 impl StdError for Error {62 unmodified lines95 // Not using ok_or_else to save 2 useless frames off the captured96 // backtrace.97 match self {98 Some(ok) => Ok(ok),99- None => Err(Error::from_display(context, backtrace!())),99+ None => Err(Error::construct_from_display(context, backtrace!())),100 }101 }102 103 fn with_context<C, F>(self, context: F) -> Result<T, Error>2 unmodified lines106 F: FnOnce() -> C,107 {108 match self {109 Some(ok) => Ok(ok),110- None => Err(Error::from_display(context(), backtrace!())),110+ None => Err(Error::construct_from_display(context(), backtrace!())),111 }112 }113 }114 79 unmodified linesmodified:src/error.rs+12 added-8 removed
34 unmodified lines35 where36 E: StdError + Send + Sync + 'static,37 {38 let backtrace = backtrace_if_absent!(&error);39- Error::from_std(error, backtrace)39+ Error::construct_from_std(error, backtrace)40 }41 42 /// Create a new error object from a printable error message.43 ///37 unmodified lines81 pub fn msg<M>(message: M) -> Self82 where83 M: Display + Debug + Send + Sync + 'static,84 {85- Error::from_adhoc(message, backtrace!())85+ Error::construct_from_adhoc(message, backtrace!())86 }87 88 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]89 #[cold]90- pub(crate) fn from_std<E>(error: E, backtrace: Option<Backtrace>) -> Self90+ pub(crate) fn construct_from_std<E>(error: E, backtrace: Option<Backtrace>) -> Self91 where92 E: StdError + Send + Sync + 'static,93 {94 let vtable = &ErrorVTable {17 unmodified lines112 unsafe { Error::construct(error, vtable, backtrace) }113 }114 115 #[cold]116- pub(crate) fn from_adhoc<M>(message: M, backtrace: Option<Backtrace>) -> Self116+ pub(crate) fn construct_from_adhoc<M>(message: M, backtrace: Option<Backtrace>) -> Self117 where118 M: Display + Debug + Send + Sync + 'static,119 {120 use crate::wrapper::MessageError;20 unmodified lines141 unsafe { Error::construct(error, vtable, backtrace) }142 }143 144 #[cold]145- pub(crate) fn from_display<M>(message: M, backtrace: Option<Backtrace>) -> Self145+ pub(crate) fn construct_from_display<M>(message: M, backtrace: Option<Backtrace>) -> Self146 where147 M: Display + Send + Sync + 'static,148 {149 use crate::wrapper::DisplayError;21 unmodified lines171 }172 173 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]174 #[cold]175- pub(crate) fn from_context<C, E>(context: C, error: E, backtrace: Option<Backtrace>) -> Self175+ pub(crate) fn construct_from_context<C, E>(176+ context: C,177+ error: E,178+ backtrace: Option<Backtrace>,179+ ) -> Self180 where181 C: Display + Send + Sync + 'static,182 E: StdError + Send + Sync + 'static,183 {21 unmodified lines205 }206 207 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]208 #[cold]205- pub(crate) fn from_boxed(209+ pub(crate) fn construct_from_boxed(210 error: Box<dyn StdError + Send + Sync>,211 backtrace: Option<Backtrace>,212 ) -> Self {213 use crate::wrapper::BoxedError;351 unmodified lines565 {566 #[cold]567 fn from(error: E) -> Self {568 let backtrace = backtrace_if_absent!(&error);565- Error::from_std(error, backtrace)569+ Error::construct_from_std(error, backtrace)570 }571 }572 573 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]458 unmodified linesmodified:src/kind.rs+2 added-2 removed
68 unmodified lines69 pub fn new<M>(self, message: M) -> Error70 where71 M: Display + Debug + Send + Sync + 'static,72 {73- Error::from_adhoc(message, backtrace!())73+ Error::construct_from_adhoc(message, backtrace!())74 }75 }76 77 pub struct Trait;37 unmodified lines115 impl Boxed {116 #[cold]117 pub fn new(self, error: Box<dyn StdError + Send + Sync>) -> Error {118 let backtrace = backtrace_if_absent!(&*error);119- Error::from_boxed(error, backtrace)119+ Error::construct_from_boxed(error, backtrace)120 }121 }