Skip to content

Commit ab2dced

Browse files
committed
windows: Properly hide all win32-trace code behind conditionals
Make sure all code related to the `win32-trace` feature is compiled only when the feature is enabled. This avoids unnecessary bloat; as well as potential compile errors when other code conditional on this feature is added.
1 parent 1ce2631 commit ab2dced

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/platform/windows/mod.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use libc::intptr_t;
1414
use std::cell::{Cell, RefCell};
1515
use std::cmp::PartialEq;
1616
use std::default::Default;
17+
#[cfg(feature = "win32-trace")]
1718
use std::env;
1819
use std::ffi::CString;
1920
use std::io::{Error, ErrorKind};
@@ -33,14 +34,17 @@ use self::aliased_cell::AliasedCell;
3334
lazy_static! {
3435
static ref CURRENT_PROCESS_ID: winapi::ULONG = unsafe { kernel32::GetCurrentProcessId() };
3536
static ref CURRENT_PROCESS_HANDLE: WinHandle = WinHandle::new(unsafe { kernel32::GetCurrentProcess() });
37+
}
3638

39+
#[cfg(feature = "win32-trace")]
40+
lazy_static! {
3741
static ref DEBUG_TRACE_ENABLED: bool = { env::var_os("IPC_CHANNEL_WIN_DEBUG_TRACE").is_some() };
3842
}
3943

4044
/// Debug macro to better track what's going on in case of errors.
4145
macro_rules! win32_trace {
4246
($($rest:tt)*) => {
43-
if cfg!(feature = "win32-trace") {
47+
#[cfg(feature = "win32-trace")] {
4448
if *DEBUG_TRACE_ENABLED { println!($($rest)*); }
4549
}
4650
}
@@ -1023,8 +1027,8 @@ impl OsIpcReceiver {
10231027
},
10241028

10251029
// Anything else signifies some actual I/O error.
1026-
err => {
1027-
win32_trace!("[$ {:?}] accept error -> {}", handle.as_raw(), err);
1030+
_err => {
1031+
win32_trace!("[$ {:?}] accept error -> {}", handle.as_raw(), _err);
10281032
Err(WinError::last("ConnectNamedPipe"))
10291033
},
10301034
};
@@ -1706,8 +1710,8 @@ impl WinError {
17061710
}
17071711
}
17081712

1709-
fn from_system(err: u32, f: &str) -> WinError {
1710-
win32_trace!("WinError: {} ({}) from {}", WinError::error_string(err), err, f);
1713+
fn from_system(err: u32, _f: &str) -> WinError {
1714+
win32_trace!("WinError: {} ({}) from {}", WinError::error_string(err), err, _f);
17111715
WinError::WindowsResult(err)
17121716
}
17131717

0 commit comments

Comments
 (0)