Skip to content

Commit ffecefc

Browse files
authored
Merge pull request #401 from dtolnay/construct
Add `construct_` prefix to name of private construct functions
2 parents 8ceb5e9 + 671f700 commit ffecefc

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

src/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mod ext {
2525
C: Display + Send + Sync + 'static,
2626
{
2727
let backtrace = backtrace_if_absent!(&self);
28-
Error::from_context(context, self, backtrace)
28+
Error::construct_from_context(context, self, backtrace)
2929
}
3030
}
3131

@@ -96,7 +96,7 @@ impl<T> Context<T, Infallible> for Option<T> {
9696
// backtrace.
9797
match self {
9898
Some(ok) => Ok(ok),
99-
None => Err(Error::from_display(context, backtrace!())),
99+
None => Err(Error::construct_from_display(context, backtrace!())),
100100
}
101101
}
102102

@@ -107,7 +107,7 @@ impl<T> Context<T, Infallible> for Option<T> {
107107
{
108108
match self {
109109
Some(ok) => Ok(ok),
110-
None => Err(Error::from_display(context(), backtrace!())),
110+
None => Err(Error::construct_from_display(context(), backtrace!())),
111111
}
112112
}
113113
}

src/error.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Error {
3636
E: StdError + Send + Sync + 'static,
3737
{
3838
let backtrace = backtrace_if_absent!(&error);
39-
Error::from_std(error, backtrace)
39+
Error::construct_from_std(error, backtrace)
4040
}
4141

4242
/// Create a new error object from a printable error message.
@@ -82,12 +82,12 @@ impl Error {
8282
where
8383
M: Display + Debug + Send + Sync + 'static,
8484
{
85-
Error::from_adhoc(message, backtrace!())
85+
Error::construct_from_adhoc(message, backtrace!())
8686
}
8787

8888
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
8989
#[cold]
90-
pub(crate) fn from_std<E>(error: E, backtrace: Option<Backtrace>) -> Self
90+
pub(crate) fn construct_from_std<E>(error: E, backtrace: Option<Backtrace>) -> Self
9191
where
9292
E: StdError + Send + Sync + 'static,
9393
{
@@ -113,7 +113,7 @@ impl Error {
113113
}
114114

115115
#[cold]
116-
pub(crate) fn from_adhoc<M>(message: M, backtrace: Option<Backtrace>) -> Self
116+
pub(crate) fn construct_from_adhoc<M>(message: M, backtrace: Option<Backtrace>) -> Self
117117
where
118118
M: Display + Debug + Send + Sync + 'static,
119119
{
@@ -142,7 +142,7 @@ impl Error {
142142
}
143143

144144
#[cold]
145-
pub(crate) fn from_display<M>(message: M, backtrace: Option<Backtrace>) -> Self
145+
pub(crate) fn construct_from_display<M>(message: M, backtrace: Option<Backtrace>) -> Self
146146
where
147147
M: Display + Send + Sync + 'static,
148148
{
@@ -172,7 +172,11 @@ impl Error {
172172

173173
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
174174
#[cold]
175-
pub(crate) fn from_context<C, E>(context: C, error: E, backtrace: Option<Backtrace>) -> Self
175+
pub(crate) fn construct_from_context<C, E>(
176+
context: C,
177+
error: E,
178+
backtrace: Option<Backtrace>,
179+
) -> Self
176180
where
177181
C: Display + Send + Sync + 'static,
178182
E: StdError + Send + Sync + 'static,
@@ -202,7 +206,7 @@ impl Error {
202206

203207
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
204208
#[cold]
205-
pub(crate) fn from_boxed(
209+
pub(crate) fn construct_from_boxed(
206210
error: Box<dyn StdError + Send + Sync>,
207211
backtrace: Option<Backtrace>,
208212
) -> Self {
@@ -562,7 +566,7 @@ where
562566
#[cold]
563567
fn from(error: E) -> Self {
564568
let backtrace = backtrace_if_absent!(&error);
565-
Error::from_std(error, backtrace)
569+
Error::construct_from_std(error, backtrace)
566570
}
567571
}
568572

src/kind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl Adhoc {
7070
where
7171
M: Display + Debug + Send + Sync + 'static,
7272
{
73-
Error::from_adhoc(message, backtrace!())
73+
Error::construct_from_adhoc(message, backtrace!())
7474
}
7575
}
7676

@@ -116,6 +116,6 @@ impl Boxed {
116116
#[cold]
117117
pub fn new(self, error: Box<dyn StdError + Send + Sync>) -> Error {
118118
let backtrace = backtrace_if_absent!(&*error);
119-
Error::from_boxed(error, backtrace)
119+
Error::construct_from_boxed(error, backtrace)
120120
}
121121
}

0 commit comments

Comments
 (0)