Make private module more clearly private
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Tolnay · committed by David Tolnay · parent 6be2da9 · Browse files · 5 files·+29 added−29 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+29 added−29 removed
- tests:+1 added−1 removed
- other:+28 added−28 removed
Provenance
- Commit
b88a699- Tree
3f4dca5- Author
David Tolnay <dtolnay@gmail.com>- Committer
David Tolnay <dtolnay@gmail.com>- Parent
6be2da9
5 files changed+29 added−29 removed
modified:src/ensure.rs+10 added-10 removed
786 unmodified lines787 match (&$lhs, &$rhs) {788 (lhs, rhs) => {789 if !(lhs $op rhs) {790 #[allow(unused_imports)]791- use $crate::private::{BothDebug, NotBothDebug};791+ use $crate::__private::{BothDebug, NotBothDebug};792 return Err((lhs, rhs).__dispatch_ensure(793- $crate::private::concat!(793+ $crate::__private::concat!(794 "Condition failed: `",795- $crate::private::stringify!($lhs),795+ $crate::__private::stringify!($lhs),796 " ",797- $crate::private::stringify!($op),797+ $crate::__private::stringify!($op),798 " ",799- $crate::private::stringify!($rhs),799+ $crate::__private::stringify!($rhs),800 "`",801 ),802 ));803 }6 unmodified lines810 #[macro_export]811 macro_rules! __fallback_ensure {812 ($cond:expr $(,)?) => {813 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), "`")816 ));817 }818 };819 ($cond:expr, $msg:literal $(,)?) => {820 if !$cond {821- return $crate::private::Err($crate::__anyhow!($msg));821+ return $crate::__private::Err($crate::__anyhow!($msg));822 }823 };824 ($cond:expr, $err:expr $(,)?) => {825 if !$cond {826- return $crate::private::Err($crate::__anyhow!($err));826+ return $crate::__private::Err($crate::__anyhow!($err));827 }828 };829 ($cond:expr, $fmt:expr, $($arg:tt)*) => {830 if !$cond {831- return $crate::private::Err($crate::__anyhow!($fmt, $($arg)*));831+ return $crate::__private::Err($crate::__anyhow!($fmt, $($arg)*));832 }833 };834 }modified:src/kind.rs+1 added-1 removed
38 unmodified lines39 //40 // The anyhow! macro will set up the call in this form:41 //42 // #[allow(unused_imports)]43-// use $crate::private::{AdhocKind, TraitKind};43+// use $crate::__private::{AdhocKind, TraitKind};44 // let error = $msg;45 // (&error).anyhow_kind().new(error)46 47 use crate::Error;69 unmodified linesmodified:src/lib.rs+1 added-1 removed
632 unmodified lines633 }634 635 // Not public API. Referenced by macro-generated code.636 #[doc(hidden)]637-pub mod private {637+pub mod __private {638 use crate::Error;639 use alloc::fmt;640 use core::fmt::Arguments;641 39 unmodified linesmodified:src/macros.rs+16 added-16 removed
53 unmodified lines54 /// ```55 #[macro_export]56 macro_rules! bail {57 ($msg:literal $(,)?) => {58- return $crate::private::Err($crate::__anyhow!($msg))58+ return $crate::__private::Err($crate::__anyhow!($msg))59 };60 ($err:expr $(,)?) => {61- return $crate::private::Err($crate::__anyhow!($err))61+ return $crate::__private::Err($crate::__anyhow!($err))62 };63 ($fmt:expr, $($arg:tt)*) => {64- return $crate::private::Err($crate::__anyhow!($fmt, $($arg)*))64+ return $crate::__private::Err($crate::__anyhow!($fmt, $($arg)*))65 };66 }67 68 /// Return early with an error if a condition is not satisfied.50 unmodified lines119 #[macro_export]120 macro_rules! ensure {121 ($cond:expr $(,)?) => {122 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), "`")125 ));126 }127 };128 ($cond:expr, $msg:literal $(,)?) => {129 if !$cond {130- return $crate::private::Err($crate::__anyhow!($msg));130+ return $crate::__private::Err($crate::__anyhow!($msg));131 }132 };133 ($cond:expr, $err:expr $(,)?) => {134 if !$cond {135- return $crate::private::Err($crate::__anyhow!($err));135+ return $crate::__private::Err($crate::__anyhow!($err));136 }137 };138 ($cond:expr, $fmt:expr, $($arg:tt)*) => {139 if !$cond {140- return $crate::private::Err($crate::__anyhow!($fmt, $($arg)*));140+ return $crate::__private::Err($crate::__anyhow!($fmt, $($arg)*));141 }142 };143 }144 43 unmodified lines188 /// ```189 #[macro_export]190 macro_rules! anyhow {191 ($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));194 error195 })196 };197 ($err:expr $(,)?) => {198- $crate::private::must_use({199- use $crate::private::kind::*;198+ $crate::__private::must_use({199+ use $crate::__private::kind::*;200 let error = match $err {201 error => (&error).anyhow_kind().new(error),202 };203 error204 })205 };206 ($fmt:expr, $($arg:tt)*) => {207- $crate::Error::msg($crate::private::format!($fmt, $($arg)*))207+ $crate::Error::msg($crate::__private::format!($fmt, $($arg)*))208 };209 }210 211 // Not public API. This is used in the implementation of some of the other2 unmodified lines214 #[doc(hidden)]215 #[macro_export]216 macro_rules! __anyhow {217 ($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));219 error220 });221 ($err:expr $(,)?) => ({222- use $crate::private::kind::*;222+ use $crate::__private::kind::*;223 let error = match $err {224 error => (&error).anyhow_kind().new(error),225 };226 error227 });228 ($fmt:expr, $($arg:tt)*) => {229- $crate::Error::msg($crate::private::format!($fmt, $($arg)*))229+ $crate::Error::msg($crate::__private::format!($fmt, $($arg)*))230 };231 }modified:tests/ui/must-use.stderr+1 added-1 removed
1-error: unused return value of `anyhow::private::must_use` that must be used1+error: unused return value of `anyhow::__private::must_use` that must be used2 --> tests/ui/must-use.rs:8:93 |4 8 | anyhow!("it failed");5 | ^^^^^^^^^^^^^^^^^^^^7 unmodified lines