Skip to content

Commit 6c946ae

Browse files
committed
Fix compiler warnings
1 parent 7433a2a commit 6c946ae

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed

src/plan/tracing.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
use crate::scheduler::gc_work::{ProcessEdgesWork, SlotOf};
55
use crate::scheduler::{GCWorker, WorkBucketStage};
6+
#[cfg(debug_assertions)]
67
use crate::util::log;
78
use crate::util::ObjectReference;
89
use crate::vm::SlotVisitor;

src/util/copy/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::policy::copyspace::CopySpaceCopyContext;
88
use crate::policy::immix::ImmixSpace;
99
use crate::policy::immix::{ImmixCopyContext, ImmixHybridCopyContext};
1010
use crate::policy::space::Space;
11+
#[cfg(debug_assertions)]
1112
use crate::util::log;
1213
use crate::util::object_forwarding;
1314
use crate::util::opaque_pointer::VMWorkerThread;

src/util/log.rs

+34-22
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,43 @@ use the_log_crate;
1313

1414
pub(crate) use the_log_crate::{error, info, warn};
1515

16-
cfg_if::cfg_if! {
17-
if #[cfg(all(not(debug_assertions), not(feature = "hot_log")))] {
18-
// If it is release build and the feature "hot_log" is not enabled,
19-
// then we define verbose logs as no-op in release build.
16+
/// Whether logs of DEBUG and TRACE levels are enabled.
17+
/// In debug build, they are always enabled.
18+
/// In release build, they are not enabled unless the "hot_log" Cargo feature is enabled.
19+
pub(crate) const HOT_LOG_ENABLED: bool = cfg!(any(not(debug_assertions), feature = "hot_log"));
2020

21-
/// The `log::debug!` macro is disabled in release build.
22-
/// Use the "hot_log" feature to enable.
23-
macro_rules! debug {
24-
($($arg:tt)+) => {}
21+
/// A wrapper of the `debug!` macro in the `log` crate.
22+
/// Does nothing if [`HOT_LOG_ENABLED`] is false.
23+
macro_rules! debug {
24+
(target: $target:expr, $($arg:tt)+) => {
25+
if $crate::util::log::HOT_LOG_ENABLED {
26+
the_log_crate::debug!(target: $target, $($arg)+)
2527
}
26-
27-
/// The `log::trace!` macro is disabled in release build.
28-
/// Use the "hot_log" feature to enable.
29-
macro_rules! trace {
30-
($($arg:tt)+) => {}
28+
};
29+
($($arg:tt)+) => {
30+
if $crate::util::log::HOT_LOG_ENABLED {
31+
the_log_crate::debug!($($arg)+)
3132
}
33+
}
34+
}
3235

33-
// By default, a macro has no path-based scope.
34-
// The following allows other modules to access the macros with `crate::util::log::debug`
35-
// and `crate::util::log::trace`.
36-
pub(crate) use debug;
37-
pub(crate) use trace;
38-
39-
} else {
40-
// Otherwise simply import the macros from the `log` crate.
41-
pub(crate) use the_log_crate::{debug, trace};
36+
/// A wrapper of the `trace!` macro in the `log` crate.
37+
/// Does nothing if [`HOT_LOG_ENABLED`] is false.
38+
macro_rules! trace {
39+
(target: $target:expr, $($arg:tt)+) => {
40+
if $crate::util::log::HOT_LOG_ENABLED {
41+
the_log_crate::trace!(target: $target, $($arg)+)
42+
}
43+
};
44+
($($arg:tt)+) => {
45+
if $crate::util::log::HOT_LOG_ENABLED {
46+
the_log_crate::trace!($($arg)+)
47+
}
4248
}
4349
}
50+
51+
// By default, a macro has no path-based scope.
52+
// The following allows other modules to access the macros with `crate::util::log::debug`
53+
// and `crate::util::log::trace`.
54+
pub(crate) use debug;
55+
pub(crate) use trace;

src/vm/scanning.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub trait SlotVisitor<SL: Slot> {
1515
/// This lets us use closures as SlotVisitor.
1616
impl<SL: Slot, F: FnMut(SL)> SlotVisitor<SL> for F {
1717
fn visit_slot(&mut self, slot: SL) {
18-
#[cfg(debug_assertions)]
1918
log::trace!(
2019
"(FunctionClosure) Visit slot {:?} (pointing to {:?})",
2120
slot,

0 commit comments

Comments
 (0)