Skip to content

Commit 0b8c9dd

Browse files
committed
Silence unused variable warnings for all log macros
Not just the error! macro.
1 parent c6fff67 commit 0b8c9dd

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

src/macros.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,31 +71,28 @@ macro_rules! cfg_any_os_ext {
7171

7272
macro_rules! trace {
7373
($($t:tt)*) => {
74-
#[cfg(feature = "log")]
75-
log::trace!($($t)*)
74+
log!(trace, $($t)*)
7675
}
7776
}
7877

7978
macro_rules! warn {
8079
($($t:tt)*) => {
81-
#[cfg(feature = "log")]
82-
log::warn!($($t)*)
80+
log!(warn, $($t)*)
8381
}
8482
}
8583

8684
macro_rules! error {
8785
($($t:tt)*) => {
88-
#[cfg(feature = "log")]
89-
{
90-
log::error!($($t)*)
91-
}
86+
log!(error, $($t)*)
87+
}
88+
}
9289

93-
// Silence warnings
90+
macro_rules! log {
91+
($level: ident, $($t:tt)*) => {
92+
#[cfg(feature = "log")]
93+
{ log::$level!($($t)*) }
94+
// Silence unused variables warnings.
9495
#[cfg(not(feature = "log"))]
95-
{
96-
if false {
97-
format!($($t)*);
98-
}
99-
}
96+
{ if false { let _ = ( $($t)* ); } }
10097
}
10198
}

0 commit comments

Comments
 (0)