about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2025-07-08 22:50:29 -0500
committerGitHub <noreply@github.com>2025-07-08 22:50:29 -0500
commit00aa4e1627bfb0890302da9fcb715cd34926f8c8 (patch)
treec94ea4e968e55783ce840f31111fa09749e2f062 /src
parentf1517ddae8a8090ad613c2c6b40eae9a8ede2959 (diff)
parente5f7d4d783c1567ddc16e02091bae8bacfca1418 (diff)
downloadrust-00aa4e1627bfb0890302da9fcb715cd34926f8c8.tar.gz
rust-00aa4e1627bfb0890302da9fcb715cd34926f8c8.zip
Rollup merge of #143520 - Stypox:enter_trace_span-closure, r=RalfJung
Fix perf regression caused by tracing

See rust-lang/rust#143334, this is another alternative that may be worth benchmarking as suggested in https://github.com/rust-lang/rust/pull/143334#issuecomment-3038953172.

r? ``@RalfJung``
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/src/machine.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs
index 693b8916d89..35399dbf4cb 100644
--- a/src/tools/miri/src/machine.rs
+++ b/src/tools/miri/src/machine.rs
@@ -1014,8 +1014,6 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
 
     const PANIC_ON_ALLOC_FAIL: bool = false;
 
-    const TRACING_ENABLED: bool = cfg!(feature = "tracing");
-
     #[inline(always)]
     fn enforce_alignment(ecx: &MiriInterpCx<'tcx>) -> bool {
         ecx.machine.check_alignment != AlignmentCheck::None
@@ -1827,6 +1825,16 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
         #[cfg(not(target_os = "linux"))]
         MiriAllocParams::Global
     }
+
+    fn enter_trace_span(span: impl FnOnce() -> tracing::Span) -> impl EnteredTraceSpan {
+        #[cfg(feature = "tracing")]
+        { span().entered() }
+        #[cfg(not(feature = "tracing"))]
+        {
+            let _ = span; // so we avoid the "unused variable" warning
+            ()
+        }
+    }
 }
 
 /// Trait for callbacks handling asynchronous machine operations.