Skip to content

Commit b88a699

Browse files
committed
Make private module more clearly private
1 parent 6be2da9 commit b88a699

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

src/ensure.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -788,15 +788,15 @@ macro_rules! __fancy_ensure {
788788
(lhs, rhs) => {
789789
if !(lhs $op rhs) {
790790
#[allow(unused_imports)]
791-
use $crate::private::{BothDebug, NotBothDebug};
791+
use $crate::__private::{BothDebug, NotBothDebug};
792792
return Err((lhs, rhs).__dispatch_ensure(
793-
$crate::private::concat!(
793+
$crate::__private::concat!(
794794
"Condition failed: `",
795-
$crate::private::stringify!($lhs),
795+
$crate::__private::stringify!($lhs),
796796
" ",
797-
$crate::private::stringify!($op),
797+
$crate::__private::stringify!($op),
798798
" ",
799-
$crate::private::stringify!($rhs),
799+
$crate::__private::stringify!($rhs),
800800
"`",
801801
),
802802
));
@@ -811,24 +811,24 @@ macro_rules! __fancy_ensure {
811811
macro_rules! __fallback_ensure {
812812
($cond:expr $(,)?) => {
813813
if !$cond {
814-
return $crate::private::Err($crate::Error::msg(
815-
$crate::private::concat!("Condition failed: `", $crate::private::stringify!($cond), "`")
814+
return $crate::__private::Err($crate::Error::msg(
815+
$crate::__private::concat!("Condition failed: `", $crate::__private::stringify!($cond), "`")
816816
));
817817
}
818818
};
819819
($cond:expr, $msg:literal $(,)?) => {
820820
if !$cond {
821-
return $crate::private::Err($crate::__anyhow!($msg));
821+
return $crate::__private::Err($crate::__anyhow!($msg));
822822
}
823823
};
824824
($cond:expr, $err:expr $(,)?) => {
825825
if !$cond {
826-
return $crate::private::Err($crate::__anyhow!($err));
826+
return $crate::__private::Err($crate::__anyhow!($err));
827827
}
828828
};
829829
($cond:expr, $fmt:expr, $($arg:tt)*) => {
830830
if !$cond {
831-
return $crate::private::Err($crate::__anyhow!($fmt, $($arg)*));
831+
return $crate::__private::Err($crate::__anyhow!($fmt, $($arg)*));
832832
}
833833
};
834834
}

src/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
// The anyhow! macro will set up the call in this form:
4141
//
4242
// #[allow(unused_imports)]
43-
// use $crate::private::{AdhocKind, TraitKind};
43+
// use $crate::__private::{AdhocKind, TraitKind};
4444
// let error = $msg;
4545
// (&error).anyhow_kind().new(error)
4646

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ pub fn Ok<T>(t: T) -> Result<T> {
634634

635635
// Not public API. Referenced by macro-generated code.
636636
#[doc(hidden)]
637-
pub mod private {
637+
pub mod __private {
638638
use crate::Error;
639639
use alloc::fmt;
640640
use core::fmt::Arguments;

src/macros.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@
5555
#[macro_export]
5656
macro_rules! bail {
5757
($msg:literal $(,)?) => {
58-
return $crate::private::Err($crate::__anyhow!($msg))
58+
return $crate::__private::Err($crate::__anyhow!($msg))
5959
};
6060
($err:expr $(,)?) => {
61-
return $crate::private::Err($crate::__anyhow!($err))
61+
return $crate::__private::Err($crate::__anyhow!($err))
6262
};
6363
($fmt:expr, $($arg:tt)*) => {
64-
return $crate::private::Err($crate::__anyhow!($fmt, $($arg)*))
64+
return $crate::__private::Err($crate::__anyhow!($fmt, $($arg)*))
6565
};
6666
}
6767

@@ -120,24 +120,24 @@ macro_rules! bail {
120120
macro_rules! ensure {
121121
($cond:expr $(,)?) => {
122122
if !$cond {
123-
return $crate::private::Err($crate::Error::msg(
124-
$crate::private::concat!("Condition failed: `", $crate::private::stringify!($cond), "`")
123+
return $crate::__private::Err($crate::Error::msg(
124+
$crate::__private::concat!("Condition failed: `", $crate::__private::stringify!($cond), "`")
125125
));
126126
}
127127
};
128128
($cond:expr, $msg:literal $(,)?) => {
129129
if !$cond {
130-
return $crate::private::Err($crate::__anyhow!($msg));
130+
return $crate::__private::Err($crate::__anyhow!($msg));
131131
}
132132
};
133133
($cond:expr, $err:expr $(,)?) => {
134134
if !$cond {
135-
return $crate::private::Err($crate::__anyhow!($err));
135+
return $crate::__private::Err($crate::__anyhow!($err));
136136
}
137137
};
138138
($cond:expr, $fmt:expr, $($arg:tt)*) => {
139139
if !$cond {
140-
return $crate::private::Err($crate::__anyhow!($fmt, $($arg)*));
140+
return $crate::__private::Err($crate::__anyhow!($fmt, $($arg)*));
141141
}
142142
};
143143
}
@@ -189,22 +189,22 @@ macro_rules! ensure {
189189
#[macro_export]
190190
macro_rules! anyhow {
191191
($msg:literal $(,)?) => {
192-
$crate::private::must_use({
193-
let error = $crate::private::format_err($crate::private::format_args!($msg));
192+
$crate::__private::must_use({
193+
let error = $crate::__private::format_err($crate::__private::format_args!($msg));
194194
error
195195
})
196196
};
197197
($err:expr $(,)?) => {
198-
$crate::private::must_use({
199-
use $crate::private::kind::*;
198+
$crate::__private::must_use({
199+
use $crate::__private::kind::*;
200200
let error = match $err {
201201
error => (&error).anyhow_kind().new(error),
202202
};
203203
error
204204
})
205205
};
206206
($fmt:expr, $($arg:tt)*) => {
207-
$crate::Error::msg($crate::private::format!($fmt, $($arg)*))
207+
$crate::Error::msg($crate::__private::format!($fmt, $($arg)*))
208208
};
209209
}
210210

@@ -215,17 +215,17 @@ macro_rules! anyhow {
215215
#[macro_export]
216216
macro_rules! __anyhow {
217217
($msg:literal $(,)?) => ({
218-
let error = $crate::private::format_err($crate::private::format_args!($msg));
218+
let error = $crate::__private::format_err($crate::__private::format_args!($msg));
219219
error
220220
});
221221
($err:expr $(,)?) => ({
222-
use $crate::private::kind::*;
222+
use $crate::__private::kind::*;
223223
let error = match $err {
224224
error => (&error).anyhow_kind().new(error),
225225
};
226226
error
227227
});
228228
($fmt:expr, $($arg:tt)*) => {
229-
$crate::Error::msg($crate::private::format!($fmt, $($arg)*))
229+
$crate::Error::msg($crate::__private::format!($fmt, $($arg)*))
230230
};
231231
}

tests/ui/must-use.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: unused return value of `anyhow::private::must_use` that must be used
1+
error: unused return value of `anyhow::__private::must_use` that must be used
22
--> tests/ui/must-use.rs:8:9
33
|
44
8 | anyhow!("it failed");

0 commit comments

Comments
 (0)